Repository navigation
perf(octane): update a same-component de-opt list item without entering its render - #1664
Merged
Merged
Conversation
…ak maps #1069 made every module that can receive a signal handle record each native handler's signal authority: the element's owner in one weak map and an "escaped" mark for the scope in another. Keyed rows paid two weak-map insertions per mounted row even with no signals in use. A same-runner paired A/B put prepend100/append100/insertmid100 at 0.48 -> 0.76 ms across #1069. The element's authority now lives in a $$signalOwner property beside its handler slots, journaled and rolled back like before, and the escape mark is a signalTokenEscaped field on Scope/Block with the same retirement truth table. Mounting no longer touches a weak map. bindSignalText also writes a scalar over the Text it already owns directly, skipping bindDirectSignal's policy dispatch; setText still journals the text and the binding bag. That path runs for every compiled text-hole update in such a module (memo-wall context refresh: 0.669 -> 0.622 ms paired). The signal-dom-bindings suite gains a deterministic guard counting weak-map insertions per mounted and inserted handler row (2 on main, 0 now), with dispatch and survivor-identity controls. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…cord #833 made root renders undoable and journaled every keyed survivor's previous itemIndex in updateSurvivor: four journal slots per row on each reorder, removal, or insertion that shifts positions. A same-runner paired A/B put a 1,000-row rotate at 0.050 ms before #833 and 0.071 ms on main. An index moves only when the list's membership or order does, which records the list's shape (journalForSlot) anyway. reconcileKeyed now takes that record before the first survivor index write, and restoreForSlot restores each row's itemIndex from its chain position; a row whose index already differed is kept exactly. The hydration adoption branch, which restores a DOM range instead of a chain, still journals indices per row. Transition journals, which never restored itemIndex, now restore it too. The shape record also builds the key order with one spread and an early-exit comparison instead of an iterator loop that copied the order element by element. The root-transactions suite gains reorders.mjs, which counts root-journal slots per row for rotate/reverse/remove-first/insert-first (4 on main, 0 now). A held-root test pins that index-reading rows render their positions after a held reorder retries; it fails when the index restore is removed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The stable-event-authority work observer counted authority writes through WeakMap.prototype.set. Authority now lives in each host's $$signalOwner property, so the observer counts writes through an Element.prototype accessor instead. The expected counts are unchanged (400 mount, 0 retained, 0 changed capture), and dropping the runtime's unchanged-authority skip still fails the retained-write assertion. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The bench report on this PR measured +250 raw / +90 gzip bytes in every bundle with a keyed list. journalForSlot now returns false, so the call sites clear their pending flag without a helper. Rollback restores each row's index from its chain position without a side map, since every reconcile leaves a row's index equal to its position and the record is taken before the first survivor index write. The hydration-adoption branch does not restore a chain at all (its rows are fresh), so it no longer journals indices per row either. js-framework octane-tsrx bundle against main: +51 raw / +10 gzip (was +251 / +51). The held-root index test still fails when the restore is removed; the reorder guard still reads 0 slots per row. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The hydration-adoption branch of journalForSlot restores a DOM range, not a chain, so the trim that dropped its per-row index entries left an existing row's itemIndex on the aborted position after a hydrating render reordered the list and rolled back. Journal each existing row's index there again, before reconcileKeyed moves any of them. Bundle cost against main is now +130 raw / +31 gzip for js-framework octane-tsrx. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… into perf/memo-wall-survivor-rows
…rf/memo-wall-survivor-rows
…ng its render A value-position list rebuilt by createElement (memo-wall wall B, every @octanejs binding) hands back a fresh descriptor per row. Each surviving row entered its item render (renderBlock, deoptItemBody, a nested childSlot) only to reach the memo bail of the component already mounted there, and the root journal recorded the item's inputs and render for every row. updateSurvivor now hands a plain de-opt item to updateDeoptComponent, which takes that nested childSlot's same-component branch directly, in the item's scope and with the priority its render would inherit: the memo bail, the identical-props bail, or a journaled props update and render of the existing component Block. A bail leaves the item's committed descriptor in place. Hydration, signal owners, native reads, non-root captures, unsettled items and every other child regime keep the ordinary item render. The function reaches updateSurvivor through ForSlot.itemUpdate, stamped in renderPreparedChildList, so compiled @for bundles never retain the descriptor renderer. Per bailed row (new memo-wall survivor-work guard, jitless precise calls): 48 calls and 8 root-journal slots before, 26 and 0 now. One __oneChangeB on the memo-wall production build: 46,138 calls before, 24,138 now. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tem twin Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
October 3, 2026 11:06
Contributor
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)
10 other measured values are unchanged. Public-import reachability bundles (bytes)
81 other measured values are unchanged. |
trueadm
added a commit
that referenced
this pull request
Oct 3, 2026
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]>
…lready implies An item whose nested slot holds a component Block never has recorded $$ctxReads (it is neither memo nor armed) and never also holds a portal. Its end marker and a former body-function flag do not change the same-component branch it mirrors. A non-object item fails the kind check without the separate null and typeof tests. -100 raw / -17 gzip in bundles that include the descriptor renderer. Co-Authored-By: Claude Opus 5.5 <[email protected]>
#1646 waived memo-wall one_change_B (octane-tsrx/react, maxRatio 1.4) until the per-row survivor work was fixed. With same-component de-opt survivors taking the memo bail directly, paired ~20 ms samples measured 0.80x, 0.80x and 0.82x across two same-runner runs (the previous code: 1.30-1.41x; #639: 0.97x). 1.1 keeps about 35% headroom while catching a return of the per-row item render. Co-Authored-By: Claude Opus 5.5 <[email protected]>
2 of 5 tasks
The plain de-opt flag now holds the list's survivor update itself (updateDeoptComponent, or null), so ForSlot needs no second field and the compiled @for path that shares updateSurvivor pays only one optional call. updateDeoptComponent writes the survivor's index. The js-framework rows app (compiled lists only) now grows +20 raw / +11 gzip over main, within the committed +32 budget, instead of +74 / +29. Co-Authored-By: Claude Opus 5.5 <[email protected]>
2 of 3 tasks
trueadm
added a commit
that referenced
this pull request
Oct 3, 2026
#1664 lets a surviving value-position list row whose descriptor names the same component take the memo bail without entering its item render. memo-wall one_change_B goes from 1.30-1.41x to 0.80x React Compiler (paired, same runner). Per bailed row it drops from 48 to 26 production calls and from 8 root-journal slots to 0. The fast path itself (updateDeoptComponent) is code that bundles which already contain the descriptor renderer now carry: about +800 raw / +210-290 gzip. Compiled-only applications pay +20 raw / about +10 gzip for the shared call, which fits their budgets except weather's total gzip, whose headroom had fallen to 7 bytes. Each budget below is set to #1664's measured bytes (PR bench run 37140101926, on its merge commit with main d826c3e) plus 32 for raw and gzip and plus 256 for brotli, as #1638 set them. Only values #1664 exceeds change. Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Merged
5 of 6 tasks
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
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
added a commit
that referenced
this pull request
Oct 3, 2026
…ion (#1663) * perf(octane): read a deferred JSX value's fields once per classification 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]> * ci(bench): drop the tooltip_swarm waiver now that its accessor reads 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]> * perf(octane): call ownListKey directly where list keys fall back to the 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]> * fix(benchmarks): check svg-dashboard work metrics by name in the bundle 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]> * perf(octane): keep descNeedsBlocks byte-identical to main 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]> * perf(octane): drop the resolver's dead null-reads guard on a cache hit 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]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Surviving rows of a value-position list no longer run their own item render just to reach their component's memo bail. This is the per-row survivor cost behind the memo-wall
one_change_Bratio guard.Builds on #1655 and #1656 (both merged), which removed the other two attributed costs of this op: per-row event-owner maps and the keyed survivor index journal.
createElementbuilds (memo-wall wall B, and every@octanejs/*binding) hands back a fresh descriptor for every row on every render. Each surviving row went throughupdateSurvivor→renderBlock→deoptItemBody→ a nestedchildSlot. That nested slot then re-classified the descriptor, only to land on the memo bail of the component already mounted there. Every row paid the full item render: the render-phase update loop, the signal-owner checks, warm-plan and effect-event bookkeeping, and two root-journal entries (JOURNAL_INPUTSandJOURNAL_RENDER, 8 slots).updateDeoptComponenttakes that nestedchildSlot's same-component branch directly from the survivor visit. Depending on the props, that branch does one of three things: the memo bail, the identical-props implicit bail, or a journaled props update and render of the existing component Block. It runs in the item's scope (scoped descriptors resolve there, as before) and gives the item the render priority its own render would inherit. A bail leaves the item's committed descriptor in place; its props are the ones the bailed component kept.updateSurvivoris shared with compiled@forlists. NamingdeoptItemBodythere would pull the whole descriptor renderer into every compiled app (the fix: stop the compiled @for path retaining the descriptor renderer #767 hazard). So the function reaches it as data,ForSlot.itemUpdate, stamped inrenderPreparedChildListbesideplainDeopt, inside the graph that already retains it.ForSlot.plainDeoptfield (now the update function or null), so the compiled path pays one optional call and no new field. The first version cost +74 / +21–32. Bundles that already contain the descriptor renderer (octane-jsx, root-static, the binding scenarios) grow by about +860 raw / +250 gzip: the fast path itself, after dropping checks the component Block already implies (−100 raw / −17 gzip). ReusingupdateSurvivor's existinglitebranch would cost compiled apps nothing, but it journals and writes the item's inputs before its body runs, which puts back 4 journal slots and 2 calls per bailed row.Why
Deterministic counts (jitless precise calls, the same build inputs):
__oneChangeB, memo-wall production build (unminified for coverage)renderBlockcalls in that opsurvivor-workguard: callssurvivor-workguard: root-journal slotsThe memo-wall
work.mjsexact gates for wall B are unchanged: 1,000 survivor visits, 1,000 descriptors, 1,001 memo compares and 1/1/1 bodies forone_change_B. Its one failure,one_change_A.updateSurvivor 1 !== 1000, fails identically on the base build; that gate is stale and outside CI.Timing: same-runner paired A/B (Bench workflow on a scratch branch with #1646's paired harness, 15 rounds, every build served at once), ms per change. The second run serves each octane build twice to measure same-build spread.
one_change_Bagainst React (guard 1.4): this head 0.80 / 0.80 / 0.82, the base stack 1.41 / 1.33 / 1.30, main 1.30, #639 0.97. The other memo-wall ops do not reach the new code. In the second run they match the stack within same-build spread (ctx_through_wall_B0.554 on both heads and 0.556 / 0.554 on both stacks). The first run's 0.615 vs 0.574 for that op was noise.Changes
packages/octane/src/runtime.ts:updateDeoptComponent,ForSlot.itemUpdate(declared in both ForSlot literals), the stamp inrenderPreparedChildList, and one optional call inupdateSurvivor.benchmarks/memo-wall/survivor-work.mjs(new, registered inbench.mjs): wall B's shape in happy-dom (a compiled memo row, a plain-JScreateElementhelper, a{rows}hole) at 128 and 256 rows with one changed row. It reports root-journal slots and jitless production-bundle calls per bailed row, with render-probe, host-identity and changed-text controls. Pass a runtime path to A/B another revision.benchmarks/baselines/ratios.json:bailed_row_journal_slots(budget 0) andbailed_row_calls(budget 26) againstsurvivor-work-budget. memo-wallone_change_Bdrops its waiver and tightens from 1.4 to 1.1.packages/octane/tests/memo-value-position.test.ts: four behavioral cases for memo rows in a value-position keyed list (six tests). Each passes on the base runtime and with the fast path disabled; the mutation each one catches is listed below.Validation
shallowEqualProps(no context handling): fails four, including both context-refresh cases.useDeferredValueskipped the urgent deferral).CURRENT_BLOCKon the list owner only differs when scoped descriptors replay context reads under a memo ancestor. Dropping the miss path's journal entries is covered by the rollback's own invalidation of the re-rendered component. Both are kept for parity with the nestedchildSlot.memo-value-position.test.ts(--project octane), 6 passedpnpm typecheck:fileson the changed runtime and test;pnpm format:files:checkon every changed file;pnpm sync(no generated changes)node benchmarks/memo-wall/survivor-work.mjs(26 / 0); with the base runtime: 48 / 8pnpm test,pnpm typecheck,pnpm format:check: left to CI (many parallel local sessions)example apps (3/3)/examples: signal-chatislands-budget.spec.tsfailed on main itself (71,762 B gzip against 71,680). It is fixed on main by 9985bee, which raises that e2e ceiling to 71 KiB, and this branch now includes it. This PR adds 1 B to that page.benchmark report: every budget breach it lists is already over budget on the base commit (for exampletodo_fw_raw135,618 vs 134,272,octane-jsx fw_raw218,605 vs 216,064). Bundles under budget on base (rows, weather, cli-spa-starter) stay under it. It stays red until ci(bench): re-set every byte budget to measured + 32 bytes #1638 resets main's budgets. All 64 js-framework work counters are unchanged.Risk / follow-ups
childSlot's same-component branch, and its preconditions are spelled out field by field. A future change to that branch has to keepupdateDeoptComponentin step. Both carry comments pointing at each other's contract.copyElementConfigand its helpers), keying (appendScopedDeoptKey), the memo compare, andrestampCtxDeps's ancestor walk, which readsbody.__memoon every ancestor. Exiting that walk onmemoInChainwould also needmemoInChainkept true for blocks armed after their descendants exist; that is a separate change.bindingsapp key ci: enforce every byte budget on pull requests and keep raises out of feature changes #1639 added and the headroom for landing alongside perf(octane): read a deferred JSX value's fields once per classification #1663 and perf(octane): skip the warm-plan stack restore when a render registered no plan #1666. Land ci(bench): raise byte budgets for the scoped-read, de-opt survivor, and warm-plan perf PRs #1687 before this PR. Until thenbenchmark reportand the "Verify every bundle budget" test stay red on exactly those values. All 64 js-framework work counters are unchanged.one_change_Bwaiver and tightens the guard from 1.4 to 1.1. Paired runs read 0.80–0.82x; the previous code read 1.30–1.41x. Thectx_through_wall_Bwaiver (also from fix(benchmarks): pair the timing samples behind waived ratio guards and re-judge them #1646, waiting on perf(octane): record event signal authority on the host instead of weak maps #1655 and perf(octane): restore keyed survivor indices from the list's shape record #1656, both merged) belongs to that work, not this PR. This PR's runs read that op at 0.67x and 0.83x against its 0.85 guard.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 list reconciliation and memo/context journaling in
runtime.ts; behavior is gated by many preconditions but mistakes could affect hydration, transitions, or memo correctness.Overview
Surviving rows in value-position keyed lists (fresh
createElementdescriptors per row, memo-wall wall B) no longer enter each item’s full render just to hitReact.memoon the nested component.updateDeoptComponentruns fromupdateSurvivorfor plain de-opt lists: same-component survivors get memo bail, identical-props bail, or an in-place props update + component render; everything else (hydration, signals, child-type changes, etc.) still uses the ordinary item render.ForSlot.plainDeoptis now a nullable callback (stamped asupdateDeoptComponent) instead of a boolean, keeping the descriptor renderer off compiled-only@forpaths.Benchmarks & CI: new
survivor-work.mjsgates per-bailed-row root-journal slots (budget 0) and production calls (budget 26); memo-wallone_change_Bvs React tightens to 1.1 and drops its performance waiver.Tests:
memo-value-position.test.tsadds coverage for one-row updates, custom comparators, context/useDeferredValuerefresh under bailed rows, and suspended sibling commits.Reviewed by Cursor Bugbot for commit 68fc0d3. Bugbot is set up for automated code reviews on this repo. Configure here.