Repository navigation
perf(lynx): announce a batch's hosts from what composing already knows - #132
Conversation
A `nodes-ref` selector is installed only where a commit announced it would query the host. That announcement waited on the negotiated lazy-public-instance capability, which a background does not have when it composes its first batch: that batch is built before the main-ready reply reaches it. So the largest tree a root ever mounts installed a selector on every element node whether or not anything could ever query it — 4,028 writes for a 1,000-row first screen, 40,028 for 10,000, measured by the harness this commit's parent added. Whether a batch named its hosts is a property of the background that composed it, not of the session, and a background knows it while composing. A driver now declares `publicInstanceAnnouncements` as a static capability, universal-core emits `ensure-public-instance` from that rather than from a negotiated reply, and `commit.announces` travels on every Lynx commit. Both arms of the harness now read 0. The negotiated capability keeps its own job. `commit.instances` — deferring a commit's handle deltas — still comes from it, captured at compose, and the main thread still rejects that flag from a peer that did not negotiate. What it no longer gates is the announcement, so the main thread's rejection of an "unnegotiated" announcement is gone: the flag is answerable without a session. Adoption learns to accept `ensure-public-instance` while replaying a first-screen batch. It creates and mutates nothing, and adoption stamps every adopted record with a selector unconditionally for the identity reason recorded at the transfer site, so the announcement is already answered by the time it would be replayed. `milestone-8-integration` caught this: adoption rejected the operation outright. The regression is the pre-handshake oracle in `background-root.test.ts`, now asserting both halves — the ref'd host addresses its node, and the hosts nothing can obtain a handle for carry no attribute. Reverting the driver's declaration turns both halves red. One consequence to name rather than bury: the first batch of a root now carries `commit.announces`, and its `ensure-public-instance` commands, without having negotiated them. It cannot be otherwise — there is nothing to negotiate with before the first message — so a background at this version needs a main thread at this version, and an older one rejects the first commit at validation rather than failing quietly. Today both threads ship from one build of one package. Refs #103, #66. Co-Authored-By: Claude <[email protected]> Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
|
| file | test | why |
|---|---|---|
octane/tests/browser/suspense-hydration/suspense-hydration.test.ts |
restores focused input and its selected text after a keyed DOM reorder | expected [ +0, +0 ] to deeply equal [ 2, 9 ] — headless selection restore, reproduces in isolation |
drei/tests/browser/upstream-e2e.browser.test.ts |
should match previous one | container cannot fetch potsdamer_platz_1k.hdr; the page.waitForFunction timeout is downstream of that |
dropzone/tests/probes/hydration.test.ts |
adopts root/input nodes and remains interactive without diagnostics | 5000ms timeout; already filed as its own issue |
rspeedy-plugin-octane/tests/native-demo.test.ts |
escalates cleanup for a detached descendant after its leader exits | pre-existing here per #66 §2.3 — macOS Lynx Explorer path |
Two things worth recording beyond the pass count.
One failure from the previous run is gone, and that is informative rather than lucky. #130's run reported five failing files; the fifth was octane-events-browser native-change, 12 page.waitForFunction timeouts, which passed 12/12 in isolation at the time. This run started on an idle host and native-change passed inside the full run. That is the load-induced reading confirmed, so it should not be carried forward as a standing container failure — the four above should.
Provenance of the run. It executed against this PR's head with two additional working-tree files, benchmarks/lynx-table/prototype/run-fcp.mjs and benchmarks/lynx-table/web/driver-client.mjs, which were committed afterwards as #133. Neither is in any Vitest project — vitest.config.js names no benchmarks path — so no test imports them and the run stands as evidence for this diff and for #133 alike. Recording it because the tree was not byte-identical to the pushed commit, not because it changes the result.
Generated by Claude Code
Correction and measurement: this fix does not reach a plugin-default first screen, and does not move first paintMeasured on #133, recorded there in full and in 1. The summary table's 2. What it is worth in first paint, where it does apply: nothing detectable. With the background owning the first commit, 40,028 → 0 moves median view-attach FCP from 2,134.9 ms to 2,102.2 ms — ~1.5%, n=5, ranges overlapping, the eager arm's fastest sample beating every announcing sample. That does not change my view that this should land. The case for it is the wire contract — a commit rather than a session carrying the promise, which is what closed the gallery regression and the latent #129 defect — plus the per-node work removed. The case is not first paint, and I would rather say so here than let a "40,028 → 0" headline get cited as a startup win. Consequence for the obvious follow-up. Teaching direct emission and adoption to install selectively is the slice that would reach the production first screen. This run argues against it on first-paint grounds: removing exactly those writes on the background path bought nothing measurable. NO-GO unless a different reason appears — retained attribute memory, or native attribute-selector matching cost. Scope is Lynx for Web in headless Chromium; native Body left unedited deliberately; this comment and the README are the record. Generated by Claude Code |
Adoption dropped every operation of the adopting batch, including ensure-public-instance. The transfer-site selector stamp only reaches hosts that own a physical node, and a native list row owns none until a cell materializes it, so a row named by the first batch kept selectorWanted=false forever and its ref addressed nothing. Adoption now replays exactly the ensure-public-instance operations. Also folds the always-true announces branch in the transport: the announcement is an invariant of this background, every commit carries it, and the constant's literal type keeps any future branch on it visibly dead. Co-Authored-By: Claude <[email protected]>
Summary
The first screen stops paying for selectors nothing can query.
after-renderis the order a production Lynx bundle starts in. The numbers comefrom the harness this PR's parent (#131) added; nothing else about it changed.
Why
A
nodes-refselector is installed only where a commit announced it would querythe host, and the announcement waited on the negotiated lazy-public-instance
capability. A background does not have that capability when it composes its
first batch — the batch is built before the main-ready reply reaches it — so the
largest tree a root ever mounts named nothing and the main thread installed on
every node of it.
Whether a batch named its hosts is a property of the background that composed
it, not of the session, and a background knows it while composing. That is the
whole change.
Changes
universal-core.ts— a new static capability,publicInstanceAnnouncements, joinslazyPublicInstancesas a reason to emitensure-public-instance. The two are separate reasons: a peer deferringpublic-instance metadata cannot produce a handle without being asked, and a
peer that announces always is one whose mount-time decisions depend on being
told before the batch ends. Drivers that declare neither are unaffected.
client-driver.ts— the Lynx driver declares it, from an exportedLYNX_PUBLIC_INSTANCE_ANNOUNCEMENTSso the fact has one home.transport.ts—commit.announcesnow comes from that fact.deferPublicInstanceskeeps reading the negotiated capability captured atcompose, which is the coupling perf(lynx): let a commit say whether it announced its public instances #130 introduced and this must not undo.
main-thread.ts— drops the "unnegotiated announced public instances"rejection. The announcement is answerable without a session, which is the
point;
commit.instanceskeeps both of its rejections.host-driver.ts— first-screen adoption accepts anensure-public-instanceoperation while replaying. It creates and mutatesnothing, and adoption stamps every adopted record unconditionally for the
identity reason recorded at the transfer site, so the announcement is already
answered by the time it would be replayed.
protocol.ts,nodes-ref.ts, andhost-driver.tsnow say what thesession decides (deferral) and what the commit decides (naming).
Validation
pnpm format:fileson the changed treespnpm sync— no generated changestsgo --noEmit -p packages/lynx/tsconfig.json,packages/lynx/tsconfig.testing.json,packages/octane/tsconfig.json—all clean. (
pnpm typecheck:fileson the single test file reportsnarrowing errors at lines this diff does not touch; they reproduce with
the file reverted, so they are an artifact of typechecking one file out of
its project.)
vitest run --project lynx— 32 files, 445 tests, all passvitest run --project octane— 439 files, 6,795 tests, all passvitest run packages/rspeedy-plugin-octane/tests/browser/web-host.test.ts— 3/3 pass. This is the real Lynx-for-Web harness, where the background
really does compose before the reply, and it holds the gallery
auto-scroll case perf(lynx): let a commit say whether it announced its public instances #130 fixed.
node benchmarks/bench.mjs --quick --ratios --only lynx-table— 13/13applicable guards pass, every count byte-identical to the pre-fix run
(
select=2 (252B, 2r),swap=2 (395B, 0r)), which is the evidence that atree naming nothing pays nothing new.
node benchmarks/lynx-table/first-screen-selectors.mjs --reps 2— botharms 0 at both scales
pnpm test— not run in full. The two projects this diff can affect aregreen above; the remaining failures in this container are the four
attributed on docs(bench): measure what the L5 main-thread repayment is worth #125.
Red-green. The oracle is "addresses a ref the background asked for before
the main thread was there", now asserting both halves: the ref'd host addresses
its own node and drives
setNativeProps, and#summary,#rows,#healthycarry no attribute. Setting
LYNX_PUBLIC_INSTANCE_ANNOUNCEMENTStofalseturnsthat assertion red, and takes the sibling demand test with it — which is the
right shape, since the constant is what both rest on.
A defect this surfaced.
milestone-8-integrationfailed on the first run:adoption rejected
ensure-public-instanceas an operation it cannot replay, soa first screen that adopts and holds a ref would have faulted. That is the fix
in
host-driver.tsabove, and it is exactly why announcing unconditionallyneeded the whole suite rather than the selector tests.
Risk / follow-ups
carries
commit.announcesand itsensure-public-instancecommands beforeany reply could have granted them — there is nothing to negotiate with before
the first message. So a background at this version needs a main thread at this
version; an older one rejects the first commit at validation with a message,
rather than failing quietly. Today both threads ship from one build of one
package, which is what makes that acceptable; if mixed-version pairing ever
becomes supported, this needs
LYNX_TRANSPORT_PROTOCOL_VERSION, and that isshared with the universal transport. Worth a maintainer's explicit call.
ref, a hostlifecycle, or a main-thread callback is announced and pays one write.
construction, unchanged, for the identity reasons recorded at those call sites.
Provenance
agent-authored)Generated by Claude Code