Repository navigation
perf(octane): restore keyed survivor indices from the list's shape record - #1656
Merged
Merged
Conversation
…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]>
trueadm
marked this pull request as ready for review
October 3, 2026 09:44
Contributor
Benchmark report
Compares js-framework: 1k/10k row operations (ms, lower is better)All 20 timed operations (20 within noise)
Application bundle size (bytes)
9 other measured values are unchanged. Public-import reachability bundles (bytes)
60 other measured values are unchanged. |
This was referenced Oct 3, 2026
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]>
trueadm
added a commit
that referenced
this pull request
Oct 3, 2026
…ed fixes rotateb and ctx_through_wall_B clear with #1655 and #1656; one_change_B's per-row remainder and tooltip_swarm's scoped-descriptor accessor reads each have their own fix task. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Hydration rollback drops row indices
- Added itemIndex snapshot/restore in the hydration-adoption branch of journalForSlot so rollback restores row indices that updateSurvivor overwrites without a per-row journal, avoiding stale indices that cause pure retries to skip rendering.
Or push these changes by commenting:
@cursor push 2da71e9a19
Preview (2da71e9a19)
diff --git a/packages/octane/src/runtime.ts b/packages/octane/src/runtime.ts
--- a/packages/octane/src/runtime.ts
+++ b/packages/octane/src/runtime.ts
@@ -4752,8 +4752,13 @@
// The initial chain is empty even though its DOM is already owned: server
// nodes or raw hosts being upgraded to Blocks. A failed adoption discards
// fresh scopes, not those hosts, while restoring the original range.
+ // A re-render on a chain the initial fill already populated may overwrite
+ // row indices in updateSurvivor; snapshot them so rollback can restore.
+ let rows: Block[] | null = null;
+ for (let b: Block | null = state.head; b !== null; b = b.nextSibling) (rows ??= []).push(b);
journalUndo(() => {
seen.delete(state);
+ if (rows !== null) for (let i = 0; i < rows.length; i++) rows[i].itemIndex = i;
});
journalRootRange(domNode(state.start).parentNode!, state.start, state.end);
return false;You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit d1080a4. Configure here.
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]>
trueadm
added a commit
that referenced
this pull request
Oct 3, 2026
…nd re-judge them (#1646) * ci(bench): triage the weekly ratio-guard breaches so new ones show The weekly Bench job (`bench.mjs --quick --ratios`) was red with 81 ratio breaches, 4 suites that wrote no numbers and 4 harness gate failures, so a new breach was invisible. Every item is now a fix or a rebaseline. - Harness drift, fixed. Each harness had stopped producing numbers when runtime source it anchors on changed: - ssr-final-replay: a second suspended loop since 2026-09-29. - root-transactions/contracts: staged-DOM text and attribute journaling since 2026-09-15. - signal-dom-bindings: a second native style Block allocation site since 2026-09-23. - codegen-size: the server runtime's lazy streamed-signals chunk since 2026-09-16. - recursive-context: counted a pure-call annotation and trailing newlines as output growth. - Rebaselined, with numbers in each note: five cross-framework bundle-size ratios and the workerd script-size ratio. The absolute app and server-render budgets are now the ratchet. Lynx's no-worklet byte caps from 2026-08-17 are reset to measured + 32, with the background program pinned exactly. - Fix pending, with dated waivers that expire 2026-10-24, each with an owner task: - three exact counters the revived harnesses exposed (one extra closure per ssrTry, 128 live text reads per 128 unchanged compiled updates, compiled output at 1.295x its source); - Lynx create ratios and the re-entrant transport gate; - superlinear hydrate boundary preparation; - Octane Three versus R3F size and frame dispatch; - two timing regressions near the timer floor; - ten quick-mode timing guards whose samples are noise-bound; - the scoped descriptor shape change. - bench.mjs supports a guard `waiver` ({ reason, expires }). A waived breach prints and does not fail, and fails again once the date passes. HARNESS_FAILURE_ALLOWLIST now also covers a suite whose harness writes no numbers. The budget breaches (57) clear when the budget reset lands. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(benchmarks): pair and lengthen the timing samples behind waived ratio guards Twelve timing guards breached in weekly quick runs without a verdict. Their samples sat near Chromium's 100 µs clock or under two-sample noise, and each target ran its whole block minutes after the other side of its guard. - benchmarks/lib/paired.mjs: rotating per-round visit order and a ~20 ms sample calibration shared by the harnesses below. - js-framework-reorder, memo-wall, svg-dashboard, spa-navigation: every target's page stays open in one browser and each sample round visits all targets; short ops repeat until a sample takes about 20 ms (clicks, hook invocations, op batches, and summed navigation legs). - activity caught-reveal: a sample reveals several independent hidden roots in one window, with the small case revealing eight times as many roots so both cases do equal work; the cases alternate per round. - ssr-workerd: an untimed priming spawn per target, then paired cold-spawn rounds; quick mode runs six rounds instead of two. - bench.yml: a `suites` dispatch input to run selected suites. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(benchmarks): collect garbage before every timed spa-navigation leg The untimed return leg mounts a whole route, and its collection landed inside the next timed teardown: nav_teardown samples ran at 17-45% rme. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(benchmarks): re-judge the twelve waived timing guards with paired samples Two quick CI runs of the paired, ~20 ms harness and same-runner A/B runs against the commits that set each guard decided every waiver: - Passing, waiver removed: activity reports, ssr-workerd cold_spawn_to_first_byte, svg-dashboard pan_zoom, memo-wall parent_rerender_equal_A and octane-jsx mount, spa-navigation nav_teardown and nav_mount (no Octane change since #674 on one runner). - Rebaselined: svg-dashboard icon_swap 1.2 -> 1.6, because #983's esbuild minification made React 15% faster while Octane stayed flat. - Confirmed Octane regressions, waiver kept and pointed at the fix: js-framework-reorder rotateb (1.41x per click since #639), memo-wall one_change_B (1.5x) and ctx_through_wall_B (1.44x), and svg-dashboard tooltip_swarm (1.31x since #635). - The rotateb note claimed React moves every survivor; it moves one. A new rotatef guard covers the LIS-vs-lastPlacedIndex differentiator (0.043x). Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(benchmarks): rebaseline spa-navigation nav_mount to its CI baseline The 1.2 ceiling came from a local 0.94x reading. On CI runners #674 itself measures 1.15x and head 1.09-1.16x, so the ceiling left 3% of quick-mode headroom; 1.35 keeps a margin while still catching per-node mount growth. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ci(bench): drop the three weekly waivers that now have fix PRs The waived guards now have owner PRs: ssr-final-replay try_closures (#1644), root-transactions equal_reads (#1643) and codegen-size gzip compiled/source (#1645). #1645 rebaselines the same codegen-size entry, so this branch no longer edits it. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ci(bench): leave lynx-render to its owner fix The lynx-render transport gate failure and the create_1k/create_10k ratio breaches both trace to #885's JSON-encoded transport and now have an owner fix. Its branch re-notes those two guards, so this branch drops their waivers and the suite's allowlist entry instead of editing the same entries. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ci(bench): keep harness failures unwaivable and leave descriptor shapes to their owner Waiving a suite that throws before it writes numbers would hide any crash in that suite, not only the known shape change, and skip all of its guards. The scoped-descriptor-shapes defect has an owner fix in progress. That fix re-pins the harness's expected keys, so narrowing the waiver here would edit the same assertion. HARNESS_FAILURE_ALLOWLIST is empty again, and a thrown suite failure always fails the job. Dated waivers remain only on individual ratio guards. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ci(bench): leave the Three guards to their owner fixes three-renderer frame_1k_subscribers and the two three-bundle-size ratios have owner PRs (#1651, #1652) that re-note and ratchet those entries, so this branch drops their waivers instead of editing the same entries. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(benchmarks): point the four kept timing waivers at their attributed fixes rotateb and ctx_through_wall_B clear with #1655 and #1656; one_change_B's per-row remainder and tooltip_swarm's scoped-descriptor accessor reads each have their own fix task. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(benchmarks): point parent_rerender_equal_A's note at its per-commit journal fix Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This was referenced Oct 3, 2026
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
Keyed reorders no longer journal every surviving row during an undoable root render. This removes about half of #833's keyed-reorder regression (js-framework-reorder rotate/displace/remove).
updateSurvivorjournaled each survivor's previousitemIndex: oneJOURNAL_PROPentry, four slots per row, on every reorder, removal or insertion that shifts positions. An index moves only when the list's membership or order does, and that already records the list's shape (journalForSlot).reconcileKeyednow takes that record before the first survivor index write.restoreForSlotrestores each row'sitemIndexfrom its chain position, since every reconcile leaves a row's index equal to its position.journalForSlotrestores a DOM range, not a chain, so it still journals each existing row's index, before any of them moves. Transition journals never restoreditemIndex(the per-row entry was root-only); they now restore it with the chain.items.values()and an early-exit comparison, replacing an iterator loop that copied it element by element. The result is the same:nullwhen the key order equals the chain order, otherwise the full key order.Why
Same-runner paired A/B (Bench workflow, scratch branch, every build served at once, paired
run-reorder.mjsfrom #1646), run 37112063521, ms per click:Measurement-only variants on the same run bound what is left. Dropping the key-order scan gave rotateb 0.0578. Dropping the whole shape snapshot, which is unsafe, gave 0.0535, so the snapshot's O(N) chain copy, the per-commit transaction setup and parked removals account for the rest. Final numbers for this branch follow below.
Final paired runs (this head and with #1655)
Runs 37114023279 and 37114031982, same runner, 15 paired rounds. Each cell gives the two runs, in ms.
rotateb against React (guard 0.6, waived on #1646): main 0.64 / 0.63, this PR 0.53 / 0.53, with #1655 0.55 / 0.53. When the guard was set, before #833, it was 0.45.
Validation
fresh-root-scope-hold.test.ts: index-reading keyed rows are reordered (rotate, reverse, remove first, insert first) while a sibling suspends without a boundary. The DOM stays put, and after the retry every row showsitem:positionwith survivor identity kept. It fails (4/4) whenrestoreForSlotdoes not restore indices, and on main with its per-row journal removed. It passes on main.root-transactions/reorders.mjscounts root-journal slots per row (difference between 128- and 256-row lists) for rotate, reverse, remove first and insert first. It reads 4 on main and 0 here, againstmaxRatio: 0, with DOM order and survivor identity checked.node benchmarks/bench.mjs root-transactions --quick --ratiospasses all checked guards. The suite's existingcontracts.mjsfails a source-string assertion on main; ci(bench): triage the weekly ratio-guard breaches so new ones show #1641 fixes it.--project octane):fresh-root-scope-hold,parked-two-windows,suspense-preserves-dom,transitions,empty-refill-rollback,for,differential/suspense-timing,keyed-removal-lifetime,keyed-selection-aliasand two reconcile conformance stress files: 600 passed.pnpm typecheck:fileson the changed source and tests (the fixture's untyped-props errors are pre-existing on main);pnpm format:files;pnpm sync.pnpm test,pnpm typecheck,pnpm format:check: left to CI (many parallel local sessions).Risk / follow-ups
nodeValueread, which is a contract, plus a bag clone.rotatebwaiver lives on fix(benchmarks): pair the timing samples behind waived ratio guards and re-judge them #1646. Remove it after both land, using the paired numbers above.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Changes undo/rollback invariants for keyed
@forduring root transactions; incorrect index restoration would show wrong positions after held renders, though new benchmarks and held-root tests target this path.Overview
Keyed list reorders during undoable root renders no longer journal each survivor's
itemIndex(four journal slots per row). Rollback now relies on the existing list shape snapshot:reconcileKeyedrecords that shape before the first index write, andrestoreForSlotsets each row'sitemIndexfrom its position in the restored chain. The hydration/adoption path still journals indices per row because it restores a DOM range, not a chain.journalForSlotis triggered when a survivor's index changes (prefix/suffix/middle walks), returnsfalseafter recording, and builds key-order comparison via a single[...state.items.values()]spread instead of incremental copying.Validation: new
root-transactions/reorders.mjsbenchmark guards (0 per-row index slots vs 4 on main), README baseline table update, and held-root tests for@forrows that readindexacross rotate/reverse/insert/remove while a sibling suspends.Reviewed by Cursor Bugbot for commit b96e690. Bugbot is set up for automated code reviews on this repo. Configure here.