Repository navigation
perf(lynx): install a nodes-ref selector only where one was requested - #129
Merged
Merged
Conversation
A native <list> cell used to clear and reinstall a nodes-ref selector on every element node of every recycle, and three predicates in main-thread.ts installed one as a side effect of asking an unrelated question, because driver.getPublicInstance installs as it reads. A record now carries a sticky selectorWanted bit beside its per-node selectorInstalled bit, set by ensure-public-instance and by getPublicInstance. The list-cell create and rebind paths install only for hosts that asked, the enqueue-time clear only clears what was installed, and the three predicates use a new non-installing getLynxHostHandle. The want outlives the node because a detached cell owns none and nothing re-renders to re-announce the request. Both peers derive the regime from one negotiated flag, now single-sourced as lynxLazyPublicInstancesNegotiated in protocol.ts: a peer that announces no public instances keeps the eager install, because for it an uninstalled selector is a ref that addresses nothing. The wire is unchanged -- universal-core already announced exactly the hosts that can obtain a handle. One steady-state recycle now costs the slot-write floor exactly: 2 Element PAPI writes on the 3-node row and 3 on the 9-node row, down from 6 and 15. The lynx-list ratio ceilings drop from 3 and 5 to 1. Co-Authored-By: Claude <[email protected]> Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
1 task done
Huxpro
pushed a commit
that referenced
this pull request
Aug 21, 2026
The demand rule from #129 covered only native list cells. Extending it to ordinary create, recreate, and template-run mounts drops the benchmark table from 4,000 nodes-ref selector writes to 0 at 1,000 rows, and from 40,000 to 0 at 10,000. Reading the session's negotiated lazyPublicInstances capability to decide it is unsound. A background composes its first batch before the main-ready reply granting the capability reaches it, and dispatches it after, so that batch names none of the hosts it will query however the session was negotiated. The main thread, reading the reply it had already sent, skipped their selectors: the gallery example's <list ref> mounted unaddressable and its auto-scroll invoke failed with native code 2. Commits now carry the promise themselves in a new optional `announces` field, stamped from the capability captured when the batch was composed. The main thread latches its container into demand installs on the first commit that makes it, which is sound because delivery is FIFO. `instances` is decided from the same compose-time capability rather than re-read at dispatch, closing the same silent ref loss for a compact template-only first batch. Co-Authored-By: Claude <[email protected]> Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
This was referenced Aug 21, 2026
Huxpro
changed the base branch from
perf/lynx-demand-nodes-ref-selector
to
new-lynx
August 21, 2026 22:18
Huxpro
marked this pull request as ready for review
August 21, 2026 22:18
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
A
nodes-refselector is now installed only where a public instance wasrequested, and it follows its logical host across native
<list>recycles.One steady-state recycle costs the slot-write floor exactly.
list-item > text > #textsetRefSelectorno longer appears in a steady-state recycle at all. Bothbenchmarks/baselines/ratios.jsonceilings drop from 3 and 5 to 1.Why
#128 measured the residual over the floor and named its three sources. Two calls
per element node per recycle — cleared at
enqueueComponent, reinstalled atcomponentAtIndex— plus three places inmain-thread.tsthat installed aselector as a side effect of asking an unrelated question, because
driver.getPublicInstanceinstalls one:updatecommand in a commit;on every recycle.
#128's ablation showed why installing lazily at the create/rebind paths alone
buys nothing: the attachment predicate reinstalls what the enqueue cleared, so
the same calls move into a different column. The floor is reachable only if the
predicate stops installing too — and that is what makes this a protocol change
rather than a local one.
The protocol already carries the request.
ensure-public-instanceis emitted byuniversal-corefor exactly the hosts that can obtain a handle (aref, alifecycle, or a local callback), so this adds zero extra commands to the
wire. What was missing was that the main thread treated the announcement as
advisory and installed eagerly anyway.
Changes
host-driver.ts: a record carries a stickyselectorWantedbit beside itsper-node
selectorInstalledbit.ensure-public-instanceandgetPublicInstanceset it; the list-cell create and rebind paths install onlyfor hosts that asked; the enqueue-time clear only clears what was installed.
The want outlives the node, because a detached cell owns none and nothing
re-renders to re-announce the request.
getLynxHostHandle(container, id): one host's identity withoutrequesting a public instance. The three predicates above use it, which leaves
acknowledgementHandleswith no use for the driver at all, so that parametergoes.
protocol.ts:lynxLazyPublicInstancesNegotiated(capabilities)— the singlederivation of the negotiated flag, now used by both peers. The main thread
goes demand-only only when it holds, and
client-driver.tssets its ownlazyPublicInstancesfrom the same call. Each half is unsound without theother: a main thread that skips the selector while the background skips the
announcement strips refs with no error anywhere.
LYNX_LAZY_PUBLIC_INSTANCE_READY_REQUEST_BASE, or one thatannounced no capabilities, keeps the eager install. For it an uninstalled
selector is a ref that addresses nothing.
existing end-to-end recycled-list scenario in
background-list.test.tsstrengthened to assert that a row's own handle still addresses the cell
showing it, across a real recycle over the real transport.
Only the native-list paths (
createPhysicalTree/rebindPhysicalTree) becamedemand-driven. Ordinary create, recreate, and first-screen adoption still
install eagerly; making those lazy too is the broader change and is not in
this diff.
Validation
pnpm format:checkpnpm typecheckpnpm test— 21,052 pass, 3 fail, none in a package this difftouches.
git diff base..head --name-onlylists onlypackages/lynx/,benchmarks/, and a changeset, so all three suites read byte-identicalinputs on both sides. All three are already attributed as this container's
persistent failures in
#125's per-file attribution,
which reproduced them on two branches sharing no code:
rspeedy-pluginnative-demo(stopProcessTreereaping in a Linuxcontainer, pre-existing per Execution plan (#58): complete L2, then drive L4→L6 — full context handoff #66 §2.3),
drei-adapted-browserupstream-e2e(an external.hdrasset this container cannot fetch), andoctane-events-browsersuspense-hydration([0, 0]instead of[2, 9]). I re-ran the last one alone on a quiet host and it still fails,which matches docs(bench): measure what the L5 main-thread repayment is worth #125 placing it in the persistent rather than the
load-sensitive class. docs(bench): measure what the L5 main-thread repayment is worth #125's fourth,
dropzoneprobes/hydration, did notfail in this run.
vitest run --project lynx— 32 files, 443 tests, all passnode benchmarks/bench.mjs --quick --ratios lynx-list— 3/3applicable guards pass at the new 1.00x ceilings
Both oracles were checked against a broken implementation, not just asserted:
asked about; on this change it reports none.
end-to-end scenario red at
expected null to be 'Row 0'— the row wasannounced at mount, a thousand rows before any cell existed.
Risk / follow-ups
and each announced node still pays the clear-and-reinstall pair. The saving
is per node nobody queries, not per row; the benchmark's rows carry none, so
the headline numbers are the best case, not the average one.
announcesPublicInstancesfallback is covered by a regression test but isnot measured by the benchmark suite.
creates a fresh node or reuses one that
clearPhysicalTreeAttachmentcleared,and both re-entry points reset
selectorInstalledfirst, so a demand-skippedinstall cannot leave a node answering an old selector.
detachListCellclearson all four pooling modes;
recreateskips hosts with no active node, so adetached cell is never materialized outside the list path.
createandrecreateops, first-screen direct emission, and first-tree adoption. Every node they
produce gets a selector whether or not anything ever queries it. The
template-run path is already conditional, so how much that is worth depends on
how much of a first screen mounts through templates — which is unmeasured, and
is the next thing to measure rather than to assume. (The third incidental site
this PR removed, the per-
updatehandle publication, is not part of thatremainder; it is fixed here.)
Provenance
agent-authored)Generated by Claude Code