Module 2 · Dive 2.1
The in-heap structure.
Champ keeps the outbox in a persistent map — a hash-array-mapped trie, the BEAM’s native immutable kind. Updating it does not mutate; it returns a new version that shares almost everything with the old one. That one property is why a snapshot costs nearly nothing: keep the old root. Click a slot and watch the sharing.
Why the accept tier wants this
graft.design.mdTwo consequences fall straight out, and both serve the accept tier. A snapshot is a reference: to checkpoint, Champ keeps the current root and hands it to the writer that fsyncs it, while accepts keep producing newer roots — no copy, no stop-the-world. And readers are lock-free: a reader holds a root and sees a consistent version no matter how many writes follow. The next dive turns the checkpoint into a dial; this is the property that makes it cheap.
References & sources
- External
- Hash array mapped triethe structure Champ uses
- Persistent data structuresstructural sharing, path copying
- CHAMP — efficient immutable mapsthe compressed HAMT family
- Echo records
- store.design.mdthe in-heap accept structure
- graft.design.mdthe snapshot-as-reference checkpoint