Skip to content

perf(octane): read a deferred JSX value's fields once per classification - #1663

Merged
trueadm merged 13 commits into
mainfrom
perf/scoped-value-repeat-reads
Oct 3, 2026
Merged

trueadm merged 13 commits into
mainfrom
perf/scoped-value-repeat-reads

Conversation

@trueadm

@trueadm trueadm commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

svg-dashboard's tooltip_swarm went from about 1.6–1.7 ms at #635/#833-era commits to 2.06–2.24 ms on main. That puts it at 0.75–0.78× React against a 0.8 ceiling, and its guard is waived on #1646. Paired same-runner attribution (runs 37114023279 and 37114031982) places the extra cost at #1069 and later.

Every ui commit re-renders Viewport, which receives the dashboard subtrees as deferred JSX values (createScopedValue). Each commit classifies the same defs value and the four children of the layers Fragment again. Every field read of a deferred value runs an accessor that calls its resolver. Before this change, a commit paid 88 accessor calls:

  • childSlot read the type up to seven times per value.
  • childSlot read the key twice and the invocation site once on update paths that never use them. feat: add async signals and streaming SSR #1069 added those reads.
  • De-opt list keys read each child's key three times.

This PR reads each field once per classification and skips the reads an update path never needs:

  • childSlot reads the element type once, after Usable unwrapping, and derives the component, host, pure-host, Fragment and unframed-root checks from it. The component descriptor's key and __octaneInvocationSite are read only on the mount path that builds the signal instance key; componentSlot already stamps only new or replacement instances.
  • deoptItemBody, prepareDeoptList and normalizePortalBody reuse one type read. deoptItemBody treats a component item as needing Blocks directly. childSlot's pure-host check asks descNeedsBlocks about a host's children, which is equivalent once Usable unwrapping has run.
  • ownListKey reads a list child's key once and serves deoptKey, deoptKeyPositional and flattenReactChildContainer. appendScopedDeoptKey now takes that key instead of re-reading item.key. The missing-key warning keeps its conditions, now behind a leading NODE_ENV check so production drops it.
  • createScopedResolver returns a resolved record that read no context without computing scope identity. Only a context-reading record ever compares resolvedScope, and each resolution resets it.

Accessor laziness, context-aware rebuilds, the descriptor shape and keys are unchanged. Scoped classification is still per resolving scope; nothing is cached by descriptor identity, which descriptor-renderer's audit showed is unsound.

Deterministic work: svg-dashboard/work.mjs

The new untimed work pass rebuilds the octane fixture unminified and counts named production calls under jitless Chromium precise coverage, the same method as recursive-context/work.mjs.

commits accessor calls on main this PR renderBlock / childSlot / deoptItemBody (both)
16 tooltip_swarm 1,408 (920 type, 316 key, 92 props, 80 site) 404 92 / 112 / 64
8 pan_zoom 680 184 40 / 56 / 32
  • Controls. The structural counts match, so the same slot visits now cost about a quarter of the accessor calls. The gate also compares every commit's tooltip transform and title, and the viewBox and root transform, with the shared ops replay. It fails if a dashboard subtree (defs, topology, charts, sparks, icons) loses DOM identity.
  • Guards. Two ratio guards cap tooltip_cycle_scoped_reads and pan_zoom_scoped_reads at the reviewed budget, max ratio 1. Main fails both.

Timing

Timing was not measured locally. A same-runner paired A/B on the scratch branch scratch/scoped-reads-ab, which is never merged, reuses benchmarks/ab-scratch.sh from scratch/bench-attrib-regressions. It builds svg-dashboard's octane fixture at main 950ef0b and at this change (6e54159), serves both beside React, and runs the paired harness from #1646 twice, rotating target order every round: run 37117916097. Times are ms per batch, pass 1 / pass 2.

op main this PR PR/main main/React PR/React
tooltip_swarm 2.030 / 1.996 1.833 / 1.786 0.903 / 0.895 0.777 / 0.785 0.701 / 0.702
pan_zoom 2.192 / 2.239 1.681 / 1.775 0.767 / 0.793 0.559 / 0.538 0.428 / 0.426

Bytes

  • Bundle-size suite. The framework chunks for js-framework, TodoMVC, chat and weather are byte-identical to main on raw, gzip and brotli. descNeedsBlocks is unchanged because the read-once callers no longer need a pre-read type.
  • Reachability. Scenarios that include the full child-slot code are flat or smaller in raw size (root-static −33, binding-radix-vite −17, binding-apollo-client-vite −31, binding-base-ui-vite +7 bytes). Their gzip and brotli move by tens of bytes from minified identifier renaming; the token diff is in a PR comment.

Validation

  • pnpm format:check: not run repo-wide. pnpm format:files:check passes on every changed file.
  • pnpm typecheck: not run repo-wide. pnpm typecheck:files is clean on runtime.ts, the new test, and its fixture.
  • pnpm test: left to CI.
  • targeted tests, octane project, 19 files, 817 tests: scoped-jsx-props-rerender (new), hydration/signal-instance-identity, descriptor-classification, scoped-jsx-prop-identity, scoped-jsx-values, deopt-child-key-aliasing, deopt-fragment-sibling-keys, conformance/fragment-reconciliation, conformance/element-children-api, deopt-item-selfmark, deopt-pure-host-upgrade, deopt-item-path-switch, portal-into-deopt-host, portal-child-key, portal-value, portal, fragments, jsx-context-children, svg-deopt. The new test also passes in octane-prod.
  • New scoped-jsx-props-rerender.test.ts follows the svg-dashboard shape. An owner passes deferred values to a shell that re-renders on its own state: a lone keyed component, a positional Fragment, a keyed array, an unkeyed array, and a portal body. Each mutation below was applied deliberately and turned the named test red:
    • list keys ignored → keyed reorder test;
    • keyed-single list key dropped → key-remount test;
    • positional children warning → the shell re-render test, which pins exactly one missing-key warning.
  • Existing tests already guard the other two changes:
    • resolver ignoring context reads → 12 failures across scoped-jsx-prop-identity and descriptor-classification;
    • mount path dropping the invocation site → 12+ failures in signal-instance-identity.
  • svg-dashboard/work.mjs passes on this head and its semantic controls pass on main, which exceeds both budgets.

Risk / follow-ups

  • Pathological descriptors. A forged $$kind: ELEMENT_TAG object whose type getter returns different values on successive reads now gets one read where it used to get several. Octane descriptors never do this.
  • Remaining reads. A tooltip commit still reads each layers child's type twice, once in deoptItemBody and once in its nested childSlot, and the native scoped resolver has no context-free fast path. Both are left out to keep the change small.
  • fix(octane): enumerate deferred JSX values with ordinary element keys #1659. It flipped the same accessor table's __octaneInvocationSite to non-enumerable, and it is now merged. This branch merges main, including fix(octane): enumerate deferred JSX values with ordinary element keys #1659, without conflicts, and signal-instance-identity passes on the merged head.

Provenance

  • An agent produced this diff (agent-authored)

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Note

Medium Risk
Touches core reconciliation (childSlot, de-opt lists, scoped resolvers); behavior is intended to be identical but mis-threading type/key reads could affect keys, mounts, or context-scoped classification.

Overview
Reduces repeated work when child slots classify deferred JSX passed as props (e.g. dashboard Viewport re-rendering with the same defs / layers values). Each accessor read used to re-resolve the scoped record; classification now reads type once and threads it through childSlot, prepareDeoptList, normalizePortalBody, and related paths. List keys go through ownListKey (one read per child); component key and __octaneInvocationSite are read only on mount for signal identity. createScopedResolver skips scope checks when the cached record never read context.

Adds svg-dashboard/work.mjs (jitless precise coverage) with tooltip_cycle_scoped_reads / pan_zoom_scoped_reads budgets, wires it into the benchmark runner, updates tooltip_swarm baseline notes and removes the performance waiver. New scoped-jsx-props-rerender tests lock DOM identity, keys, context, and portals across shell re-renders.

Reviewed by Cursor Bugbot for commit b04557f. Bugbot is set up for automated code reviews on this repo. Configure here.

A component that receives JSX values as props classifies them again on
every re-render, and each field read of a deferred value runs its accessor
and resolves its record. childSlot read the type up to seven times per
value and read the key and invocation site on update paths that never use
them; de-opt list keys read each child's key three times.

Read the type once in childSlot, deoptItemBody, descNeedsBlocks,
prepareDeoptList and normalizePortalBody, read each list child's key once
through ownListKey, and read a component descriptor's key and invocation
site only when a new instance mounts. A deferred record that read no
context now returns from its resolver without inspecting the scope.

svg-dashboard's ui commits drop from 1,408 to 404 accessor calls per 16
tooltip commits and from 680 to 184 per 8 pan_zoom commits, for the same
renderBlock/childSlot/deoptItemBody visits. A new untimed work pass
(svg-dashboard/work.mjs) counts them by jitless precise coverage with
tooltip/viewport and subtree-identity controls, guarded at ratio 1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent perf PR: performance work labels Oct 3, 2026
@trueadm
trueadm marked this pull request as ready for review October 3, 2026 10:55
trueadm and others added 3 commits October 3, 2026 11:55
…are fixed

A same-runner paired A/B (run 37117916097, two passes) measured
tooltip_swarm at 0.70x React with read-once classification, against
0.78x on main and the 0.8 ceiling.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

  • 🟡 js-framework: 1 timed operation(s) slower beyond ±3%
  • 🔴 bundle-size: 9 value(s) increased within budget
  • 🔴 bundle-reachability: 13 value(s) increased within budget

Compares 73feb8fc7, the merge commit's first parent with 9f9bcf6c2 on the same runner. A byte value over its committed budget or any increase in a js-framework work counter fails this check. Wall time is a report: base and head samples alternate in one browser, and an operation is called slower or faster only when the 95% confidence interval of its ratio excludes ±3%. Workflow run

js-framework: 1k/10k row operations

target operation base ms head ms head/base 95% CI
octane-tsrx select_lots 0.005 0.006 +7.3% +6.5% … +8.0% 🟡 slower
All 20 timed operations (19 without a verdict)
target operation base ms head ms head/base 95% CI
octane-tsrx run 2.667 2.617 −0.0% −3.6% … +3.4% ⚪ within noise
octane-tsrx replace 5.650 5.500 −4.4% −6.1% … −0.8% ⚪ within noise
octane-tsrx add 2.358 2.358 ±0.0% −4.0% … +4.3% ⚪ within noise
octane-tsrx update 0.120 0.119 −0.5% −1.5% … +0.3% ⚪ within noise
octane-tsrx select 0.005 0.005 +0.8% −0.5% … +1.5% ⚪ within noise
octane-tsrx swap 0.033 0.032 −0.9% −1.0% … +1.4% ⚪ within noise
octane-tsrx remove 0.016 0.016 ±0.0% −3.3% … +2.4% ⚪ within noise
octane-tsrx runlots 21.392 22.550 +5.4% +1.6% … +7.3% ⚪ within noise
octane-tsrx select_lots 0.005 0.006 +7.3% +6.5% … +8.0% 🟡 slower
octane-tsrx clear 40.900 40.125 +0.5% −1.5% … +2.3% ⚪ within noise
octane-jsx run 3.458 3.342 +0.0% −3.0% … +5.6% ⚪ within noise
octane-jsx replace 7.033 6.617 +1.7% −1.8% … +8.7% ⚪ within noise
octane-jsx add 3.150 3.133 ±0.0% −3.0% … +1.3% ⚪ within noise
octane-jsx update 0.234 0.232 −1.1% −2.2% … +0.4% ⚪ within noise
octane-jsx select 0.122 0.122 +0.9% −0.6% … +2.4% ⚪ within noise
octane-jsx swap 0.205 0.207 +1.1% +0.3% … +1.7% ⚪ within noise
octane-jsx remove 0.164 0.165 +0.6% −0.6% … +2.8% ⚪ within noise
octane-jsx runlots 27.267 27.717 +0.4% −2.0% … +2.2% ⚪ within noise
octane-jsx select_lots 1.292 1.329 +1.3% +1.2% … +2.5% ⚪ within noise
octane-jsx clear 41.800 41.400 −3.1% −3.8% … −1.5% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

target metric base head Δ
octane-tsrx bindings_js_raw 718,907 718,899 −8 (−0.0%) 🟢
octane-tsrx bindings_js_gzip 240,431 240,484 +53 (+0.0%) 🔴
octane-tsrx bindings_js_brotli 204,622 204,749 +127 (+0.1%) 🔴
octane-tsrx bindings_app_gzip 121,727 121,716 −11 (−0.0%) 🟢
octane-tsrx bindings_app_brotli 101,633 101,774 +141 (+0.1%) 🔴
octane-tsrx bindings_fw_raw 362,986 362,978 −8 (−0.0%) 🟢
octane-tsrx bindings_fw_gzip 118,704 118,768 +64 (+0.1%) 🔴
octane-tsrx bindings_fw_brotli 102,989 102,975 −14 (−0.0%) 🟢
octane-jsx js_raw 227,161 227,147 −14 (−0.0%) 🟢
octane-jsx js_gzip 72,489 72,505 +16 (+0.0%) 🔴
octane-jsx js_brotli 62,815 62,874 +59 (+0.1%) 🔴
octane-jsx app_brotli 2,505 2,507 +2 (+0.1%) 🔴
octane-jsx fw_raw 218,702 218,688 −14 (−0.0%) 🟢
octane-jsx fw_gzip 69,553 69,569 +16 (+0.0%) 🔴
octane-jsx fw_brotli 60,310 60,367 +57 (+0.1%) 🔴

39 other measured values are unchanged.

Public-import reachability bundles (bytes)

target metric base head Δ
root-static raw 203,400 203,367 −33 (−0.0%) 🟢
root-static gzip 64,672 64,733 +61 (+0.1%) 🔴
root-static brotli 56,119 56,184 +65 (+0.1%) 🔴
binding-base-ui-vite raw 213,631 213,628 −3 (−0.0%) 🟢
binding-base-ui-vite gzip 68,279 68,310 +31 (+0.0%) 🔴
binding-base-ui-vite brotli 59,204 59,228 +24 (+0.0%) 🔴
binding-base-ui-esbuild raw 211,576 211,572 −4 (−0.0%) 🟢
binding-base-ui-esbuild gzip 68,210 68,257 +47 (+0.1%) 🔴
binding-base-ui-esbuild brotli 59,184 59,295 +111 (+0.2%) 🔴
binding-aria-esbuild gzip 3,331 3,329 −2 (−0.1%) 🟢
binding-radix-vite raw 215,563 215,546 −17 (−0.0%) 🟢
binding-radix-vite gzip 68,807 68,855 +48 (+0.1%) 🔴
binding-radix-vite brotli 59,687 59,765 +78 (+0.1%) 🔴
binding-radix-esbuild raw 213,467 213,450 −17 (−0.0%) 🟢
binding-radix-esbuild gzip 68,797 68,829 +32 (+0.0%) 🔴
binding-radix-esbuild brotli 59,778 59,776 −2 (−0.0%) 🟢
binding-apollo-client-vite raw 358,623 358,592 −31 (−0.0%) 🟢
binding-apollo-client-vite gzip 112,365 112,396 +31 (+0.0%) 🔴
binding-apollo-client-vite brotli 98,044 98,087 +43 (+0.0%) 🔴
binding-apollo-client-esbuild raw 361,560 361,525 −35 (−0.0%) 🟢
binding-apollo-client-esbuild gzip 114,544 114,578 +34 (+0.0%) 🔴
binding-apollo-client-esbuild brotli 99,791 99,866 +75 (+0.1%) 🔴

83 other measured values are unchanged.

trueadm and others added 3 commits October 3, 2026 12:12
…he index

The PR bench now fails on any added jitless production call. The
deoptKey and deoptKeyPositional wrappers had added an ownListKey call per
list key; their two remaining callers now call ownListKey themselves, so a
key costs one call and one field read as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Precise coverage omits a function that ran zero times, so requiring every
control in coverage fails once surviving de-opt items skip deoptItemBody
(#1664). Check each metric's name in the production bundle source, and
require coverage hits only for the functions every ui commit calls.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@blacksmith-sh

This comment has been minimized.

Its optional pre-read type and local stopped esbuild from folding its
element branch into one conditional chain, which cost every js-framework,
TodoMVC, chat and weather framework chunk 21-26 raw bytes. The read-once
callers no longer need it: a host value in childSlot needs Blocks exactly
when its children do once Usable unwrapping has run, and deoptItemBody
answers a component item from its type. Those four framework chunks are
now byte-identical to main, and svg-dashboard's accessor counts stay at
404/184.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@trueadm

trueadm commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator Author

Failing checks on a1c4a03

benchmark report (budgets). main is already over the committed byte budgets, so every PR fails this gate until #1638 resets them.

  • On the base ac729dc148, for example, todo_fw_raw is 135,618 against a budget of 134,272, and octane-jsx fw_raw is 218,605 against 216,064.
  • This PR's own growth on those apps came from descNeedsBlocks. With an added parameter and local, esbuild could no longer fold its element branch into one conditional chain, which cost 21–26 raw bytes.
  • 79c9d29 restores descNeedsBlocks byte-for-byte. The js-framework, TodoMVC, chat and weather framework chunks are now byte-identical to main on raw, gzip and brotli, measured with the suite's own Vite configuration.
  • All 64 js-framework work counters were unchanged on a1c4a03.

bundle-reachability. In scenarios that include the full child-slot code, raw size is flat or smaller:

scenario raw gzip brotli
root-static −33 +43 +43
binding-base-ui-vite +7 +59 +105
binding-radix-vite −17 +49 +148
binding-apollo-client-vite −31 +48 +29
cli-spa-starter 0 0 0

The compression changes come from minified identifier renaming, not added code. A token diff of root-static from run-minimal.mjs against both runtimes shows top-level names reassigned from the first statements onward (na→Zc, ta→ea, …; 10,047 changed tokens), because the set of top-level functions changed (deoptKey and deoptKeyPositional folded into ownListKey).

example apps (3/3). main fails it too: signal-chat's islands-only JavaScript budget measured 71,762 B at ac729dc148 against a 71,680 B limit. This PR adds 4 B. It is tracked separately.

heavy integration (browser). One react-parity tooling test failed: vitest-browser-collection.test.ts, "browser collection releases a file mock before collecting an unmocked consumer". It passed on main's run of the same base, and nothing in this diff touches Vitest browser mocking. The new head reruns it.

@vercel

vercel Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated
octane-website Skipped Skipped Oct 3, 2026 1:26pm UTC
octane-website-mcp Skipped Skipped Oct 3, 2026 1:26pm UTC

Request Review

@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp October 3, 2026 13:26 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website October 3, 2026 13:26 Inactive
trueadm added a commit that referenced this pull request Oct 3, 2026
Main gained #1685, which raised 51 budgets for the useLayoutSnapshot
commit-phase priority fix (#1686), and #1681/#1665. Re-measured on main
425a32a: each of #1663, #1664 and #1666 merged alone, and all three
plus #1686 merged together. Each budget is the larger of main's value and
the largest measured value plus 32 (raw/gzip) or 256 (brotli), so the
three perf PRs and #1686 can land in any order.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm and others added 2 commits October 3, 2026 20:39
With the context-free fast path, a cached resolution reaches the replay
branch only when it read context, so the guard never fails. Saves 10 raw
bytes in the bindings framework chunk.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm added a commit that referenced this pull request Oct 3, 2026
…nd warm-plan perf PRs (#1687)

Three open runtime perf pull requests fail the PR bench byte gate on main
12c32ec, and landing any two of them stacks past the 32-byte headroom:

- #1664 (de-opt survivor fast path): +809 raw / +290 gzip
  in the bindings app framework chunk, which #1676 did not raise because
  #1639 added that budget key first; +20 raw in every compiled-only app.
- #1666 (warm-plan length guard): +17 raw in every client
  bundle, two `!==` guards.
- #1663 (scoped-value read-once): +2 raw / +30-70 gzip in
  descriptor-renderer bundles, a compression shift from the restructured
  childSlot reads.

Main had already spent part of the headroom: bindings framework gzip
measured exactly its budget and deferred-hydration raw had 8 bytes left.

Each budget is set to the largest value measured across each PR merged
alone with main and all of them merged together (plus #1665, which moves
none of these values), plus 32 for raw and gzip and 256 for brotli. Only
values one of those trees exceeds change.

Co-authored-by: Claude Opus 5.5 <[email protected]>
@trueadm
trueadm merged commit 16d6090 into main Oct 3, 2026
30 checks passed
@trueadm
trueadm deleted the perf/scoped-value-repeat-reads branch October 3, 2026 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent perf PR: performance work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant