Skip to content

perf(octane): transported universal roots adopt retained subtrees — render breadth proportional to change size ([lynx-perf 3]) - #11

Closed
Huxpro wants to merge 1 commit into
lynx/commit-pacingfrom
lynx/auto-memo
Closed

Huxpro wants to merge 1 commit into
lynx/commit-pacingfrom
lynx/auto-memo

Conversation

@Huxpro

@Huxpro Huxpro commented Aug 9, 2026 •

Copy link
Copy Markdown
Owner

Closes #4. Stacked on #10 ([lynx-perf 2], base lynx/commit-pacing), which stacks on #1.

Summary

  • Transported universal roots now adopt committed component subtrees whose component reference, props, and consumed contexts are unchanged, instead of re-rendering them — the same retained-subtree machinery local drivers got in chore: universal root component now carries a committed range octanejs/octane#587, extended to the transport path it was conservatively excluded from.
  • On the Lynx table app this kills the O(N) replay breadth that dominated point updates: a 2-row select over 10k rows renders 2 Row components instead of 10,000, and a far swap renders 0.
  • The lynx-table rig gains a deterministic Row render-breadth counter (profile builds only, compiled out of shipping bundles), a swap op covering keyed reorder of adopted items, and 8 new ratio guards.

Why

  • Issue [lynx-perf 3] Compiler-backed auto-memo for keyed list items — kill O(N) replay breadth #4's directive was "README already claims memo bailouts — first find why the universal path doesn't get them before writing new machinery." The answer: #587 landed generic retained-subtree adoption at the universalComponent reconcile boundary two days ago, but retainEligible categorically excluded transported roots, so the whole dual-thread Lynx path never bailed. No new machinery (and no compiler assist) was needed — the exclusion was the entire defect.
  • The transport-specific bookkeeping the exclusion guarded turns out to already be adoption-safe: a full-root commit is acknowledged against one whole-tree version (adoption never creates a scoped protocol), retained ranges emit no commands (the wire diff was already change-proportional after feat(lynx): change-size-proportional commit wire cost, with a gated cross-framework benchmark (integration of 3 upstream PRs) #1), universal IDs are root-monotonic, and the accepted listener table is edited in place, retiring only re-staged or removed hosts — its own comment anticipates "retained subtrees, which this commit never re-staged".
  • Two deliberate deviations from the issue's sketch, called out for review:
    • Bail predicate stays Object.is shallow-equality (React memo semantics), not per-entry sameUniversalHostPropValue. The compiled @for shape passes identity-stable rows and useCallback-stable handlers, so identity comparison already bails; value-comparison would loosen React parity for mutated-in-place objects. Measured result meets the acceptance floor exactly, so the looser predicate stays a possible follow-up, not a need.
    • No compile-universal.js change. The adoption boundary fires for any @for item that renders a component child — the same boundary React memo uses. Items that inline bare hosts without a component boundary still re-run their lambda (wire output still elides via value-diff from feat(lynx): change-size-proportional commit wire cost, with a gated cross-framework benchmark (integration of 3 upstream PRs) #1).

Changes

  • packages/octane/src/universal-core.ts: drop this.transport === null from the full-root retainEligible predicate; comment documents why transported roots qualify. Bridge, replay, transition, and full-root-scheduled attempts stay excluded; the scoped owned-update path stays local-only.
  • packages/octane/tests/universal-transport.test.ts: new transported retained-subtree adoption suite over the real MessageChannel loopback — adoption + retained-listener dispatch + own-prop re-entry, context-change re-render through retained-prop items (and re-adoption after the provider settles), keyed rotation of adopted items without re-render or remount. All three fail before the fix (every item re-renders).
  • benchmarks/lynx-table: Row render counter behind __OCTANE_LYNX_PROFILE__ (App.lynx.tsrx), itemRenders per-op counters and a swap op (workload.ts), gates + drift signature + console output (run.mjs), README notes the third counter.
  • benchmarks/baselines/ratios.json: 8 guards — {update10th,select,swap}_item_renders_{1k,10k} at the changed-rows floor, plus swap_commands_{1k,10k} pinned as a KNOWN GAP waterline (997 move commands for a rows-1↔998 transposition vs the 2-move model; LIS guarantees final order and survivor identity, not move-set minimality).
  • .changeset/universal-transport-retained-adoption.md: octane patch.

Measured

Deterministic (in-process dual-thread rig, real tap tokens, drift-checked across iterations; wire counters byte-identical before/after):

op item renders before after floor
select@1k / @10k 1000 / 10000 2 / 2 2
update10th@1k / @10k 1000 / 10000 100 / 1000 ceil(rows/10)
swap@1k / @10k 1000 / 10000 0 / 0 — (model 2)

Red-checked: reverting the gate breaches update10th_item_renders_1k at 10.00×, select_item_renders_1k and swap_item_renders_1k at 500.00×, and the three new behavioral tests fail on both octane and octane-prod projects.

Lynx for Web wall clock (same 4-core host, back-to-back runs, identical instrument every cell, medians of n=3), before → after:

op @10k octane before octane after vue-vdom vue-vapor react
create 4819 (2.10×) 4459 (2.17×) 2055 2293 1759
update10th 888 (4.57×) 473 (2.60×) 182 176 265
select 813 (5.32×) 274 (1.95×) 141 155 174
updateStorm 3590 (1.09×) 1460 (0.51×) 2885 1567 6121
selectStorm 1039 (0.71×) 487 (0.35×) 1383 165 2671
op @1k octane before octane after vue-vdom
update10th 129 (4.17×) 53 (2.80×) 19
select 123 (5.59×) 28 (1.15×) 24
updateStorm 453 (2.05×) 153 (0.78×) 196
selectStorm 158 (1.95×) 43 (0.58×) 73
  • select@1k reaches vue-vdom parity; both storms now beat vue-vdom outright at 10k (updateStorm 0.51×, selectStorm 0.35×) and land at vue-vapor's level.
  • Issue [lynx-perf 3] Compiler-backed auto-memo for keyed list items — kill O(N) replay breadth #4's aspirational bands (select@10k 150–250ms, update10th@10k 200–350ms) are not fully reached: 274ms and 473ms. The residual is the O(N) item-lambda re-run itself (10k descriptor/props allocations + shallow-compare per parent render), which adoption does not remove — noted on the issue as the honest remainder.
  • create is unchanged within noise (deterministic create counters identical).

Validation

  • pnpm format:check
  • pnpm typecheck
  • pnpm test — full root run on this head: 16889 passed / 106 skipped; 19 failed files are the container's known pre-existing set, identical to the pre-change baseline run (17 Playwright-browser files — no Chromium download allowed in this environment, rspeedy native-demo — macOS-only, website ssr-smoke /benchmarks card count — pre-existing on the base branch, reported on feat(lynx): change-size-proportional commit wire cost, with a gated cross-framework benchmark (integration of 3 upstream PRs) #1). Six more tests pass than baseline: the three new retention tests × two projects.
  • targeted: universal-transport (48/48, both projects, incl. the pinned ack-coalescing contract), all universal-* suites (444/444), packages/lynx/tests (280/280, two-realm rig with validation on)
  • node benchmarks/bench.mjs --quick --ratios --only lynx-table → PASS, 13 guards checked; red-check breaches exactly the new guards
  • new tests red-checked against the reverted gate

Risk / follow-ups

Provenance

  • An agent produced this diff (agent-authored)

🤖 Generated with Claude Code

https://claude.ai/code/session_013br9KPN1riTSP683xEvUuU


Generated by Claude Code

Transported full-root attempts were categorically excluded from
retained-subtree adoption, so every background render re-ran all keyed
children even when their component, props, and consumed contexts were
unchanged - on the Lynx table benchmark a 2-row select re-rendered all
10k rows. A transported full-root commit is still acknowledged against
one whole-tree version, adoption emits no commands for retained ranges,
and the accepted listener table already retires only re-staged hosts, so
the local-driver adoption gate extends to transported roots unchanged.

Regression tests pin adoption, context refresh, retained-listener
dispatch, and keyed reorder of adopted items over a real MessageChannel
transport. The lynx-table rig gains a profile-only Row render-breadth
counter, a swap op, and 8 ratio guards; select@1k renders drop 1000 -> 2
and swap renders 0 while every wire counter stays byte-identical.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013br9KPN1riTSP683xEvUuU
@Huxpro

Huxpro commented Aug 11, 2026

Copy link
Copy Markdown
Owner Author

Conclusion: close as landed upstream. The adoption fast path is represented by octanejs/octane PR 696, so this historical branch should not be merged separately.

@Huxpro Huxpro closed this Aug 11, 2026
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