Repository navigation
test(bench): measure what one native-list recycle costs at the Element PAPI - #119
Conversation
…t PAPI The lynx-list benchmark counted how many cells are reused. It did not count what a reuse costs, which is the number issue #103's U3 step is named for: recycling a row by writing only the slots whose value differs, instead of rebinding its physical subtree. Count every fake Element PAPI entry point and sample one window around each scroll step's enqueueComponent + componentAtIndex pair, reported against a slot-write floor derived from the fixture's own row shape. A second row shape runs beside the existing one — 9 nodes, 3 varying values, 6 static props — because one shape cannot separate "the write path tracks the changed values" from "it tracks the row's size". The answer is the same at both widths: setAttribute is 2 and 3, which is the floor exactly. The whole gap is setRefSelector, two calls per element node per recycle, clearing the nodes-ref selector when a cell is enqueued and reinstalling it for the incoming logical host. Per-recycle PAPI traffic is bounded by the row's element count, not its prop count, and the prop write path has no slack in it. Both ratios are committed as guards so the finding is a gate rather than a note. They are deterministic call counts, not timings, and they do not measure the CPU the host spends deciding what to write. Co-Authored-By: Claude <[email protected]> Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
Answering this PR's follow-up: demand-driven selector installation — NO-GO as a local changeThis PR's body nominated the residual as its own design and its own PR:
I took it, implemented it, and reverted it. The finding is worth more than the patch was. Demand-driven installation already existsIt is not missing — it is already built, and already correct:
So the eager installs are not an oversight. They are the fallback for every regime that is not that one. Why the gate is where it isLaziness requires both The reason is sound, and it is about the background, not about main. Only under a compact acknowledgement does the background derive its handles locally from the batch ( Why a native list can never reach that regime
Meanwhile The two populations are disjoint by construction. The only code that recycles is the only code that can never be lazy. That is the whole finding, and no amount of local rework in What I actually built, and what it costA sticky
Those last four are not stale assertions. They are the deliberate contract above, and my latch was reading What it would actually takeBoth options are protocol-level, and both are about when the background becomes able to query — not about when main installs:
I recommend 1. It reuses a command that already exists, it deletes a special case rather than adding one, and it makes every regime behave the way the compact one already does. 2 keeps the change inside The prize, if it is takenPer steady-state recycle, on this PR's own counters:
That is the slot-write floor this PR defined, reached exactly — and reached by fixing selector lifetime, which this PR correctly identified as a different lever from the slot tables it ruled out. This needs a decision before anyone writes it, so I am leaving it here rather than opening a PR that changes the protocol on my own initiative. Generated by Claude Code |
The narrow and wide reuse workloads compare their numbers against each other, so the begin/leave/sampleSoFar/enter/end window must be the same on both arms; it was copy-pasted, and a future edit to one loop would silently skew one arm. sampleRecycle() now owns the window for both. Reported numbers are unchanged (ratios 3.00x/5.00x reproduce). Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01YHfFsy9CLaRovTFH8pTGyY
Summary
Issue #103, step U3a — the ceiling measurement §5 puts before U3's implementation slices. It is independent of the #66 stack and based directly on
new-lynx.benchmarks/lynx-list/already counts how many cells are reused (12 physical cells, 988 reuses, 1,000 logical rows). It never counted what a reuse costs, which is the number U3 is named for: recycling a row by writing only the slots whose value differs, instead of rebinding its physical subtree node by node.This adds that counter. Every fake Element PAPI entry point routes through one recorder, and one sample is taken around each scroll step's
enqueueComponent+componentAtIndexpair. The result is reported against a slot-write floor — write the values that differ between the outgoing row and the incoming one, touch only the nodes that own them — derived from the fixture's own row description rather than restated as a constant.A second row shape runs beside the existing one, because one shape cannot separate two very different answers: the write path tracks the changed values versus it tracks the row's size.
The measurement
Zero variance: all 988 samples of each shape are identical (
writes 6-6,writes 15-15).Broken down by entry point, one steady-state recycle is:
setAttributesetRefSelectorgetUniqueIdflushcreateElement/ insert / remove / replaceWhat it says
setAttributeis 2 and 3 — the floor exactly, at both widths.planLynxHostPropPatchalready diffs, sorebindPhysicalTreewrites only the values that actually changed, and it does so independently of how many static props and extra nodes the row carries. There is no prop-write slack for a slot table to recover.The entire gap is
setRefSelector: two calls per element node per recycle —clearPhysicalTreeAttachmentblanks thenodes-refselector when a cell is enqueued, andensureNodesRefSelectorreinstalls it for the incoming logical host. The selector encodes the logical host id (r{root}-h{id}-g{generation}), which necessarily changes when one physical cell is re-pointed at a different logical row. So per-recycle PAPI traffic is bounded by the row's element count, not its prop count.This is a NO-GO for U3's recycling-by-slot-write premise on this workload, and the U3 design's §3 claim that reuse costs "proportional to the row's node count and prop count" is wrong for the prop half. A template-described row would still have to rewrite the selector, because it still changes logical identity — so the residual is not something slot tables address. I am recording the verdict here rather than softening it; §5's gate says the step stops if the current path is already near the floor.
It does name a separate, better-scoped question for later: every host element gets a
nodes-refselector installed eagerly, whether or not any query can ever name it. On the wide row that is 12 of 15 writes per recycle, 80%, paid by pages that never callSelectorQuery. Making selector installation demand-driven is its own design and its own PR.Guards
Both ratios are committed to
benchmarks/baselines/ratios.json, so the finding is a gate rather than a note — a regression in the prop diff shows up as a breach, and an improvement to selector lifetime shows up as headroom.Validation
node benchmarks/bench.mjs --quick --ratios lynx-list→ PASS, 3/3 guards checked (physical_cells0.012x eager unchanged,reuse_writes3.00x,wide_reuse_writes5.00x)vitest run --project lynx→ 441 passed (32 files)pnpm sync— no generated changespnpm format:fileson every changed filepnpm typecheck— not run for this diff: no changed file is in any TypeScript project (benchmarks/lynx-list/workload.tsis bundled by esbuild and is not in a tsconfig). Checked standalone with the sametsgoflags before and after: the two pre-existing errors (getParent/isEqualmissing from the fake PAPI,setEvent's listener union) are identical onnew-lynx, and this diff adds none.pnpm test— not run for this diff; it touches onlybenchmarks/, and the tworspeedy-pluginfailures issue Execution plan (#58): complete L2, then drive L4→L6 — full context handoff #66 §2.3 records as pre-existing in this container are unrelated to it.Risk / follow-ups
rebindPhysicalTreestill walks the subtree and builds a prop patch per node even when it emits nothing. A row-width sweep of that cost would need a timing harness, and this suite is deliberately not one.slot-write-flooris a target with no implementation behind it. It exists to be a denominator; it is not a claim that 3 writes is reachable whilenodes-refselectors keep their current lifetime.Provenance
agent-authored)Generated by Claude Code