Skip to content

fix(lynx): restore the dense first mount for decoded program runs - #1700

Merged
trueadm merged 1 commit into
mainfrom
fix/lynx-decoded-run-dense-mount
Oct 4, 2026
Merged

trueadm merged 1 commit into
mainfrom
fix/lynx-decoded-run-dense-mount

Conversation

@trueadm

@trueadm trueadm commented Oct 4, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Two weekly lynx-render failures trace to #885 (957b91046b), which made the Lynx transport JSON-encode every message. This PR fixes both. #1641 triaged the weekly breaches and left lynx-render unwaived for this owner fix. This fix is also a prerequisite for Phase 1 of #1055, the dedicated Lynx compiler backend, whose numbers depend on a working lynx-render.

1. The first mount lost its dense path. This is a product fix in @octanejs/lynx.

  • prepareLynxHostBatch takes the dense host record store only when Object.isFrozen(command.values).
  • Decoded runs arrive mutable. So every fresh root's first program-run mount fell back to staging one record per host. The output was correct but about twice as slow at 1k rows.
  • installLynxMainThread now freezes a fresh root's validated compact runs before preparing them. The post-first-tree path already did this. The decoded run is receiver-local, so freezing it cannot affect the sender.

2. The reentrant bench pair was dead. This is a harness fix.

  • runReentrantCommits still dispatched raw objects, which the receiver rejects. The pair received zero acknowledgements and reported 0 ms, and bench.mjs failed the suite as a harness failure.
  • It now encodes the burst with encodeLynxTransportValue before the timer starts, so the interval stays the receiver's drain.

Keeping it from recurring.

  • benchmarks/lynx-render/workload.test.mjs takes about 1 s. It builds the production workload, drains a reentrant burst over the encoded wire, and mounts keyed rows as one compiled program run with one compact acknowledgement.
  • It runs in ci:workflow:test on every pull request and in the weekly Bench pre-step. scripts/ci-workflow.test.mjs pins both.
  • build.mjs is shared by run.mjs and the contract, so both exercise the same bundle.

Guards. The ceilings are unchanged. The two create_* guard notes record the post-#885 measurement and the cause of the weekly breach.

The README now states that both sides pay serialization.

Refs #1055

Evidence

node benchmarks/bench.mjs --quick lynx-render --ratios, same machine (Apple M5 Max) and session, current main 76b5b02671 against this branch:

Operation main: octane / react ratio this PR: octane / react ratio guard
create_1k_rows_ms 6.8 / 5.5 1.24 4.7 / 4.6 1.02 ≤ 1.8
create_10k_rows_ms 109.8 / 56.8 1.93 ✗ 57.6 / 53.3 1.08 ≤ 1.4
update_10k_rows_ms 8.1 / 10.3 0.79 9.0 / 8.2 1.10 ≤ 1.5
reentrant drain_ms 20k vs 10k 0.0 / 0.0 (harness failure) — 142.2 / 71.1 2.00 ≤ 3.5
  • On main, the gate fails with one ratio breach and the reentrant harness failure.
  • On this branch, every checked guard passes.
  • The structural counters are unchanged: 15 wire commands, one compiled program run, and one compact acknowledgement per mount.
  • An earlier 21-sample run of the same fix, on 11a9da935a, measured create_1k 1.66× → 1.14× and create_10k 1.59× → 1.13×.
  • The remaining roughly 0.1× is the codec's own JSON round trip plus GC. React's Snapshot transport also serializes.

Validation

  • vitest run --project lynx packages/lynx/tests/transport-conformance.test.ts: 5 passed. The new case fails without the main-thread.ts change (expected +0 to be 24 dense-path __AppendElement calls) and passes with it.
  • node --test benchmarks/lynx-render/workload.test.mjs: 2 passed.
  • node --test scripts/ci-workflow.test.mjs: 72 passed.
  • octane-tsc -p packages/lynx/tsconfig.json: clean.
  • pnpm format:files:check on every changed file.
  • pnpm sync: no generated changes.
  • pnpm format:check, pnpm typecheck, and pnpm test were not run locally. CI runs them.

Risk / follow-ups

Provenance

  • An agent produced this diff (agent-authored)

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Note

Medium Risk
Touches main-thread commit preparation for first compact mounts; scoped to post-validation freezing with existing reject-on-failure behavior, but it is on the hot path for large keyed lists.

Overview
Restores fast first-screen mounts for compiled keyed rows after Lynx transport messages became JSON strings. Decoded mount-template-run payloads are mutable, so fresh roots no longer qualified for the dense host record store and fell back to per-host staging (~2× slower at 1k rows). installLynxMainThread now freezes validated program runs on the negotiated compact first mount—the same step the post-first-tree path already took—so output and wire semantics stay the same.

The lynx-render harness is aligned with production: reentrant drain benchmarks encode commits with encodeLynxTransportValue (raw objects are rejected), encoding happens before the timer, and a shared build.mjs plus workload.test.mjs contract runs on every PR and in the weekly Bench workflow. Baseline guard notes and the benchmark README now record that both Octane and ReactLynx pay serialization on the wire.

Reviewed by Cursor Bugbot for commit 12015ca. Bugbot is set up for automated code reviews on this repo. Configure here.

Since #885 made the transport JSON-encode every message, the main thread
receives each program run as fresh, mutable data. prepareLynxHostBatch
takes the dense host record store only for a frozen run, so every fresh
root's first mount fell back to staging one record per host. The main
thread now freezes a fresh root's validated compact runs before it
prepares them, as it already did for runs appended after first-screen
adoption.

The lynx-render reentrant pair also broke with #885: runReentrantCommits
still dispatched raw objects, which the receiver rejects, so the pair
measured 0 ms. It now encodes the burst through the transport codec
before the timer starts. A new fixture contract,
benchmarks/lynx-render/workload.test.mjs, runs on every pull request and
in the weekly Bench pre-step, so a wire change cannot strand the workload
again. The build is shared with run.mjs through build.mjs.

Refs #1055

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@trueadm
trueadm marked this pull request as ready for review October 4, 2026 15:10
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Oct 4, 2026
@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Benchmark report

  • 🟡 js-framework: 1 timed operation(s) slower beyond ±3%

Compares 76b5b0267, the merge commit's first parent with 78961581a on the same runner. A byte value over its committed budget or any increase in a js-framework work counter fails this check. Wall time is a report: base and head samples alternate in one browser, and an operation is called slower or faster only when the 95% confidence interval of its ratio excludes ±3%. Workflow run

js-framework: 1k/10k row operations

target operation base ms head ms head/base 95% CI
octane-tsrx select_lots 0.006 0.006 +9.1% +7.1% … +10.9% 🟡 slower
All 20 timed operations (19 without a verdict)
target operation base ms head ms head/base 95% CI
octane-tsrx run 3.133 3.133 +1.5% −6.3% … +6.6% ⚪ within noise
octane-tsrx replace 6.342 5.917 −0.0% −3.9% … +3.8% ⚪ within noise
octane-tsrx add 2.600 2.500 ±0.0% −1.8% … +0.0% ⚪ within noise
octane-tsrx update 0.122 0.126 −0.6% −1.3% … +1.2% ⚪ within noise
octane-tsrx select 0.005 0.005 +1.3% +0.5% … +1.9% ⚪ within noise
octane-tsrx swap 0.033 0.034 +1.1% +0.3% … +2.3% ⚪ within noise
octane-tsrx remove 0.019 0.019 −2.7% −5.0% … +1.5% ⚪ within noise
octane-tsrx runlots 25.158 26.800 +1.1% −2.7% … +6.4% ⚪ within noise
octane-tsrx select_lots 0.006 0.006 +9.1% +7.1% … +10.9% 🟡 slower
octane-tsrx clear 45.642 46.225 +3.0% ±0.0% … +5.9% ⚪ within noise
octane-jsx run 3.358 3.475 ±0.0% −2.9% … +3.1% ⚪ within noise
octane-jsx replace 6.133 6.042 +0.0% −5.2% … +4.4% ⚪ within noise
octane-jsx add 3.017 2.992 ±0.0% −3.2% … +1.5% ⚪ within noise
octane-jsx update 0.242 0.247 −0.3% −1.0% … +0.9% ⚪ within noise
octane-jsx select 0.125 0.124 −0.6% −1.5% … +0.3% ⚪ within noise
octane-jsx swap 0.226 0.227 −0.3% −1.1% … +0.8% ⚪ within noise
octane-jsx remove 0.169 0.173 −0.7% −2.0% … +0.3% ⚪ within noise
octane-jsx runlots 26.600 26.842 +0.9% −0.6% … +2.7% ⚪ within noise
octane-jsx select_lots 1.424 1.458 −0.0% −1.7% … +2.4% ⚪ within noise
octane-jsx clear 46.433 48.308 −2.9% −5.4% … +1.5% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

target metric base head Δ
octane-tsrx bindings_js_gzip 240,870 240,859 −11 (−0.0%) 🟢
octane-tsrx bindings_js_brotli 205,198 205,189 −9 (−0.0%) 🟢
octane-tsrx bindings_app_gzip 121,727 121,716 −11 (−0.0%) 🟢
octane-tsrx bindings_app_brotli 101,835 101,826 −9 (−0.0%) 🟢

50 other measured values are unchanged.

Public-import reachability bundles (bytes)

No changes across 105 measured values.

@trueadm
trueadm merged commit d94e1b0 into main Oct 4, 2026
49 of 52 checks passed
@trueadm
trueadm deleted the fix/lynx-decoded-run-dense-mount branch October 4, 2026 15:26
trueadm added a commit that referenced this pull request Oct 4, 2026
… (#1710)

#1700 freezes a fresh root's decoded program runs so a first mount takes
the dense host record store again. That costs the main thread 141 raw
bytes: preview main gzip 83,657 -> 83,742 and IFR 89,331 -> 89,404,
both over their measured + 32 caps. The weekly-only lynx-bundle-size
gate never ran on that pull request.

Raise both caps to the new measurement + 32. Re-pin the background
program at 288,390: it shrank after the 2026-10-03 reset (#1652, #1662),
and its exact pin is the next gate in the same block. Budget values and
their comment only.

Refs #1055

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant