Repository navigation
perf(octane): read a deferred JSX value's fields once per classification - #1663
Conversation
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]>
…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]>
Benchmark report
Compares js-framework: 1k/10k row operations
All 20 timed operations (19 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)
39 other measured values are unchanged. Public-import reachability bundles (bytes)
83 other measured values are unchanged. |
…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]>
This comment has been minimized.
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]>
Failing checks on a1c4a03benchmark report (budgets).
bundle-reachability. In scenarios that include the full child-slot code, raw size is flat or smaller:
The compression changes come from minified identifier renaming, not added code. A token diff of example apps (3/3). heavy integration (browser). One react-parity tooling test failed: |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
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]>
…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]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
svg-dashboard's
tooltip_swarmwent 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 samedefsvalue and the four children of thelayersFragment again. Every field read of a deferred value runs an accessor that calls its resolver. Before this change, a commit paid 88 accessor calls:childSlotread the type up to seven times per value.childSlotread 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.This PR reads each field once per classification and skips the reads an update path never needs:
childSlotreads 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__octaneInvocationSiteare read only on the mount path that builds the signal instance key;componentSlotalready stamps only new or replacement instances.deoptItemBody,prepareDeoptListandnormalizePortalBodyreuse one type read.deoptItemBodytreats a component item as needing Blocks directly.childSlot's pure-host check asksdescNeedsBlocksabout a host's children, which is equivalent once Usable unwrapping has run.ownListKeyreads a list child's key once and servesdeoptKey,deoptKeyPositionalandflattenReactChildContainer.appendScopedDeoptKeynow takes that key instead of re-readingitem.key. The missing-key warning keeps its conditions, now behind a leadingNODE_ENVcheck so production drops it.createScopedResolverreturns a resolved record that read no context without computing scope identity. Only a context-reading record ever comparesresolvedScope, 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.mjsThe new untimed
workpass rebuilds the octane fixture unminified and counts named production calls under jitless Chromium precise coverage, the same method asrecursive-context/work.mjs.renderBlock/childSlot/deoptItemBody(both)tooltip_swarmpan_zoomdefs, topology, charts, sparks, icons) loses DOM identity.tooltip_cycle_scoped_readsandpan_zoom_scoped_readsat 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, reusesbenchmarks/ab-scratch.shfromscratch/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.tooltip_swarmpan_zoomtooltip_swarm1.857 → 1.762 and 1.829 → 1.762;pan_zoom2.125 → 1.656 and 2.138 → 1.700.topology_churnat +5.8% in pass 2, but −1.4% in pass 1, with identical minimums.tooltip_swarmrecovers about half of its regression: about 1.8 ms against roughly 1.6–1.7 ms at feat(benchmarks): add the svg-dashboard SVG stress suite #635/fix: retain suspended roots without a boundary #833. The rest is outside the accessor reads this PR targets.tooltip_swarmis back under its 0.8× React ceiling with about 12% margin, so this PR also removes the waiver fix(benchmarks): pair the timing samples behind waived ratio guards and re-judge them #1646 added, which named this fix. The guard is enforced again.Bytes
mainon raw, gzip and brotli.descNeedsBlocksis unchanged because the read-once callers no longer need a pre-read type.Validation
pnpm format:check: not run repo-wide.pnpm format:files:checkpasses on every changed file.pnpm typecheck: not run repo-wide.pnpm typecheck:filesis clean onruntime.ts, the new test, and its fixture.pnpm test: left to CI.octaneproject, 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 inoctane-prod.scoped-jsx-props-rerender.test.tsfollows 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:scoped-jsx-prop-identityanddescriptor-classification;signal-instance-identity.svg-dashboard/work.mjspasses on this head and its semantic controls pass on main, which exceeds both budgets.Risk / follow-ups
$$kind: ELEMENT_TAGobject whosetypegetter returns different values on successive reads now gets one read where it used to get several. Octane descriptors never do this.layerschild's type twice, once indeoptItemBodyand once in its nestedchildSlot, and the native scoped resolver has no context-free fast path. Both are left out to keep the change small.__octaneInvocationSiteto 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, andsignal-instance-identitypasses on the merged head.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith 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
Viewportre-rendering with the samedefs/layersvalues). Each accessor read used to re-resolve the scoped record; classification now reads type once and threads it throughchildSlot,prepareDeoptList,normalizePortalBody, and related paths. List keys go throughownListKey(one read per child); component key and__octaneInvocationSiteare read only on mount for signal identity.createScopedResolverskips scope checks when the cached record never read context.Adds
svg-dashboard/work.mjs(jitless precise coverage) withtooltip_cycle_scoped_reads/pan_zoom_scoped_readsbudgets, wires it into the benchmark runner, updatestooltip_swarmbaseline notes and removes the performance waiver. Newscoped-jsx-props-rerendertests 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.