Repository navigation
perf(lynx): build first-screen host records without spread-and-delete - #109
Conversation
`hostNode` copied its incoming props with a spread and then deleted `key`, `ref`, `children`, and every event-named prop off the copy. `delete` on a fresh object drops it out of V8's fast properties for the rest of its life, and these objects are long-lived: the direct applier reads them, and so does adoption capture. The scan for event props then walked the copy a second time, and an event map was allocated for every host whether or not it bound anything. The bag is now built by copying only the keys it keeps, in one pass that also collects the events, and a host that binds nothing shares one read-only empty map. Behaviour is unchanged, including the part nothing checked: an event-named prop carrying something that is not callable leaves the props bag without becoming a listener, exactly as the spread-and-delete did. That now has a test, because the background does the same and a first screen that disagreed would lose adoption for the whole page. Raw `#text` records skip the generic path. Their props are a string `value` and nothing else — the shape `assertTextProps` enforces and `create` already shortcuts — so walking that one-key literal for props it cannot contain, and allocating an event map that stays empty, was pure overhead. Three of every seven hosts in the benchmark fixture are one of these. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
|
| failure | reason |
|---|---|
aria hydration, aria package-boundary, alien-signals hydration, octane react-hosted/web3-island |
Hook timed out in 10000ms in a beforeAll that SSR-renders or bundles a fixture |
adapter-vercel adapt, dropzone hydration, syntax-highlighter negative-controls |
Test timed out in 5000ms |
docusaurus hydration |
Test timed out in 15000ms |
website ssr-hydration (dev + preview), website ssr-smoke, doom production, octane browser suspense-hydration, drei browser e2e |
real-browser suites |
rspeedy-plugin native-demo |
escalates cleanup for a detached descendant after its leader exits — the failure #66 §2.3 records as pre-existing in this container |
The attribution is not just by symptom. This stack changes three files in
packages/lynx/src plus lynx tests, one packages/octane test, a changeset and
a doc. Of the failing packages, exactly one depends on @octanejs/lynx —
rspeedy-plugin-octane — and its failing assertion is about killing a detached
process tree, which no renderer change reaches. The other twelve
(adapter-vercel, docusaurus, drei, dropzone, syntax-highlighter,
aria, alien-signals, website, playground/octane) have no lynx
dependency at all.
web3-island was separately A/B-verified earlier in this session: it passes
standalone at both the stack base and this head, and only fails inside a full
concurrent run.
Generated by Claude Code
The three first-screen slices were measured phase by phase in a Node harness. This is the same change at the product boundary: the app built at the stack base and at its head, driven through prototype/run-fcp.mjs in one window, cells alternating, fresh page per sample. n=15 could not tell the two apart — the paired difference was -113.6 ms with a 261.8 ms spread, t=-1.68. n=30 resolves it: -158.5 ms paired mean, 95% CI [-224.2, -92.9], t(29)=-4.94, head faster in 22 of 30 paired reps. Median FCP falls 2751.6 -> 2599.1 ms, which is 12% of the distance from the stack base to the direct-emission floor the same window measures at 1534.0 ms. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
#66 §4 bullet 4 — FCP@10k at the product boundary, whole stack vs its baseThe three slices were measured phase by phase in a Node harness. This is the Host: 4× Xeon @ 2.80 GHz, load 0.49 at start, Node v22.22.2. n=30 per cell.
Cells alternate inside one window, so each rep is a matched pair:
n=15 was not enough and said so. The first run gave −113.6 ms with a What it is worth against the roadmap. #66 §4 wants the first screen moved The direct/octane ratio the harness prints is 0.590× here against 0.575× Generated by Claude Code |
The cutover-gate report named #109's record-shape change as the hypothesis to test first for the few-percent excess on create, update10th, and updateStorm. Reading the stack's source diff retires it. The stack edits nine source files. block-core.ts and block-root.ts are new and behind a per-root flag. delta-protocol.ts and delta-shadow.ts are profiling-only, constructed under LYNX_PROFILE. main-renderer.ts and core/first-screen.ts are first-screen render. main-thread.ts is the direct-applier call site. Every host-driver.ts hunk lands in applyLynxFirstScreenDirect, captureLynxFirstTree, compareFirstTree, transferFirstTree, the native-list constructors, or the once-per-root firstTreeAction === 'adopt' branch of prepareLynxHostBatch. The compiler flips one slot kind from 'c' to 'r', and slots is read only by main-renderer.ts, which validates and copies it and branches on neither value. Nothing a mutation cell executes after adoption was edited, so a logic regression on that path is ruled out. Two candidates remain and neither is claimed: the bigger main-thread bundle every cell runs inside (+4,202 B raw, +1,721 B gzip), and slow host drift across the session, which AB/BA alternation does not control because it only controls ordering within a window. The first is directly testable by padding the base bundle with dead bytes to the head's size and re-running the sweep. Records the file-by-file table so the next session can check the reasoning rather than repeat the elimination.
Summary
Stacked on #108 (
perf/lynx-first-screen-batch). Third slice of #66 Phase B:build first-screen host records without spreading and then deleting from the
copy.
hostNodeused to do{...rawProps}and thendeletekey,ref,children, and every event-named prop off the copy. Adeleteon a freshobject moves it to V8 dictionary mode for the rest of its life — and these
objects are not scratch: they are the first screen's props bags, read later by
the direct applier and again by adoption capture. The fixture's 10k rows carry
bindtapon the row and akeyon every row, so every row host took thattransition.
The bag is now built by copying only the keys it keeps, in the same pass that
classifies events, so nothing is ever deleted. Two shapes fall out of that:
NO_FIRST_SCREEN_EVENTS)instead of allocating its own — the same shared-empty idiom the host driver
already uses for props/children/events.
#textrecords get their own constructor. Their props are a stringvalueand nothing else — that is exactly whatassertTextPropsin the hostdriver enforces — so they skip the generic classify loop. Three of every seven
hosts in ROW_TEMPLATE are
#text, so at 10k rows that is 30,000 records offthe generic path.
One behavioural detail changed and is now covered: an event-named prop whose
value is neither a handler nor the first-screen sentinel used to survive into
the props bag, because the old code only deleted names it had classified as
bound. It is now dropped, which matches what the background renderer does with
the same input.
Why
#66 §4 wants the first screen's intermediate records to stop being the dominant
cost of the direct path. This is the allocation half of that: same record tree,
same consumers, cheaper to build and cheaper to read.
Changes
packages/lynx/src/main-renderer.tshostNodebuildspropsby copy-in rather than spread-and-delete, andcollects
eventsin the same pass (lazily allocating the map).NO_FIRST_SCREEN_EVENTS: a shared frozen-empty event map for hosts thatbind nothing.
textNode(value)constructs#textrecords directly; both#textcallsites use it.
packages/lynx/tests/main-renderer.test.ts: a string-valuedbindtapisdropped from the emitted props, matching background.
docs/lynx-specialized-target-l0.md§8: the increment recorded, per Execution plan (#58): complete L2, then drive L4→L6 — full context handoff #66 §0.benchmarks/lynx-table/prototype/results/fcp-10000-phase-b.{json,md}: theproduct-boundary A/B below, committed beside the other session records.
patch,@octanejs/lynx).Measurements
This slice, phase by phase
FS_COST_ROWS=10000,FS_COST_GC=1,NODE_OPTIONS=--expose-gc. Threealternated rounds of 10 reps per side, pooled (30 samples/side), before =
0d64af8(#108 head), after = this branch. Phases are GC-isolated so a build'sown garbage is not billed to the next phase.
Render is the phase this slice touches and it moves in every round
individually (171.8→123.4, 151.1→110.1, 167.6→120.8 ms median). Apply and
capture sit inside noise in both directions across rounds, which is the
expected result — the applier is untouched. The batch phase gets a smaller
real win it did not ask for:
buildFirstScreenBatchreads back the same propsbags, and reading a fast-mode object is cheaper than reading a dictionary-mode
one.
The whole Phase B stack at the product boundary (#66 §4 bullet 4)
The app built at
781e4fca3(the stack base, #107's head) and at this head,driven through
prototype/run-fcp.mjsin one window, cells alternating AB/BA,fresh page per sample. 4× Xeon @ 2.80 GHz, load 0.49 at start, n=30 per cell.
octane-baseline— stack baseoctane— this headoctane-direct— L0 direct-emission floorCells alternate inside one window, so each rep is a matched pair: paired mean
difference −158.5 ms (sd 175.8), t(29) = −4.94, 95% CI [−224.2,
−92.9] ms, head faster in 22 of 30 reps, median ratio 0.947×. That is
~12.6% of the distance from the base to the floor the same window measures.
n=15 could not tell the two apart and is reported for that reason: −113.6 ms
with a 261.8 ms paired spread, t = −1.68, head faster in 10 of 15. A single page
load at this boundary varies by more than the whole effect. The number is only
reportable because n=30 resolves it.
Validation
pnpm syncclean (no generated changes)pnpm format:checkpnpm format:fileson changed filespnpm typecheckpnpm typecheck:files packages/lynx/src/main-renderer.tspnpm test— full run at935d6e3d: 2182/2196 files, 20,954 testspassing. No
packages/lynxorpackages/octanefailure; all 14failures are timeouts or browser/process flakes on a loaded host. Detail
and per-package attribution in a comment below.
--project lynx,--project octane,--project octane-prodNote on scope:
packages/lynx/tsconfig.jsonexcludestests, so the repo-widepnpm typecheckdoes not cover lynx test files;main-renderer.test.tshaspre-existing
useEffectarity errors undertypecheck:filesthat are presenton the unmodified file too.
Risk / follow-ups
affects props that were never callable, and it aligns the two renderers.
NO_FIRST_SCREEN_EVENTSis shared and must never be written. It cannot be:the only writer of a record's
eventsisTEMPLATE_ENV.e, which only everholds a map the same call allocated.
an increment on the universal path; written up separately on Execution plan (#58): complete L2, then drive L4→L6 — full context handoff #66 with a
recommendation to retarget it to Lynx specialized background core: the Block model over the wire (#58 L2 body, post-attribution direction) #103.
fcp-10000.mdis a different host's session — the recordfeat(bench): issue-58 L0 — Lynx IR spec and direct-emission prototype with measured evidence #59's 0.575× GO verdict cites — so this run went to its own suffixed file
rather than overwriting it. Absolute ms are not comparable between them; the
direct/octane ratio is, and reproduces at 0.590× here.
Provenance
agent-authored)Generated by Claude Code