B2.3.1 · dive 1 of 3 · module B2.3
Structural sharing.
A persistent map: a new version copies only the path to the change and shares every untouched subtree with the old. A snapshot is the old root kept, and it costs nothing.
The idea
echo_data · champ_node.ex, branded_champ.exA CHAMP is a persistent map: updating it returns a new version while the old one stays valid and unchanged. It does this by sharing — a new version copies only the nodes on the path from the root to the change, and points at every untouched subtree the old version already held. A snapshot, then, is the old root kept; taking one costs nothing.
The node layout is what keeps the sharing tight. Each node carries two 32-bit bitmaps over one compact tuple — a datamap marking inline key-value pairs and a nodemap marking child nodes — with five-bit fragments of the hash driving 32-way branching down a handful of levels. A change rewrites a short spine of small nodes, not the map; the rest is reused by reference.
Codemojex wants this every time it shows or rewinds a game. A snapshot of a room for a spectator, a round preserved for replay, an undo of the last move — each is a cheap new root over a shared structure, not a copy of the board. The old state remains exactly itself, which is what makes versioning and broadcast affordable.
The doors
the sibling coursesEchoMQ — the protocol, in depth
The bus B3 narrates, taught rung by rung: the keyspace, the Lua inventory, and the 3.0 Stream Tier — XADD, XREADGROUP, XACK — with conformance on Valkey.
Redis Patterns Applied
The substrate patterns under the bus: sorted sets, atomic Lua moves, locks, and streams — the judgement layer.
/echo-persistenceEcho Persistence — the durable floor
Beneath the volatile tiers: the Graft page engine built twice, the commit-LSN loop, and the stream archive on Tigris. Where Part I says state lives somewhere, this says where it lives durably.
References
sources · relatedSources
- Steindorfer & Vinju — CHAMP (OOPSLA 2015)the compressed hash-array-mapped prefix tree, two bitmaps per node
- King — Announcing Snowflake (2010)time-ordered ids whose key order is mint order
- Helland — Life Beyond Distributed Transactions (CIDR 2007)durable entities a restarted system rehydrates by name
Related
- BCS — the course homethe law, the id anatomy, the chapter map
- Echo Persistencethe durable floor beneath the bus