Repository navigation
perf(lynx): make commit wire cost proportional to change size, not tree size - #662
Merged
Merged
Conversation
…rows floor A point update's commit currently ships the whole tree: selecting one row in the 10,000-row cross-framework table serializes ~30,000 commands / 2.4MB — identical in size to a commit where every tenth row actually changed — because every row's re-encoded class array and both bindtap closures cross the wire on every commit. This adds the instrument that makes that cost a tracked, gateable number before any fix lands: - @octanejs/lynx gains a permanent __OCTANE_LYNX_PROFILE__-gated wire profiler (globalThis.__OCTANE_LYNX_PROF): per-thread commits, commands, serialized bytes, and pipeline-stage milliseconds. Compiled away when the define is absent. - benchmarks/lynx-table drives the krausest-style table app (mirrored operation-for-operation from the Vue Lynx unified benchmark matrix) through the real background root, transport, main-thread receiver, and host driver via real tap tokens, and reports deterministic per-operation command counts and commit bytes against the changed-rows semantic floor. - benchmarks/lynx-table/web is the Lynx-for-Web wall-clock harness: the same app for Octane and vendored ReactLynx / Vue Lynx vdom / Vue Lynx vapor reference bundles under one byte-identical Chromium page driver. - ratios.json gains 12 lynx-table guards pinned at today's measured waterline (select = 1500x the floor, update10th = 31x, storms likewise), each marked KNOWN GAP with the instruction that fixes must tighten them. CI now fails on any further regression and visibly tracks the gap itself. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SW6xKsEpmsN7rFu4K9mFM9
…ee size On a transported root every object-valued host prop is re-encoded through the wire clone per render, so the identity-based prop diff could never certify sameness: a one-row select over 10,000 rows shipped ~30,000 commands / 2.4MB. Three cuts: - Value-semantic prop diff: exported sameUniversalHostPropValue (Object.is fast path, depth-2 structural equality over arrays and plain records from any realm via a universal-side hasCrossRealmPlainPrototype, the twin of packages/lynx/src/core/plain-object.ts). Used by shallowPropsEqual, and cloneSerializableValue accepts cross-realm plain objects through the same predicate. - Events re-announce only what the host can observe: a re-created equivalent handler keeps its stable listener ID and the background dispatch table always rebinds to the newest closure, so only a new listener, priority change, or owner change emits a command. Host callbacks (attach) keep closure-identity announcement — their re-run on handler replacement is an observable contract. - Compiler lowers statically string-or-falsy class arrays to their clsx-composed string (all-literal arrays fold to a static plan prop) and folds string-literal children and literal attribute values into the frozen plan, so hot per-row slot values are primitives. The transport's backpressure coalescing (renders scheduled while a commit awaits acknowledgement fold into one commit carrying the latest state) is now an explicit, tested contract. select@10k: 30,000 cmds / 2,406,468 B -> 2 cmds / 225 B. All 12 lynx-table ratio guards tighten from KNOWN GAP ceilings (31x-15,000x) to 1.0x-1.5x floors; baselines re-recorded. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SW6xKsEpmsN7rFu4K9mFM9
5 of 7 tasks
domgan-oai
marked this pull request as ready for review
August 9, 2026 10:32
This was referenced Aug 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Depends on #660 (the instrument that measures this change) — review the last commit only.
Fixes the P0 that #660 pins: on a transported root every object-valued host prop is re-encoded through
cloneSerializableValueper render, so the identity-basedshallowPropsEqualcan never certify sameness — a one-row select over 10,000 rows shipped ~30,000 commands / 2.4MB, and every freshbindtapclosure re-announced its (stable) listener. Three cuts, ~three small sites, no architecture changes:sameUniversalHostPropValue:Object.isfast path, then depth-2 structural equality over arrays and plain records from any realm (via a universal-sidehasCrossRealmPlainPrototype, the twin ofpackages/lynx/src/core/plain-object.ts); deeper or exotic values stay identity-compared. Used byshallowPropsEqual, so the compact-leaf, stable-leaf, and general diff sites fix together.cloneSerializableValueaccepts cross-realm plain objects through the same predicate.attach) deliberately keep closure-identity announcement: their re-run on handler replacement is an observable contract (pinned byuniversal-event-scope.test.ts).class={[…]}arrays whose elements are statically string-or-falsy lower to their clsx-composed string (all-literal arrays fold to a static plan prop); string-literal children and literal attribute values fold into the frozen plan.The transport's backpressure coalescing ("renders scheduled while a commit awaits acknowledgement fold into one commit carrying the latest state; intermediate states never cross") is now an explicit, tested contract — it previously held only as a side effect of acknowledgement timing and becomes load-bearing for storm throughput once commits stop saturating the main thread.
Measured (deterministic, same harness as #660)
All 12
lynx-tableguards tighten from KNOWN GAP ceilings (31×–15,000×) to 1.0×–1.5× floors; baselines re-recorded. Wall clock on the measurement host: select@10k 1374→857ms, selectStorm@10k reaches parity with Vue vdom. Honest trade, disclosed: updateStorm wall clock regresses ~25–30% (the old number rode accidental backpressure coalescing — a busy main thread folded 50 ticks into ~19 commits; with 30× smaller commits every tick commits and lays out). The coalescing contract plus the storm command gates prevent silent decay; recovering that number needs deliberate frame-aligned commit throttling, which is a protocol change left as follow-up. The remaining select wall-clock gap vs Vue is background replay breadth — a separate P1, not attempted and not regressed here.Validation
pnpm format:checkpnpm typecheck(rantsc -p packages/octaneand-p packages/lynxclean)pnpm test(targeted below)octaneandoctane-prodprojects; new regression tests red-checked against reverted implementations (comparator reverted toObject.is→ suppression test fails; event handler-identity term restored → suppression and replacement tests fail)node benchmarks/bench.mjs --quick --ratios --only lynx-table→ PASS at the tightened floorsRisk / follow-ups
universal-transport.test.tsfetched the third occurrence of a re-announced listener command; the listener ID is now announced once, and the updated assertion (same ID must dispatch to the newest closure) is the stronger contract.Provenance
agent-authored)Note
High Risk
Changes universal transported-root prop diff, event wire semantics, and compiler slot lowering on the Lynx dual-thread hot path; incorrect equality or listener behavior would break updates or dispatch silently.
Overview
Transported Lynx commits no longer fan out across the whole table when only a few rows change. Prop diffing switches from reference equality to exported
sameUniversalHostPropValue(depth-2 structural compare aligned with wire cloning), so unchanged class/style-shaped props stop generating spuriousupdatecommands. The compiler folds common per-row shapes—class={[…]}to clsx strings and literal children/attrs into the frozen plan—so slots stay primitive-stable across renders. Event handlers keep stable listener IDs and rebind locally without re-emittingeventcommands on every fresh closure; attach callbacks still follow closure identity.A new
lynx-tablebenchmark (Node wire gates + optionallynx-table-webChromium timings) drives the krausest-style app through the real dual-thread path with__OCTANE_LYNX_PROFILE__counters. CI ratio guards vs achanged-rows-modelfloor pin select at 2 commands / ~225 B at 10k rows (down from ~30k / ~2.4MB) and tighten storm/update guards to ~1.0×. Baselines, bench manifest entries, and changesets document the wire profiler and payload fix.Reviewed by Cursor Bugbot for commit 12d44ea. Bugbot is set up for automated code reviews on this repo. Configure here.