Three days offline: 144 million transforms, or one?
transcript
One person reconnects to a shared doc. And 30 people could stop seeing each other's typing. For over two minutes.
Kabir edits the quarterly report offline for three days. 2,400 changes. Meanwhile, 25 colleagues make 60,000 revisions. Transform each of his past each of theirs? 144 million transforms.
At a microsecond each, that's about 144 seconds. On the document server's thread. Everyone else waits behind it.
Here's the trick. Don't transform one by one. Compose first. Their 60,000 revisions squash into one change. His 2,400 squash into one too. Now it's one transform. Milliseconds.
Why does that work? One by one, the cost grows with every edit. A composed change can't be bigger than the document itself. And a background worker composes it. The server's thread never stalls.
But here's the catch. It only works while his base is in the fine-grained window. Older than that? Fall back to a three-way merge, like a code merge.
Don't replay three days one step at a time. Squash both sides. Then merge once.
Full breakdown in the lecture.