Skip to content

test(lynx): pin what a recycled list cell spends at the host boundary - #259

Merged
Huxpro merged 2 commits into
new-lynxfrom
test/lynx-recycle-host-boundary
Aug 31, 2026
Merged

Huxpro merged 2 commits into
new-lynxfrom
test/lynx-recycle-host-boundary

Conversation

@Huxpro

@Huxpro Huxpro commented Aug 31, 2026

Copy link
Copy Markdown
Owner

Summary

#193's Layer 1 sketch prices recycling-as-slot-writes as something program-per-cell would buy — "no teardown, no re-describe". Neither is what the renderer does today, so the sketch would have banked a saving that is already banked. This counts the boundary rather than arguing about it, and the count is the oracle a later slice has to beat.

Recycling one physical cell from row 0 to row 617 of a deferred run, against the same three-host row a fresh materialize builds:

call fresh recycle
createElement 3 0
insertBefore 3 0
setClasses 1 0
setAttribute 2 2
setRefSelector 2 2
getUniqueId 2 2
flush 1 1
total 14 7

The two writes on the recycle are exactly the two bound slots (item-key → item-617, text → Row 617). class is static in the program, so the patch finds nothing on it and setClasses never runs — the prop diff pays for itself here rather than costing. The two setRefSelector calls are not waste: the selector encodes the host id, which genuinely changes when a cell changes rows.

So a compiled rebind could not issue fewer host calls than these, only decide them for less.

Why

What the count cannot see is where that deciding happens — the record and frozen prop bag resolveRecord allocates per host, the patch planLynxHostPropPatch computes to rediscover which names a run already says are the only ones that vary, and the event set torn down and reinstalled per host. #195 R2 measured that script at 73% of the callback wall on device against ~8 ms/window of element+crossing, so a near-minimal count here does not mean a recycle is cheap: it locates the remaining cost off this boundary, which is the finding.

The full design reading this supports — including why the emission needs no rebind entry — is on #193.

Changes

  • packages/lynx/tests/list-recycling.test.ts: one test in the existing Lynx deferred template runs block, reusing that block's fixture. Wraps the Element PAPI in a plain counting object (not a Proxy — createLynxElementPAPI returns frozen non-configurable members, which a Proxy may not report as anything but themselves).

No product code changes, so no changeset.

Validation

  • pnpm format:check — ran pnpm format:files packages/lynx/tests/list-recycling.test.ts, unchanged
  • pnpm typecheck — exit 0
  • pnpm test — not run in full; npx vitest run --project lynx instead
  • targeted tests: npx vitest run --project lynx — 48 files / 737 passed; pnpm sync clean

Seen red three ways before being trusted, each on its own assertion, each restoring green:

mutation went red on
rebindPhysicalTree re-describes the row ({} as previous props) instead of diffing against what the cell holds …to not include setClasses
materializeListItem never reuses a pooled cell the createElement/insertBefore assertions
resolveRecord materializes without retaining the record-count assertions

Risk / follow-ups

A count-pinning test is deliberately brittle: a later Layer 1 slice that changes the recycle path will turn it red, and updating it to the new numbers is the intended workflow rather than a failure.

Branch naming: the harness assigned claude/octane-issue-66-phase-a-7wz97z for this session, but create-a-pr requires a feat/|fix/|docs/|test/|perf/ topic branch so label-pr.yml can read the type. Topic branch used; flagging the conflict rather than resolving it unilaterally.

CI on this repo is currently wedged repo-wide — classify changeset release never gets a blacksmith-4vcpu-ubuntu-2404 runner and every other ci.yml job carries needs: release_change. Nothing has produced a pass or fail since run 434. Reported at #257; not repeated here.

Provenance

  • An agent produced this diff (agent-authored)

Generated by Claude Code

Issue #193's Layer 1 sketch prices recycling-as-slot-writes as something
program-per-cell would buy -- "no teardown, no re-describe". Neither is what
the renderer does today, so the sketch would have banked a saving that is
already banked. This counts the boundary rather than arguing about it.

Recycling one physical cell from row 0 to row 617 of a deferred run, against
the same three-host row a fresh materialize builds:

  fresh    3 createElement, 3 insertBefore, 1 setClasses, 2 setAttribute,
           2 setRefSelector, 2 getUniqueId, 1 flush -- 14 calls
  recycle  0 createElement, 0 insertBefore, 0 setClasses, 2 setAttribute,
           2 setRefSelector, 2 getUniqueId, 1 flush -- 7 calls

The two writes are exactly the two bound slots. `class` is static in the
program, so the patch finds nothing on it and `setClasses` never runs -- the
prop diff pays for itself here rather than costing. The two `setRefSelector`
calls are not waste: the selector encodes the host id, which genuinely changes
when a cell changes rows.

So a compiled rebind could not issue fewer host calls than these, only decide
them for less. What the count cannot see is where that deciding happens -- the
record and frozen prop bag `resolveRecord` allocates per host, the patch
`planLynxHostPropPatch` computes to rediscover which names a run already says
are the only ones that vary, and the event set torn down and reinstalled per
host. Issue #195 R2 measured that script at 73% of the callback wall on device
against ~8 ms/window of element and crossing, so a near-minimal count here does
not mean a recycle is cheap: it locates the remaining cost off this boundary,
which is the finding.

Seen red three ways before being trusted: a recycle that re-describes the row
instead of diffing against what the cell holds, one that never reuses a pooled
cell, and a materialization that does not retain what it derived. Each turns
this test red on its own assertion and restoring turns it green.

Test-only, so no changeset.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
# Conflicts:
#	packages/lynx/tests/list-recycling.test.ts
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.

1 participant