Repository navigation
perf(octane): copy a keyed reorder's record directly until it relinks a row - #1890
Merged
Merged
Conversation
… a row A keyed reorder records its list at the first row index it rewrites, before it knows whether it will relink a few rows or every row. Since #1833 that record allocated its `links` Map and a per-journal records Map up front. When the reorder then reached the LIS path, `fullForSlotRecord` walked the chain through the empty links Map and, for a key Map already out of chain order, built a Set of every row to filter it. The record now gets its links Map at its first relink (`forSlotLinks`). Until then only index writes have run, which change neither the chain nor the key Map, so converting it copies the list as it stands, which is the full form's cost before #1833. The record rides in the spare slot of its own undo entry, found again through the window's `seen` index, so `SLOT_RECORDS` is gone and the record still lives exactly as long as its log. - recursive-context zero-context reorder: 4 Map constructions -> 2, so context-cache-work.mjs passes its ceiling again (bisected to e595a13). - js-framework reorder matrix (octane-tsrx, paired, 12 samples): rotatef, rotateb and displace3-8 are 22-27% faster than main and within 5% of the runtime before #1833; removals and inserts keep #1833's gains. - Framework bundles are 129-137 raw bytes smaller; budgets lowered. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
October 8, 2026 12:27
Contributor
Benchmark report
Compares js-framework: 1k/10k row operationsAll 20 timed operations (20 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)
7 other measured values are unchanged. Public-import reachability bundles (bytes)
84 other measured values are unchanged. |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website | 716cc05 | Commit Preview URL Branch Preview URL |
Oct 08 2026, 02:29 PM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| 🔵 In progress View logs |
octane-website-mcp | 716cc05 | Oct 08 2026, 02:29 PM |
4 tasks done
…an entry The PR bench counted two more production calls on every js-framework operation: journalForSlot and journalForOwnedListClear called the record lookup, and fullForSlotRecord with no record, even for a list's first record in a render, where there is no entry to find. Skip both when the list has no entry. Every js-framework calls_* and dom_* counter now equals main's (pair.mjs --work-only). Lower the bindings app and total brotli budgets the ratchet now asks for. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…to fix/keyed-reorder-map-allocs
…-allocs # Conflicts: # benchmarks/bundle-size/minimal-budgets.json
Inline the record lookup in journalForSlot and journalForOwnedListClear. With the helper, the bindings app's framework chunk compressed 21 gzip bytes larger than main's, past its budget, although raw was 104 bytes smaller. Inline, it is 5 gzip bytes larger and 10 under the budget. Production calls are unchanged: every js-framework calls_* and dom_* counter equals main's (pair.mjs --work-only against c0192ec). Re-measure the bundle budgets on current main. The merges took main's budget files, and this writes 40 lowers and no raises. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-allocs # Conflicts: # benchmarks/bundle-size/minimal-budgets.json
…-allocs # Conflicts: # benchmarks/bundle-size/app-budgets.json # benchmarks/bundle-size/jsx-budgets.json # benchmarks/bundle-size/minimal-budgets.json
The merge took main's budget files. #1891 raised 70 rows ahead of #1875, which is still open. Each raw and gzip row now drops by exactly what this change saves against main (2f81266), measured per scenario on both trees. A row #1891 raised therefore keeps #1875's headroom. Brotli rows keep main's values, and no value is raised. Every head measurement fits its budget. The ratchet flags only the 70 rows #1891 raised for #1875, as it does for any PR until #1875 lands. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…yed-reorder-map-allocs # Conflicts: # benchmarks/bundle-size/app-budgets.json # benchmarks/bundle-size/minimal-budgets.json
The merge took main's budget files. Each raw and gzip row that main (abe9b42) fits drops by exactly what this change saves against main, measured per scenario on both trees. Brotli rows keep main's values unless the ratchet asks for less. That gives 24 lowers and no raises. Main measures over 35 rows after #1875 and #1888, and #1887 budgets that growth. Those rows keep main's values here. Merging #1887 will re-lower the ones this change also saves on. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-allocs # Conflicts: # benchmarks/bundle-size/app-budgets.json # benchmarks/bundle-size/jsx-budgets.json # benchmarks/bundle-size/minimal-budgets.json
The merge took main's budget files (6eef1e0). Each raw and gzip row that main fits drops by exactly what this change saves against main, measured per scenario on both trees. Brotli rows keep main's values unless the ratchet asks for less. That gives 37 lowers and no raises. The rows #1893 raised for #1892 keep #1892's growth. The 30 rows main exceeds until #1887 lands keep main's values. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-allocs # Conflicts: # benchmarks/bundle-size/minimal-budgets.json
This comment has been minimized.
This comment has been minimized.
The merge took main's budget files. Main now fits every row. Each raw and gzip row drops by exactly what this change saves against main, measured per scenario on both trees. Brotli rows keep main's values unless the ratchet asks for less. That gives 63 lowers and no raises. The rows #1893 raised for #1892 keep #1892's growth. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-allocs # Conflicts: # benchmarks/bundle-size/app-budgets.json # benchmarks/bundle-size/jsx-budgets.json # benchmarks/bundle-size/minimal-budgets.json
The merge took main's budget files. e14fbdf set every budget to main's measured bytes plus headroom. Each raw and gzip row drops by exactly what this change saves against main, measured per scenario on both trees. Brotli rows keep main's values unless the ratchet asks for less. That gives 56 lowers and no raises. Every ceiling and the ratchet hold locally, and so do the budget-raise and hydration-free checks. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-allocs # Conflicts: # benchmarks/bundle-size/app-budgets.json # benchmarks/bundle-size/jsx-budgets.json # benchmarks/bundle-size/minimal-budgets.json
The merge took main's budget files (68aa481), which match main's measured bytes. Each raw and gzip row drops by exactly what this change saves against main, measured per scenario on both trees. Brotli rows keep main's values unless the ratchet asks for less. That gives 54 lowers and no raises. Locally, binding-mantine-hooks-esbuild brotli is 7 bytes over main's value, 27,265 against 27,258. Its raw and gzip bytes equal main's: esbuild assigns different minified names in that bundle, and brotli compresses them differently. 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
node benchmarks/bench.mjs recursive-contextfails on main:context-cache-work.mjsreports "Zero-context reorder allocated 4 Maps (maximum 2)". A bisect puts the jump from 2 to 4 at e595a13 (perf(octane): record only the relinked rows when a keyed list may roll back #1833). Its parent e67e86f passes, and perf(octane): skip undo entries for writes into rows the render creates, and clear lists without a call per row #1831 (50e18cc) leaves the count unchanged.links: new Map()plus a per-journalSLOT_RECORDSMap up front. When the reorder then reached the LIS path,fullForSlotRecordwalked the chain through the empty links Map. If the key Map was already out of chain order (!inOrder), it also builtnew Set(chain)and filtered the Map through it. rotatef, rotateb and displace3–8 over 1,000 rows all reach the LIS path, so every click paid that. This explains the 25–35% slowdown seen against the 0.8.0 record.linksMap at its first relink (forSlotLinks). Until then only index writes have run, and they change neither the chain nor the key Map. Converting such a record copies the list as it stands, which costs what the full form cost before perf(octane): record only the relinked rows when a keyed list may roll back #1833. The record now lives in the spare slot of its ownJOURNAL_UNDOentry, found again through the window'sseenindex, which is read inline injournalForSlotandjournalForOwnedListClear. That removesSLOT_RECORDS, and the record still lives exactly as long as its log, so perf(octane): record only the relinked rows when a keyed list may roll back #1833's retained-row fix still holds. The ceiling is unchanged.Why
The weekly Bench CI would flag the same harness failure. The regression is real work on every whole-list reorder under the root journal, which every scheduled render opens.
Changes
packages/octane/src/runtime.ts:journalForSlotandjournalForOwnedListClear(record lookup inline),fullForSlotRecord(now a no-op for a full record or none), andforSlotLinks, whichreconcileKeyed's link sites use.SLOT_RECORDSis removed.packages/octane/tests/keyed-rollback-links.test.tsand its fixture: three rollback cases for a record that only saw index writes:budget-raises.mjs --base origin/mainreports none).hydrate-frameraw was checked against main's CI shard log, and local main matches it byte for byte.octanepatch.Validation
pnpm format:check: not run repo-wide.pnpm format:fileson every changed file.pnpm typecheck: not run repo-wide.pnpm typecheck:fileson the runtime, test and fixture passes.pnpm test: not run locally (machine load rule). CI runs it.targeted tests (
--project octane):keyed-rollback-links,for,parked-two-windows,empty-refill-rollback,keyed-removal-lifetime,keyed-selection-aliasandsuspense-preserves-dompass (258 tests).New tests fail against broken variants:
TypeError … nextSibling);Gate:
node benchmarks/recursive-context/context-cache-work.mjsgives reorder Maps zero/one/two = 2/2/2 (main: 4/4/4) and "Context-cache allocation and semantic gates passed."Paired js-framework reorder matrix:
run-reorder.mjs 12withTARGETS, run against production builds of e67e86f (before perf(octane): record only the relinked rows when a keyed list may roll back #1833), main 9d4c14f and this fix, served side by side and sampled in rotating order in one Chromium. The final build was re-run after self-review. Medians in ms per click:rme is at most 3.6% on the rotate and displace rows. perf(octane): record only the relinked rows when a keyed list may roll back #1833's swap, remove and insert gains are kept; the timer-floor ops (
*100,removeevery10) are within noise.Against [email protected] (8a4a2e0), the baseline where the parent session saw main 12–17% slower: its own octane-tsrx fixture was built with its own toolchain and paired with main and this fix in the same
run-reorder.mjs 12run. Medians in ms per click:This fix covers the whole 0.3.6..main regression on small moves: the fix is 11–16% faster than 0.3.6 there, and rme is at most 2.8%.
Work counters:
node benchmarks/js-framework/pair.mjs --base-tree=<main c0192ec816> --work-onlyshows everycalls_*anddom_*counter, for both octane-tsrx and octane-jsx, equal to main's. The first head added two calls per operation, which the bench report caught: a record-lookup helper and a no-op conversion call ran on each list's first record. Both are gone, and the lookup is inline.Bundle size: on the pre-fix: coalesce and pace ready signal producers #1875 base (c0192ec), the CI step (
run-minimal.mjs --budgets --ratchetandrun.mjs --budgets --ratchet octane-tsrx octane-jsx) passed, and so didbudget-raises.mjsandrun-hydration-free.mjs. On current main (e14fbdf) the same steps pass: every ceiling, the ratchet,budget-raises.mjsandrun-hydration-free.mjs. Framework raw is 104–112 bytes smaller on every changed row. Gzip on the bindings app compresses badly with small changes: its framework chunk is +5 gzip against main (108,922 against a budget of 108,932) while its raw is −104. Inlining the record lookup took that from +21, which was over budget, to +5. CI and local bytes for that app matched exactly on this PR's first run.perf-review: see below.Perf review: fix/keyed-reorder-map-allocs (origin/main..HEAD)
Scan:
node scripts/perf-review-scan.mjsfound no candidates.Hot paths touched:
reconcileKeyed's journal sites, which run once per keyed reconcile that changes order or membership under a journal (every scheduled render opens the root journal);journalForSlot, once per list per window, plus one lookup per later reconcile of that list in the window;fullForSlotRecord, at most once per record.journalForSlotlinksMap until a relink, and no per-journal Map, so a reorder that ends on the LIS path allocates the record and the chain/key-order arrays only, as it did before #1833. Inserts, removals and displacements still allocate onelinksMap at their first relink.ForSlotRecordliteralcheckstays the existing development-only field.journalForSlotrecord lookuplog[at + 2]only whenlog[at] === JOURNAL_UNDO. Every otherjournalUndoentry carriesnullthere. Log walkers ignore that slot forJOURNAL_UNDO.Dismissed candidates: none.
Not checked: Event Timing, because no user-visible latency claim is made. The js-framework production call and DOM counters are left to the PR bench.
Risk / follow-ups
Budgets: main's e14fbdf reset every budget to main's measured bytes plus headroom. This PR lowers 56 of them by its measured saving and raises none. Locally the full bundle-size job passes, ratchet included. ci(bundle-size): budget combined transition cues and native producers #1887 and perf(octane): skip journal entries for Blocks a root render discards with their parent #1892, if they land later, will re-measure on a main that includes this change.
The record lookup relies on
seen(TRANSITION_JOURNAL_BAGS) andTRANSITION_JOURNALbeing paired, which every arm site does (beginRootRender/endRootRender,armTransitionJournal, the transition-attempt window). A truncation always runs the undo closures that delete a list'sseenentry first.Not run locally: the
octane-prodproject, the full suite, and e2e. CI covers them.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 transition-journal keyed-list rollback storage and conversion on hot reconcile paths; correctness is covered by expanded rollback tests but the journal entry layout is subtle.
Overview
Fixes a keyed-list reorder regression where link-style rollback records allocated a
linksMapand a per-journalSLOT_RECORDSmap up front, then paid extra work when a reorder moved every row (rotations, LIS path).journalForSlotnow stores each list’sForSlotRecordon the spare field of its ownJOURNAL_UNDOentry (lookup viaseen), andforSlotLinkscreates thelinksmap only on the first relink. Records that never relink convert with a direct list copy, matching pre-0.10.1 cost.SLOT_RECORDSis removed;reconcileKeyedandjournalForOwnedListClearfollow the new lookup and wholesale-convert rules.Adds rollback tests for full rotations, out-of-order key maps, and suspend-before-relink; lowers bundle-size budgets (~110B framework); octane patch changeset.
Reviewed by Cursor Bugbot for commit 889dd51. Bugbot is set up for automated code reviews on this repo. Configure here.