Skip to content

test(bench): count who installs the nodes-ref selector during a recycle - #128

Merged
Huxpro merged 2 commits into
new-lynxfrom
perf/lynx-demand-nodes-ref-selector
Aug 21, 2026
Merged

Huxpro merged 2 commits into
new-lynxfrom
perf/lynx-demand-nodes-ref-selector

Conversation

@Huxpro

@Huxpro Huxpro commented Aug 21, 2026

Copy link
Copy Markdown
Owner

Summary

The per-recycle measurement on #119 named the residual over the slot-write floor —
setRefSelector, two calls per element node — but could not say who makes
those calls, because the benchmark left the container's onAttachments unwired.

Production does not leave it unwired. One recycle emits an attachment delta per
node of the outgoing cell and per node of the incoming one, and main-thread.ts
filters that batch by asking the host driver for each host's public instance and
comparing generations. getPublicInstance installs the node's nodes-ref
selector as a side effect, so that predicate is an install site, not a read.

This wires it and reports two axes per recycle: the deltas the predicate
examined, and the Element PAPI writes it performed — counted inside the
existing write total rather than added to it.

row attachment deltas per recycle writes the predicate performed
list-item > text > #text 6 0
card row with a nested badge 18 0

Every pre-existing number is unchanged: 6 writes / 4 nodes on the narrow row,
15 / 9 on the wide one, 3.00x and 5.00x against the slot-write floor. The ratio
guards on reuse_writes and wide_reuse_writes still pass at their committed
ceilings.

Why the zero is the point

The obvious reading of #119's residual is "install the selector on demand instead
of eagerly". A local ablation says that buys nothing, because the predicate
reinstalls what the enqueue cleared:

arm narrow writes of which the predicate wide writes of which the predicate vs floor
today (eager install) 6 0 15 0 3.00x / 5.00x
lazy at createPhysicalTree/rebindPhysicalTree 6 2 15 6 3.00x / 5.00x
…plus guarding the enqueue-time clear 6 2 15 6 3.00x / 5.00x
…plus the predicate no longer installing 2 0 3 0 1.00x / 1.00x

The middle two arms relocate the same setRefSelector calls into the new column
instead of removing them. Only the last arm reaches the floor, and it is not a
local change: the background builds a nodes-ref selector string on first query
without ever asking the main thread to install one, so removing the incidental
install sites requires the protocol to state who installs and when. That decision
is recorded on #103; this PR only makes the cost of each option measurable.

The ablation ran as a temporary local patch and is not part of this diff —
packages/lynx/src/core/host-driver.ts is untouched here.

Validation

  • targeted: node benchmarks/lynx-list/run.mjs 1 and 2 — counts identical
    across repetitions, no reported failures
  • targeted: node benchmarks/bench.mjs --quick --ratios lynx-list —
    3/3 applicable guards pass, none breached
  • pnpm format:files on all three changed files
  • pnpm sync — no generated changes
  • pnpm typecheck — benchmarks/ is in no tsconfig project
    (pnpm typecheck:files reports "No TypeScript project includes"). Checked
    instead with a standalone strict tsc --noEmit over workload.ts: the two
    errors it reports are byte-identical to the ones the pre-change file
    produces, both in the intentionally partial fake PAPI. The change adds none.
  • pnpm test — not run; this diff touches only benchmarks/lynx-list/

Risk / follow-ups

  • The benchmark now replays the main thread's attachment-delivery predicate
    rather than importing it, because deliverHostAttachments is internal to
    main-thread.ts. If that predicate changes shape, this replay must follow.
    It throws rather than skipping when its container is unbound, so a delta it
    cannot count is a failure instead of a silently lower number.
  • Two further install sites exist and are not measured here:
    main-thread.ts publishes a handle for every update command in a commit, and
    resolves first-screen native event targets, both through the same
    side-effecting getPublicInstance. Any demand-install design has to account
    for them too.

Provenance

  • An agent produced this diff (agent-authored)

Generated by Claude Code

The per-recycle measurement said the residual over the slot-write floor is
setRefSelector, two calls per element node. It could not say who makes them,
because it left the container's onAttachments unwired.

Production does not. A recycle emits an attachment delta per node of the
outgoing cell and per node of the incoming one, and the main thread filters
that batch by asking the host driver for each host's public instance. That
call installs the node's nodes-ref selector as a side effect, so the predicate
is an install site rather than a read, and a benchmark without it measures a
recycle in a shape the product never runs.

Wire it, and report two axes: the deltas the predicate examined and the
Element PAPI writes it performed, counted inside the existing write total
rather than added to it. Every pre-existing number is unchanged — 6 writes on
the narrow row and 15 on the wide one, 3.00x and 5.00x against the floor —
because the selectors are already installed by the time the predicate runs.

That zero is the finding. Installing selectors on demand at the create and
rebind paths alone does not remove the residual; it relocates the same calls
into this column, because the predicate reinstalls what the enqueue cleared.

Co-Authored-By: Claude <[email protected]>
Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
…nodes-ref-selector

# Conflicts:
#	benchmarks/lynx-list/workload.ts
@Huxpro
Huxpro changed the base branch from test/lynx-list-reuse-work to new-lynx August 21, 2026 21:29
@Huxpro
Huxpro marked this pull request as ready for review August 21, 2026 22:17
@Huxpro
Huxpro merged commit d2673c0 into new-lynx Aug 21, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants