Repository navigation
Description
Found by the completeness critic of the adversarial audit of #58, against stack head 2fe14465f (measured at 5d000b30e). Stack-introduced by definition — base rejects target: 'lynx' outright (universalRuntime requires an explicitly selected universal renderer).
The documented bound does not hold
docs/lynx-specialized-target-l0.md:329 states: "gzip 10–22% larger on the fixture modules because repeated JSON keys compress better than code — accepted as an L1 trade, re-audited at L5."
That number is an artifact of the two small fixtures that were measured. Measured across a toolbar(n) ladder:
bench App.lynx.tsrx templates=2 raw 10774/11707 (-8.0%) gzip9 2481/2154 ( 15.2%)
rspeedy application App.tsrx templates=1 raw 3139/2935 ( 7.0%) gzip9 1086/1039 ( 4.5%)
toolbar-4 templates=1 raw 1788/1962 (-8.9%) gzip9 543/455 ( 19.3%)
toolbar-12 templates=1 raw 3476/4054 (-14.3%) gzip9 772/510 ( 51.4%)
toolbar-40 templates=1 raw 9468/11362 (-16.7%) gzip9 1509/685 ( 120.3%)
toolbar-120 templates=1 raw 27112/32282 (-16.0%) gzip9 3819/1155 ( 230.6%)
wide-20 static templates=1 raw 5033/5967 (-15.7%) gzip9 991/577 ( 71.8%)
Both fixtures the doc measured land inside the quoted band; every larger static template leaves it. Note the sign inversion — raw and minified get smaller (−16%), exactly as the doc predicts, while gzip goes to +230%.
The doc's stated cause is wrong, and the real one is fixable
The doc attributes this to "repeated JSON keys compress better than code." The actual mechanism is narrower and more tractable:
The interpreted plan for 120 identical buttons is 120 byte-identical JSON runs, so LZ77 matches whole records. The emitted create function is const n0 = env.h("view"); env.p(n0, "class", "btn"); const n1 = env.h("text"); … with a unique local name per node — naming.next++ in lynxTemplateCreateStatementsAst, packages/octane/src/compiler/compile-universal.js:3967. The unique nN breaks every match after ~30 bytes.
It is the naming scheme, not "code versus JSON", that destroys the ratio. That suggests a cheap fix: reuse a small name pool, or emit repeated subtrees through a shared helper.
Why it matters for L5
The L5 cutover gate assumes removing the interpreter and batch pipeline — a fixed saving — outweighs the encoding delta, treated as a bounded ~10–22%. But the delta is a per-static-node cost. At +230% on 120 nodes the arithmetic does not hold for a large app, and the gate has never been evaluated against the real number.
docs/lynx-specialized-target-l0.md §8 records the trade as "re-audited at L5"; this is that audit arriving early with a different answer.
Suggested direction
Parameterize toolbar(n) over n ∈ {4, 12, 40, 120, 400}, plot the gzip delta against static host count, and place that curve next to the measured byte weight of the main-thread interpreter + batch pipeline that L5 removes. Then either restate §8's claim with the curve, or fix the emitter's naming and re-measure. The naming fix is likely to move this a long way on its own.
Verification performed
Executed; probe sources and literal outputs preserved. Attribution is definitional (base rejects the target). Not yet independently re-run by me, and no adversarial refuter has adjudicated it.
Activity
Merge pull request #95 from Huxpro/perf/lynx-template-local-naming