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.
Many roots, one pool
interactiveWhy keeping versions is free
graft.design.mdRetaining 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.
References & sources
- External
- Persistent data structuresmany versions, shared nodes
- CubDB.Snapshota snapshot is a retained root
- Multiversion concurrency controlcoexisting versions
- Echo records
- graft.design.mddelta snapshots, the per-version diff
- store.design.mdretained roots on CubDB