jonnify·bcs /bcs/ideas/branding-beats-its-own-integer

B1.6 · Branding Beats Its Own Integer — manuscript appendix 1.1

Branding beats its own integer.

Chapter 1.3 measured a sentence worth promoting to its own appendix: the same snowflake rendered as decimal text (19 digits) costs 73 bytes per key on Valkey’s new table, eight more than its 14-byte branded base62 form at 65. At the storage layer the brand is a discount, not a tax. This module asks the follow-up the finding deserves: does the CPU agree? The encode path — u64 in, text out — is measured in all five runtimes of the canon, against the real implementations, with the decimal rendering as the opponent in each.

The module teaches content/bcs1.a1.md. The answer has texture: the compiled runtimes agree emphatically, the BEAM records a tie, and V8 records the one loss — in exactly the place the contract already prescribes a native crossing.

The verdict, per runtime. Select a runtime to read its measured branded and decimal encode costs and the one-line verdict — a lookup over the committed table.
C 7.21 vs 20.49 2.8× — the brand wins Rust 5.14 vs 21.77 4.2× — the brand wins Go 40.02 ns/op a split — API regimes Elixir 132.5 vs 133.6 a tie — native crossing Node 381 vs 45.6 8.4× — the one loss
readout · Select a runtime. Static reading: C 7.21 against 20.49, Rust 5.14 against 21.77, Go 40.02 in a split across API regimes, Elixir 132.5 against 133.6 — a tie, Node 381 against 45.6 — the one loss, all ns/op from the committed outputs.
§1

The question the storage record earned

content/bcs1.a1.md · scope and method

The storage verdict is already committed: 65 bytes per key for the 14-byte branded form against 73 for its own 19-digit decimal rendering, on Valkey 8.1’s single-allocation entries — five fewer bytes pushed the embedded object down one allocator size class. A discount at rest says nothing about the clock. The appendix puts the encode path itself on the bench, runtime by runtime, and inherits the storage rows verbatim rather than re-measuring them.

Method, as recorded in the committed outputs: each runtime encodes snowflakes with the low 20 bits varied (to defeat constant folding), accumulates a byte of each output into a sink (to defeat dead-code elimination), and reports the best of three runs — five on Node. Toolchains as recorded under bench/branding-vs-decimal/: cc 13.3.0 at -O2, rustc 1.75.0, go 1.22.2, Elixir with the native codec loaded, and Node v22.22.2 running the TypeScript implementation directly.

§2

Measured — the committed record

bench/branding-vs-decimal
content/echo_data/bench/branding-vs-decimal/{c,rust,go,elixir,node}_bench.outfrozen
runtime              branded encode      decimal encode                        committed output
C (cc 13.3, -O2)     7.21 ns/op          20.49 ns/op  (itoa)                   c_bench.out
Rust 1.75 (-O)       5.14 ns/op          21.77 itoa · 31.61 to_string          rust_bench.out
Go 1.22.2            40.02 ns/op         48.29 FormatUint · 25.87 AppendUint   go_bench.out
Elixir (native)      132.5 ns/op         133.6 ns/op                           elixir_bench.out
Node 22 (pure TS)    381 ns/op           45.6 ns/op  (BigInt toString)         node_bench.out

One host, the recorded toolchains; ratios travel better than absolute numbers. The three dives below take the record apart: the structure that predicts it, the five clocks that confirm and complicate it, and the accounting that settles it.

§3

The dives

three lessons, fixed by the chapter spec

The storage rows are Chapter 1.3’s, taught in module B1.3 · The ID System and inherited here verbatim. The sentence under test: the contract’s wire form is cheaper than the “lean” alternative it is usually defended against.

§4

References

sources · related

Sources

Related