… a row (#1890)
* perf(octane): copy a keyed reorder's record directly until it relinks 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]>
* perf(octane): look a keyed list's record up only when its window has 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]>
* perf(octane): read a keyed list's record from its undo entry inline
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]>
* ci(bench): lower the budgets by this change's measured saving over #1891
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]>
* ci(bench): re-lower the budgets this change saves on after #1875 landed
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]>
* ci(bench): re-lower the budgets this change saves on over #1893
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]>
* ci(bench): re-lower the budgets this change saves on over 87d9f95
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]>
* ci(bench): lower the budgets by this change's saving over main's ratchet
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]>
* ci(bench): lower the budgets by this change's saving after #1892
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]>
---------
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: domgan-oai <[email protected]>
Summary
Change 2 of the #1801 journal work (changes 1 and 3 are #1831).
What it changes: every scheduled render opens the root undo journal. Before a keyed list changed its order,
journalForSlotcopied the whole row chain and the key Map's order. It did that even for a two-row swap or a single removal. Inserts, removals and small reorders now record only the rows they relink.Measured on the js-framework rows app:
.tsrx).tsrx).tsx)Production calls and DOM mutations are unchanged on every operation. A knockout that skipped the snapshot entirely measured −18% / −23%, so this takes back essentially all of it.
How
Why only links are needed.
restoreForSlotalready rebuilds every row'sprevSiblinganditemIndexfrom chain position. So rollback only needs to walk the old order forward.Link record. Each
ForSlotRecordkeeps the old head, and the oldnextSiblingof each row whosenextSiblingthe reconcile rewrites. Rollback walks the old chain through those links (fullForSlotRecord), then restores exactly as before.beforeMiddlebeforeMiddle(the removed run keeps its own links)K_DISPmoved rows)beforeMiddleFull form. LIS moves, full replace, clear and fills keep today's full snapshot, as does any wholesale change later in the same window. A newer window's record converts an enclosing link record to the full form first.
Key Map order stays exact, because context refresh iterates it:
ForSlot.inOrdersays the Map iterates in chain order, rollback rebuilds the Map from the chain. Otherwise the removal first keeps the Map's prior order.Call parity.
journalForSlot(state, link?)is still one call per site. Record creation is inline, and so are the link notes.Development cross-check. In development builds a link record also takes the full form. On use, it throws catalogued error 343 if the two differ. So every existing rollback test checks the link path.
Validation
keyed-rollback-links.test.ts: 11 cases, each holding a root render that applies each shape, rolling it back, and checking committed node identity and order, then the settled result. The shapes are append, prepend, middle insert, middle removal, removal at the ends, removal after a committed reorder, swap, swap after a swap, several link reconciles in one held render, and a link reconcile followed by an LIS reorder or a full replace.beforeMiddlenote: 2 failures@forsuite,--project octane(dev cross-check active), passes: 59 files, 896 tests. The new file and two existing rollback suites also pass under--project octane-prod.pnpm typecheck:files,pnpm format:files:check,pnpm error-codes:check, andpnpm synccleanpnpm test/pnpm typecheckrepo-wide (left to CI under the local test-load rule)Risk / follow-ups
ForSlot. That check fails on that commit and passes now.nextSiblingit rewrites. The development cross-check catches any path that misses one in any rollback test.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 core keyed-list reconcile and transition-journal rollback invariants; correctness relies on recording every relinked
nextSibling, with dev-only cross-checks mitigating misses.Overview
Keyed list transition rollback no longer snapshots the entire row chain and key-map order on every small reconcile. Inserts, removals, and small displacements use a link record that stores the old head and prior
nextSiblingvalues only for rows that get relinked; rollback reconstructs the chain from those links. Wholesale changes (LIS reorder, full replace, clear) still take a full snapshot, and a link record is upgraded to full if a later change in the same journal window needs it.ForSlotgains aninOrderflag so rollback can rebuild the keyMapfrom the restored chain when map iteration still matches DOM order, or preserve prior map order after reorders/middle inserts.Dev builds keep a parallel full snapshot on link records and throw error 343 if link-based restoration disagrees. New
keyed-rollback-linkstests cover held renders across append/prepend/insert/remove/swap and mixed sequences.Reviewed by Cursor Bugbot for commit 888e3af. Bugbot is set up for automated code reviews on this repo. Configure here.