jonnify·bcs /bcs/ideas/branding-beats-its-own-integer/the-whole-system-accounting

B1.6 · dive — the whole-system accounting

Minted once, cheaper forever.

An id is rendered once and then stored, compared, and transmitted for the rest of its life. The brand’s per-mint cost ranges from minus 13 nanoseconds (Rust) to plus 335 (today’s Node); its per-life return is fixed: 8 bytes per key at rest on the measured table (65 against 73), 5 bytes on every wire hop, and a fixed-width, type-bearing token at every gate.

Source: content/bcs1.a1.md · the whole-system accounting + boundaries. The per-mint column is the only one where the brand ever pays.

The life of an id. Select a station to read its line of the ledger — paid once at the mint, returned at every station after it.
the mint paid once −13 ns … +335 ns the store at rest, for life 8 bytes per key · 65 vs 73 the wire every hop 5 bytes per hop · 14 vs 19 the gate every check fixed-width, type-bearing
readout · Select a station. Static reading: the per-mint cost ranges from minus 13 nanoseconds (Rust) to plus 335 (today’s Node); the per-life return is fixed — 8 bytes per key at rest (65 against 73), 5 bytes on every wire hop (14 bytes against 19 digits), and a fixed-width, type-bearing token at every gate.
§1

Minted once, cheaper forever

content/bcs1.a1.md · the whole-system accounting

Even the worst case amortizes immediately — a Node service minting ten thousand ids a second spends 3.35 milliseconds of CPU per second, a third of one percent of a core, while every one of those keys is cheaper in the store and shorter on every message it ever rides. The sentence from Chapter 1.3 survives the CPU question intact, with one runtime’s asterisk and its remedy already named: the contract’s wire form is cheaper than the “lean” alternative it is usually defended against.

content/echo_data/bench/branding-vs-decimal/node_bench.out · the worst casefrozen
v22.22.2
node branded ns/op=381
node decimal ns/op=45.6

The loss is real and it sits in exactly the place the contract prescribes the wasm crossing — the wasm codec already serves decode and hash32 through the loader, and an encode export is the carried follow-up. Until it lands, the arithmetic below keeps the loss in proportion.

§2

The worst-case arithmetic, stepped

computed live from node_bench.out
Three steps, computed live. Each step is arithmetic over the committed numbers — nothing measured, everything checkable by hand.
readout · Select a step. Static arithmetic: 381 − 45.6 → plus 335 nanoseconds per mint; 10,000 mints a second × 335 ns → 3.35 milliseconds of CPU per second; 3.35 ms in 1,000 → a third of one percent of a core.

That is the whole bill for the worst runtime on the table, at a mint rate few services reach — and every one of those ten thousand keys per second is 8 bytes cheaper at rest and 5 bytes shorter on every hop, for as long as it lives.

§3

Boundaries

content/bcs1.a1.md · boundaries

One host, the recorded toolchains; ratios travel better than absolute numbers. The Go rows compare what the APIs return, so the regime note is part of the result, not a caveat to it. The Elixir row is the native path; the pure path is conformance-covered but not separately timed here. The Node row is the pure-TypeScript implementation by construction — the wasm encode export does not exist yet, which is the point of measuring its absence. Storage figures and their allocator-class mechanics are Chapter 1.3’s, inherited verbatim:

content/echo_data/bench/valkey-id/valkey_id_bench.out · the per-life return at restfrozen
fmt     keylen  redis7  valkey81  saved
brd14   14      88      65        23
u64dec  19      104     73        31

The bus this return rides is Part III’s subject — EchoMQ, where every job key, stream entry, and lock token is a branded id on the wire. The hops this ledger counts are taught in depth on the far side of that door.

§4

References

sources · related

Sources

Related