Chapter 23Down the Rabbit Hole: Merging Text Without a Server, From Fugue to Eg-walker
The number that pulled me in came from the Eg-walker paper. On one offline-heavy editing trace, textbook operational transformation took 61.1 minutes to merge two divergent histories. Eg-walker took 23.5 milliseconds on the same machine. That's a different shape of algorithm, not a constant-factor win.
So how do you merge two separately edited copies, with no server deciding who went first, and still get text a human can read?
Positions lie#
Two people hold Helo. User 1 inserts l at index 3. User 2, concurrently, appends ! at index 4. On User 1's machine the document is now Hello, and User 2's "insert at 4" lands wrong: Hell!o. The index was written against a version that no longer exists.
Operational transformation shifts indexes (4 becomes 5) by transforming each concurrent operation against the others. Google Docs does this with a central server serialising edits. But every pair of concurrent operations must be transformed, and that's where the 61 minutes come from.
Names, not numbers#
A sequence CRDT removes the problem at the source. Every character gets a permanent ID, say H1 e2 l3 o4, and User 2's edit becomes "insert ! after o4". That means the same thing on every replica, so operations commute and replicas that saw the same operations converge.
It hides two problems:
- Deletion. Someone may delete
o4while an offline collaborator still sends "insert aftero4". So deleted characters stay as tombstones, until every replica is known to have seen the delete. - Ties. The nasty one.
A tie-break can shred words#
The Fugue paper's example: a list says milk; one user types eggs after it, the other bread at the same spot. "After milk" no longer names a unique place, so a deterministic rule must order them. A careless rule gives ebgrgesad. Every replica agrees on it. Nobody can read it.
This is interleaving: a readability bug, not a convergence bug, so all the correctness proofs pass.
Here's the cleanest case from the dive's simulation. Two users start from XZ. Each types a three-letter word backwards at the same spot (insert c at index 1, then b, then a), like building a list by adding at the top.
forward typing (a, b, c)
RGA -> XxyzabcZ runs stay whole
Fugue -> XabcxyzZ runs stay whole
backward typing (c, b, a)
RGA -> XxaybzcZ INTERLEAVED
Fugue -> XabcxyzZ runs stay wholeWhy RGA interleaves
RGA places a new character right after its anchor, then skips any neighbour with a newer ID, so concurrent siblings end up in descending ID order:
place e after e.prev, then skip while next.id > e.id
id = (lamport_counter, replica)Typing backwards gives every character the same anchor (X), so all six are siblings. A's IDs are (3,A) (4,A) (5,A), B's (3,B) (4,B) (5,B). Sorted descending they alternate: x a y b z c. Typing forwards anchors each character to the previous one, so it comes out fine. The rule compares IDs, never which run a character belongs to.
Fugue: make a run a subtree#
Weidner and Kleppmann's Fugue changes the data's shape: characters hang in a tree. To insert, take the character before as the left origin. If it has no right child, the new one becomes its right child. Otherwise it becomes a left child of the next element, the right origin. The document is an in-order walk, same-side siblings in ID order:
order(n) = order(L1) ++ ... ++ order(Lp) ++ [n] ++ order(Rq)An in-order walk emits any subtree as one contiguous block. Here X already has Z as right child, so c becomes a left child of Z, b of c, a of b. Each user's word is a chain, so concurrent inserts land before or after it, never inside.
X
Z
╱ ╲
(A's c) (B's z) in-order walk:
╱ ╱ X [a b c] [x y z] Z
(A's b) (B's y)
╱ ╱ each chain is contiguous,
(A's a) (B's x) so words never interleave(Schematic: two left-child chains under Z, one per user. Tie order between the chains is by ID.)
Convergence comes free: the order depends only on the set of nodes (parent, side, ID), never arrival order.
Fugue's paper also defines "non-interleaving" precisely. The 2019 PaPoC paper that named the bug now carries errata: its definition can't be satisfied by any algorithm and its algorithm doesn't converge. Fugue's "maximal non-interleaving" is the repair, and FugueMax provably achieves it. Even the paper that named the bug had a bug.
The bill: metadata#
Nothing is ever forgotten. In the Fugue benchmark, a 105 kB document saves to 168 kB (about 60% metadata) and costs roughly 23 bytes of memory per character. Yjs saves the same document in 160 kB. Naive Fugue and FugueMax cost 618 and 685 bytes per character, which is why run-length encoding and B-trees matter more than the pseudocode. On the paper's traces, Automerge used 241 to 848 MiB of RAM while merging.
Eg-walker: keep the log, not the CRDT#
Gentle and Kleppmann's Eg-walker flips the design. Each replica stores the event graph (every edit, pointing at the edits its author had seen) and the current text as a plain string. No CRDT on disk, no per-character IDs in memory.
The temporary structure tracks two states per character, and three operations move between them: apply, retreat (remove from the prepare version) and advance (add back).
s_p in {NotInsertedYet, Ins, Del 1, Del 2, ...}
s_e in {Ins, Del}s_e: does the character exist in the latest document. s_p: did it exist at the version this event was written against, and how many deletions hit it. The count matters because two users may delete the same character; retreating one deletion must not resurrect it while the other applies.
Why it's fast: most history is a straight line. At a critical version, where every earlier event is an ancestor and every later one a descendant, nothing is concurrent, so the temporary state can be cleared. Work scales with the concurrent stretch, not the whole history.

Figure 8 from Gentle and Kleppmann, "Collaborative Text Editing with Eg-walker: Better, Faster, Smaller" (EuroSys 2025), arXiv:2409.14252, licensed CC BY 4.0. Recompressed, white margins trimmed.
On the log axis, OT is competitive while history is a straight line, then falls off a cliff on real divergence: 6.3 seconds on A1, 61.1 minutes on A2. Eg-walker stays in milliseconds throughout, with steady-state memory of 432 KiB on A2. Loading is just reading cached text: 0.01 to 0.12 ms across all seven traces.
The clearing ablation
Clearing at critical versions matters on sequential traces: S1 goes from 1.8 ms with clearing to 9.8 ms without. On A2, which has no critical versions, it barely changes: 23.5 ms against 23.7 ms.
Where it still breaks#
- Plain text only. Rich text is future work, and the critical-version cut doesn't hold for Peritext because of how it processes concurrent annotations.
- Worst case on an adversarial graph is
O(n² log n); a poor traversal order made one trace up to 8x slower. - The asynchronous traces were reconstructed from Git history, not recorded keystrokes, and the OT baseline is a simple textbook algorithm, not a production one.
- Tombstones remain a problem everywhere. You can drop one only when the deletion is causally stable, and in open peer-to-peer systems you don't know every replica.
- "Converged" isn't "correct". Two rewrites of the same sentence both survive as gibberish every replica agrees on.
The open question#
Is Eg-walker itself maximally non-interleaving? It still needs a tie-break inside its temporary state, using a Yjs-style rule. Its authors conjecture the property and leave the analysis to future work. Fugue's proof is for a tree; the Yjs-style rule orders through origins in a flat list with different invariants, so the proof doesn't carry over.
The arc as I see it: make replicas agree, make agreement readable, make it cheap. Eg-walker took a big swing at cheap. Whether it kept readable is still open, and rich text, undo and moves wait behind it.
Sources#
- Gentle and Kleppmann, Collaborative Text Editing with Eg-walker: Better, Faster, Smaller, EuroSys 2025
- Weidner and Kleppmann, The Art of the Fugue: Minimizing Interleaving in Collaborative Text Editing, IEEE TPDS 2025
- Kleppmann et al., Interleaving anomalies in collaborative text editors, PaPoC 2019 (with errata)
- Roh et al., Replicated Abstract Data Types, JPDC 2011 (RGA)
- Litt et al., Peritext, CSCW 2022
- Bauwens and Gonzalez Boix, From Causality to Stability, MPLR 2020
- Seph Gentle, CRDTs go brrr
- Google Drive blog, What's different about the new Google Docs, 2010
- Yjs, Automerge, Loro, eg-walker-reference