jonnify·bcs /bcs/elixir-core/champ/sharing-at-the-honest-metric

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.

Two versions, one structure. The derivation drawn: two roots, one copied path, and the subtrees both roots reach. Select a region to read what the gates measured there.
v1 holds 1000 — unchanged v2 holds 1001 — one put away one path copy 122 words beside v1 the shared region 98% of v2 is shared with v1 — everything off the path
readout · Select a region. Two complete, immutable values stand over one structure; the only new heap between them is the copied root-to-leaf path, and the gates priced it.
§1

The transcript

bcs_rung_2_3_check.out · verbatim · this dive reads H2 and H3
content/echo_data/runtimes/elixir/bcs_rung_2_3_check.out · the H2 and H3 lines, verbatimfrozen
H2 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.

§2

H2 — the old snapshot is intact

content/bcs2.3.md · What

Persistence 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.

§3

H3 — the denominator trap

content/bcs2.3.md · What · Decisions

The 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 word-cost calculator. A pure function over the two committed figures — 122 words per derived version, 6688 words standalone — extends the gate's arithmetic to n versions. Select n; the readout shows both totals and the ratio.
readout · Select a version count. The model: forest words = 6688 + (n − 1) × 122, against n × 6688 standalone copies — anchored on the committed pair, extended by arithmetic.

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.

§4

References

sources · related

Sources

Related