B2.3 · dive 2 — sharing at the honest metric
A version is a path, not a map.
H2 writes a thousand ORD rows into v1, derives v2
with one more put, and gates the defining property: v1 holds 1000, v2 holds 1001, and the new row
never appears in v1. H3 then counts heap words — and records a methods lesson worth keeping.
Source: content/bcs2.3.md; the gates are H2 and H3 in
bcs_rung_2_3_check.out; the committed figures: 122 words beside v1, against 6688
standalone — 98% shared.
The transcript
bcs_rung_2_3_check.out · verbatim · this dive reads H2 and H3H2 persist ok -- the old snapshot is intact: v1 holds 1000, v2 holds 1001, and v1 cannot see the new row H3 sharing ok -- structural sharing measured: v2 costs 122 words beside v1 (one path copy) against 6688 standalone -- 98% of v2 is shared with v1
The full record — all seven gates, the mid-record [debug] boot line
included — is frozen on the module hub; it closes
PASS 7/7.
H2 — the old snapshot is intact
content/bcs2.3.md · WhatPersistence here is the data-structure sense of the word: deriving v2 does
not edit v1. H2 writes a thousand rows, derives a successor with one more put, and gates the
defining property — each version is a complete, immutable value, and the new row is absent from the old
binding. Holding a version is holding a snapshot; nothing about the derivation reaches back into it.
H3 — the denominator trap
content/bcs2.3.md · What · DecisionsThe first metric — “percent of the pair shared” — mathematically caps near fifty for two near-identical structures and failed a correct implementation: when two structures of about the same size share nearly everything, the shared words divided by the words of the pair approach one half no matter how complete the sharing is. The denominator carries both copies; the ceiling is structural, not a defect in the trie.
The metric of record is marginal cost: v2 costs 122 words beside v1 (one path
copy) against 6688 standalone -- 98% of v2 is shared with v1. The manuscript documents the trap
so it is paid for once. A write is a root-to-leaf path — 122 words at a thousand entries — and
everything off the path is the previous version, shared. A version is a path; a thousand versions are a
thousand paths, not a thousand maps.
The committed anchor, verbatim from H3: one derived version costs 122 words beside its predecessor; the same structure standalone is 6688 words; 98% of v2 is shared with v1. Larger n values are the model's straight-line extension of that pair, labelled as such.
References
sources · relatedSources
- Steindorfer & Vinju — Optimizing Hash-Array Mapped Tries (OOPSLA 2015)the node design whose paths the gate counts in words
- Erlang/OTP — the ets modulethe flat table whose snapshot is a copy-out, priced per row
Related
- B2.3 — The CHAMP Property Databasethe module hub; the full rung in context
- B2 — The Elixir BCS Corethe chapter landing; the Part II arc
- B2.2 — Property Stores on ETSthe present-tense store the forest stands beside
- Functional Programming in Elixirthe umbrella where echo_data lives