Repository navigation
perf(lynx): decline an unadoptable first screen before painting it - #110
Merged
Merged
Conversation
A page holding a native `<list>` rendered, built a full command batch, took a host container, staged and applied it, planned the native list, was refused by adoption capture, and was torn all the way back out — to reach a verdict that never depended on any of it having happened. `captureLynxFirstTree` refuses every root holding a `<list>` outright, and the renderer's record tree already carries every element type and prop that refusal reads. `firstScreenTreeIsUnadoptable` asks the question there, before the container exists, and `renderFirstScreenNow` retires a tree it claims with no container and no Element PAPI traffic at all. At 1,000 native rows (4,002 logical hosts) the synchronous first screen goes from a median 37.8 ms and 18 PAPI calls to 5.1 ms and none, with disjoint distributions across four before-passes and three after-passes of 21 samples. Almost none of the removed cost was host traffic — an unscrolled native list creates no cells — so those 18 calls stand for Octane's own batch, prepare, apply, list plan, capture, and teardown behind them. A list-free page pays only the walk: 0.063 ms median over that same 4,002-host tree, 0.06% of its first screen, with host traffic unchanged. Skipping a build must never skip a diagnostic, so the pre-check claims a tree only when the staged path would have accepted it, and establishes that by running the real validators rather than restating their rules: `createLynxListItemDescriptor` and `planLynxListUpdate` over the same nodes, with the prepare walk's nested-`<list>` and `<list-item>`-placement rules tracked alongside. A host offering no list PAPI is excluded too — a page that cannot build a `<list>` at all needs that report, not a silent skip. Ranges are transparent to both walks, which is what makes this fire on real code: a `<list>` takes its rows from a keyed `@for`, so a range sits between the list and every `<list-item>` and the rows are not the list's own children. A reader stopping at the immediate children would validate an empty list, decline, and swallow every row defect. Both walks are iterative for the same reason their neighbours are: a range chain is a chain of nested directives, and nothing here may cap a depth the renderer accepted. `captureLynxFirstTree` stays the authority on adoption. A shape the pre-check does not claim settles exactly as it does today, having paid for the paint. Two existing tests pinned build-then-teardown and were rewritten rather than deleted: one now asserts no flush ever carried the list or its shell, and the other — whose always-throwing `__RemoveElement` had become unreachable — now asserts that a declined first screen has nothing to remove and announces readiness on the first attempt. `.changeset/lynx-first-screen-declines-native-list.md` is merged but unreleased and its last paragraph promised this work while predicting a different route to it. Left alone it would ship in the same CHANGELOG entry as this change and contradict it, so it now records the item as closed and by what means. Refs #66. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
The comment said a `<list-item>` under a range under a `<list>` is "the shape every list fixture has", which is backwards: the hand-built fixtures nest rows directly and only the keyed one goes through a range. What matters is that it is the shape every *authored* list has, since rows come from a keyed `@for` — and that a reader stopping at the list's immediate children would validate an empty list, decline, and swallow every row defect. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
Every list fixture nested its rows directly under the `<list>`, which no `.tsrx` produces. Compiling `tests/_fixtures/native-list.lynx.tsrx` with `lynxMainThreadRenderer` shows the real lowering: `<list id="native-feed">` becomes a `template` create program rather than a `host` plan node, with its rows in one child hole as a keyed `@for`, and the record tree it renders is `host <list>` over one `range` per row, each holding one `host <list-item>`. Two properties the pre-check depends on, neither previously covered. The template-created `<list>` still records as an ordinary `list` host. And its rows are not its own children, so a reader stopping at the immediate children would validate an empty list, decline, and swallow every row defect — while still passing a decline test, which is why a decline test alone is not evidence of this. Adds a template fixture matching the emitted `kind`/`slots`/`create` shape, and for both it and the keyed-loop fixture a decline test plus a duplicate-`item-key` test. Making ranges opaque turns both duplicate tests red and leaves both decline tests green. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
`pnpm format:check` fails on the stack for three generated JSON results, which blocks the gate for every branch above them. All three are formatted correctly on `new-lynx`; the unformatted copies came in with this stack: - `stages/results/live-1000.json` and `live-10000.json` were rewritten by `888d9034f` and `88e9db5f0`, first carried by `perf/lynx-bg-replay-attribution` (#102). - `prototype/results/u0-block-core-counts.json` is new in `781e4fca3`, on `test/lynx-u0-block-counts` (#107). Fixed forward here rather than at the source, because both of those branches are published and under review and repairing them in place would rewrite history four and two branches deep. Nothing but whitespace changes: each file reparses to a byte-identical JSON value. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
This was referenced Aug 20, 2026
…creen The unadoptable pre-check replayed only the list validators, so a page holding a valid native <list> plus a defect the prepare walk reports — a main-thread: event prop colliding with a background listener, or one main-thread ref descriptor assigned to two visible hosts — settled as a quiet 'skipped' instead of 'failed' with the error, contradicting the pre-check's own contract that a skipped build never skips a diagnostic. Replay both checks over the tree before granting the skip verdict, and throw the staged path's errors so the screen retires exactly as it does today. Both regressions verified red first. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01YHfFsy9CLaRovTFH8pTGyY
Huxpro
changed the base branch from
perf/lynx-first-screen-records
to
new-lynx
August 20, 2026 19:57
Huxpro
marked this pull request as ready for review
August 20, 2026 19:57
This was referenced Aug 20, 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
Stacked on #109. Issue #66 Phase C opener.
A first screen holding a native
<list>was rendered, built into a full commandbatch, given a host container, staged, prepared, applied, planned as a native
list, refused by adoption capture, and then torn all the way back out — to reach
a verdict that never depended on any of it having happened.
captureLynxFirstTreerefuses every root holding a<list>outright, and therenderer's record tree already carries every element type and prop that refusal
reads. So the question is now asked there, before the container exists. A page
whose answer is "decline" retires with no container, no batch, and no Element
PAPI traffic at all.
The change is a pure predicate over
LynxFirstScreenDirectNode[]plus fivelines wiring it into
renderFirstScreenNow.What compiled pages actually look like
Every list fixture in the suite nested its rows directly under the
<list>,which no
.tsrxproduces. Compilingtests/_fixtures/native-list.lynx.tsrxwithlynxMainThreadRenderershows the real lowering:with the rows in that one child hole as
__octaneUniversalFor(...). Rendering itgives this record tree — the thing the pre-check reads:
Two properties follow, neither of which any fixture covered. A
<list>createdby a template still records as an ordinary
listhost. And its rows arenot its own children — one range per row sits in between — so a reader
stopping at the immediate children would validate an empty list, decline, and
swallow every row defect, while still passing a decline test. That is why
each of the two realistic fixtures (keyed-loop and template-lowered) carries both
a decline test and a duplicate-
item-keytest: making ranges opaque turns bothduplicate tests red and leaves both decline tests green.
Both walks are also iterative, because a range chain is a chain of nested
directives and nothing in the first-screen pipeline may cap a depth the renderer
accepted (#90).
It must not swallow a diagnostic
Skipping a build must never skip an error. The pre-check answers
trueonlyfor a tree the staged path would have accepted, and it establishes that by
running the real validators rather than restating their rules: it calls
createLynxListItemDescriptorandplanLynxListUpdatefromcore/list.tsoverthe same nodes and treats a throw as "not a decline, keep going". The two
placement rules the prepare walk owns — nested
<list>, and<list-item>notdirectly under a
<list>— it tracks alongside as it walks.That covers eight of the nine list diagnostics. The ninth is a host that offers
no list PAPI: without
__CreateLista<list>cannot be built at all, and anapplication using a documented element deserves that report rather than a silent
skip, so the whole pre-check is gated on
papi.list !== undefined.Seven tests hold each diagnostic to its current site.
Measurement
Real
installLynxMainThreadfirst-screen path, 1,000-row fixture (4,002 logicalhosts: a
<view>shell, one container, three<view>children per row). Armstaken by stashing the change so both run the same harness on the same fixture;
21 samples per pass after 3 warmups, each in a fresh environment. Element PAPI
traffic counted by wrapping every function-valued
__*global before the PAPIcaptures them, and asserted identical across all 21 samples of a pass.
A second fixture differing only in element types (
view/viewin place oflist/list-item) is the regression control.Medians of four before-passes and three after-passes. The list distributions are
disjoint — slowest after-sample 12.0 ms, fastest before-sample 30.8 ms.
Only 18 PAPI calls in the before arm because an unscrolled native list creates no
cells: the platform materializes rows through the recycling callbacks. So the
~33 ms removed is Octane's own work behind those calls — the batch, the
container, the prepare and apply walks, the list plan over 1,000 descriptors, the
capture, and the teardown. The 5.1 ms that remains is the render producing the
records the verdict reads.
The control resolves nothing end to end: its between-arm spread (104.0–110.9
before, 104.7–116.8 after) is the size of its within-arm spread. Timed directly
instead, 200 calls after 200 warmups on the same rendered tree:
0.063 ms is 0.06% of that page's ~108 ms first screen. The list tree costs more
because it runs the real validators over 1,000 descriptors, and it replaces
~33 ms of build-and-discard.
The measurement harnesses were temporary and are not in this diff; the numbers
they produced are in
docs/lynx-specialized-target-l0.md§8.Two existing tests changed rather than being deleted
Both pinned build-then-teardown, which is exactly what no longer happens.
declines a synchronous first screen holding a native list without faultingis now
…without painting it, and asserts the stronger contract: no flushever carried the list or its shell.
retries deferred cleanup for a declined first screenhad becomeunreachable — its
__RemoveElementthat always throws is never called now.It is repurposed to
announces readiness for a declined first screen with no cleanup to defer, keeping the same hostile host and assertingremovals === 0with readiness announced on the first attempt.
An unrelated
format:checkfailure the stack was carryingpnpm format:checkfailed on this branch for three committed benchmark resultJSONs — and would fail the same way on four branches below it. All three are
formatted correctly on
new-lynx; the unformatted copies came in with the stack:stages/results/live-1000.jsonandlive-10000.jsonvia888d9034f/88e9db5f0(first carried by #102), and
prototype/results/u0-block-core-counts.jsonnew in781e4fca3(#107).Repaired here rather than at the source, because both of those branches are
published and under review and fixing them in place would rewrite history four
and two branches deep. Whitespace only — each file reparses to a byte-identical
JSON value, checked before committing.
One changeset amended
.changeset/lynx-first-screen-declines-native-list.mdis merged but unreleased,and its last paragraph promised exactly this work while predicting a different
route to it ("needs the prepared batch to publish what it staged"). Left alone it
would ship in the same CHANGELOG entry as this change, contradicting it. Its
closing paragraph now records that the item is closed and by what means.
Validation
pnpm format:check— clean repo-wide (after the repair above)pnpm typecheck— cleanpnpm test— not completed in this container: the full run exceeded a60-minute cap. The projects this change can reach were run explicitly
instead, below.
--project lynx— 32 files, 434 passed--project octane --project octane-prod— 841 files, 12,436 passed,4 skipped, 0 failed; 2 files errored (see below)
packages/lynx/tests/first-screen.test.ts— 21 passednode benchmarks/bench.mjs --quick --ratios lynx-list— PASS, 0.012x eager(12 physical cells for 1,000 logical items, 988 reuses, 0 after teardown).
This is the exit gate Execution plan (#58): complete L2, then drive L4→L6 — full context handoff #66 §5 names for Phase C; C1 does not touch the list
runtime.
The 2 errored files, and why they are not this change
packages/octane/tests/react-hosted/web3-island.test.ts(once per project) failswith
Hook timed out in 10000mswhile building therainbowkithydrationfixture. No test assertion fails; the file errors in its setup hook and its 2
tests are skipped.
I initially measured it as a regression and was wrong. One run on the base
(
fbccb04c1) passed and one on this head failed — but both sat on the timeoutboundary, 10.25 s and 10.02 s against a 10,000 ms hook cap, and both failures
came directly after heavy load (a 60-minute suite, then a benchmark). Three
consecutive standalone runs on this head all pass. It is a threshold flake on a
fixture build that takes about as long as its own timeout, and nothing in this
diff is reachable from that file — the change is confined to
packages/lynx/src,which the
octaneproject does not import.Red/green on the pre-check, each break run against the full file:
truefalse<list>guard<list-item>placement guardlist.tsvalidatorspapi.listgateThe first six rows were run against the 17-test file, before the two realistic
fixtures existed; their counts are from that run. The
predicate always falsebreak re-run against the final 21-test file fails 13.
Two breaks came back green the first time and needed better fixtures. The
placement break: the stray-row fixture had no well-formed
<list>in it, so thepredicate declined to claim that tree whether or not the guard was there — it now
holds a valid list beside the stray row. And the range question was invisible
until a fixture matched compiled output, as above.
Risk / follow-ups
captureLynxFirstTreestays the authority on adoption. A shape the pre-checkdoes not claim settles exactly as it does today, having paid for the paint; the
pre-check can only ever be more conservative than capture, never less.
planLynxListUpdatemeans allocating a full insert plan — one frozenaction per row — and discarding it. That is most of the 0.501 ms the list arm
pays, and it is deliberate: the cheaper option is a local key-uniqueness check,
which restates the rule this slice exists to avoid restating. 0.5 ms to remove
33 ms is the right side of that trade.
list.tsfunctions rather than duplicating them, so a rule added there ishonoured here for free — but a rule added to the prepare walk would need
mirroring, as the two placement rules already are.
hostnorrangewould betreated as a range by both walks. Today the union is exactly those two.
than compiled in-process: the
lynxvitest project compiles.tsrxwith thebackground renderers, so a main-thread fixture would need a generated-module
loader, which
.rulesync/rules/testing.mdrules out. If the main-threadlowering changes shape, that fixture goes stale silently.
without rendering at all needs the compiler to declare that a page may hold a
<list>, which is out of scope for this slice.unnecessary rather than cheap.
Provenance
agent-authored)Generated by Claude Code