jonnify·persistence /echo-persistence/mvcc-time-travel/coexisting-versions

Module 5 · Dive 5.1

Coexisting versions.

Copy-on-write keeps every old root, so many versions are alive at once — all of them rooted in one shared pool of immutable nodes. A newer version reuses almost all of the older one’s nodes and adds a few of its own. A snapshot, then, is nothing but a root into that pool. Click a version and watch what it reaches.

§1

Many roots, one pool

interactive
Versions share a node pool. Three roots over five immutable nodes. Click a version: the nodes it reaches light up — teal for shared, amber for its own — and the others dim.
shared immutable node pool (never mutated):
readout · Click a version. It reaches three nodes; the ones it shares with the prior version are teal, its own new node is amber. All three versions coexist in the same pool — no version is a copy.
§2

Why keeping versions is free

graft.design.md

Retaining an old version costs nothing extra because its nodes already exist in the pool — they were never overwritten, and the newer versions simply don’t reference the few they replaced. So “take a snapshot” is “remember this root,” an O(1) act, and a Volume can hold many readable points at once for the price of the diffs between them. That is the engine behind delta snapshots and checkout-at-LSN: the deltas are exactly the per-version new nodes you see in amber. The only growth is those diffs — which is what compaction (Dive 4.3) and GC (Dive 5.3) keep in check.

§3

References & sources