Repository navigation
perf(octane): skip journal entries for Blocks a root render discards with their parent - #1892
Conversation
…with their parent A root render's undo journal recorded a creation entry and a render entry for every Block it created, including Blocks nested inside a parent it also created, which rollback discards with that parent. Skip both entries for such Blocks (walking past hookless stand-ins to the owning Block) at the root window's depth, and after replaying the journal sweep `created` for any Block the parent's undo did not reach: a portal whose content suspended before its slot was registered, or an arm a restored slot no longer names. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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)❌ 29 value(s) exceed their committed budget. Reduce the growth, or raise the budget in a separate pull request that names the bytes and the reason (CONTRIBUTING.md, "Size budgets").
8 other measured values are unchanged. Public-import reachability bundles (bytes)❌ 64 value(s) exceed their committed budget. Reduce the growth, or raise the budget in a separate pull request that names the bytes and the reason (CONTRIBUTING.md, "Size budgets").
36 other measured values are unchanged. |
…alls The js-framework work counters count every production function call, and the `discardedWithParent` helper added one per created or rendered Block. Test the parent's stamp inline in createdInRootRender and renderBlockInner instead. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The inlined stand-in walk at the render-entry site cost 72 raw bytes. A Block whose direct parentBlock this root render created can skip its render entry, because that parent's entries invalidate the committed path; Blocks below a hookless stand-in keep theirs. The creation entry keeps the stand-in walk. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website | 4ec3ab2 | Commit Preview URL Branch Preview URL |
Oct 08 2026, 02:22 PM |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website-mcp | 4ec3ab2 | Commit Preview URL Branch Preview URL |
Oct 08 2026, 02:25 PM |
… skip (#1892) (#1893) Co-authored-by: Claude Opus 5.5 <[email protected]>
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]>
…udgets #1888 (the split transition cue) merged ahead of its budget-only raise #1887, so main's transition-using rows exceed their ceilings. #1893 has since raised budgets for #1892, which is still open, but measured without #1888's growth. Raise only the 30 rows still over their ceilings on main 1e74902, to measured + 32 raw/gzip (+ 256 brotli) from run-minimal.mjs and run.mjs --write-budgets, and keep every other value, including #1893's pending raises: - suspense-transition, Base UI, Radix and Apollo bindings, bindings app: about +1.12 to +1.15 kB raw, +0.30 to +0.37 kB gzip - hydrate-frame +63 raw / +37 gzip; root-static brotli +279 The 62 rows #1893 raised stay above their ratchet floor until #1892 lands. This supersedes #1887. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
#1892 (78750a0) landed right after e14fbdf ratcheted main's budgets to main's measured bytes, so its root-journal growth is over the ceilings. Rewrite every budget with run-minimal.mjs and run.mjs --write-budgets on 78750a0 (measured + 32 raw/gzip, + 256 brotli): 77 raises, 2 lowerings, budget files only. Main passes the ceilings and the ratchet as it stands. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
… 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
transaction.createdand unmounts any Block it created that is still live. That covers Blocks the creator's teardown can no longer reach.Why
Every scheduled root render opens an undo journal.
createdInRootRenderlogged a 4-slotJOURNAL_CREATEDentry, andrenderBlockInnera 4-slotJOURNAL_RENDERentry, for every Block the attempt created. That included Blocks nested inside a parent the same attempt created, which rollback (undoCreatedInRootRender) discards together with that parent. On the 2,047-componentrecursive-contextmount that is 8,202 entries and about 480 KB of allocation per mount.The prototype was not rollback-equivalent
Skipping the entry when
TRANSITION_JOURNAL_DEPTH === 1 && parent.createdStamp === ROOT_DISCARD_STAMPassumes the parent's teardown reaches every skipped child. Two realistic cases break that assumption:portal()registers its slot afterrenderPortalStatereturns. A fresh portal whose content suspends is therefore unreachable, and rollback leaves its range markers and partial content in the target.@ifarm.journalRootSlotis not gated for created owners, so rollback restoresstate.blockto the old, already-disposed arm. The new arm is then unreachable, and its Block, cleanups, signal owners, and portal DOM leak.The sweep makes the set of Blocks disposed by a rollback identical to before. Every created Block is still pushed into
transaction.created, and the skip requires the Block's owncreatedStampto match, so a skipped Block is always in that list.Rollback equivalence
TRANSITION_JOURNAL_DEPTH === 1. A boundary window replays only its own entries and has no sweep, so it keeps every entry. A Block skipped at depth 1 is never inside an open nested window.retainedCreatedand hydration:ROOT_DISCARD_STAMPis -1 in hydrating attempts and after the first retention, so nothing is skipped there. The skip test runs aftercreatedInRootRender's own preserve check. Every later retention happens immediately aftercreateBlock, before the Block has children.trackPresentationFrameretains ancestors late, but only ones created while hydrating, which were preserved and so never skipped.portalSlotSlotbranch forces it). One its owner never registered is caught by the sweep, which detaches it. Its event-range and delegation registration is undone by the existingrenderPortalStatejournal closure, which is still logged.LiteBlockImplstand-ins to their owning Block; lite scopes are registered on that owner'sscope.children. The render-entry test checks only the directparentBlock, so Blocks directly below a stand-in keep their render entries.nativeLocalHookdisposers and signal-owner retirement, now run parent-first (ordinary deletion order) instead of in reverse creation order. Their effects never ran.Changes
packages/octane/src/runtime.ts: an inline ancestor-stamp test that gates theJOURNAL_CREATEDpush increatedInRootRenderand theJOURNAL_RENDERpush inrenderBlockInner, and the post-replay sweep inrollbackRootRender. The test is inline rather than a helper so the change adds no function calls; the js-framework work counters, which count every production call, matchmainexactly (40 of 40 values).packages/octane/tests/root-rollback-nested-created.test.tsand fixture: a fresh portal whose content suspends, a fresh parent swapping its arm within one attempt, and a committed boundary holding a transition.Validation
root-rollback-nested-createdpasses inoctaneandoctane-prod. 35 neighbouring rollback, portal, suspense, transition, de-opt upgrade, warm-plan and hydration files pass inoctane(618 tests).pnpm test(left to CI)pnpm typecheck:filesandpnpm format:files:checkon the changed filesperf-review: see belowMeasurements
Paired runs, base and candidate interleaved per round with rotating order. Production builds of the
octane-tsrxfixtures, headless Chromium, served cross-origin isolated for 5 µs timers. Each row has an A/A control (base against a second copy of base).mount_closed, coldmount_closed, warmopen_close_cycleopen_allmount, coldmount, warmpartial_remountAllocation per op (CDP sampling heap profiler):
A creation-only variant (render entries kept) measures 1.00 on portal cold mount, so that win comes from dropping the nested render entries. The prototype's reported 3–5% open/close gain did not reproduce.
openAllopens@ifarms under committed items, so only the tooltip and its portal are skipped: 800 of about 8,600 entries.perf-review
Scan:
node scripts/perf-review-scan.mjs→ 0 candidates. js-framework work counters (pair.mjs --work-onlyagainstmain): identical.Hot paths touched:
renderBlockInner(per Block render) andcreatedInRootRender(per Block creation inside a root render). The sweep runs once per root rollback.runtime.tscreatedInRootRender/renderBlockInnerparentBlockonBlockImplorLiteBlockImpl(both declare it) andcreatedStamponly on theBlockImplit ends at. The render side readsparentBlock?.createdStamp, which is a 2-map load when the parent is a stand-in, and only for Blocks this render created.runtime.tsrollbackRootRenderroot-static165,748 vs budget 165,531). Needs the budget-only raise in #1893, which must land first.No compiled-output, DOM, or scheduling change.
Risk / follow-ups
@iftoggles costs about 5% of a portal open/close cycle (journalRootSlot, mostly self time). Per toggle it allocates two undo closures, a spread clone of the slot state, a node array, and two Map entries. Typed journal entries for the structure release and the lease-free range restore would remove the closures. Not attempted here.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 root-render rollback and suspense teardown paths; behavior is intended to stay equivalent via the post-replay sweep, but incorrect gating could leak DOM or skip needed undo entries.
Overview
Root render undo journals no longer record
JOURNAL_CREATEDorJOURNAL_RENDERfor Blocks whose nearest real ancestor the same attempt also created—those subtrees are torn down with the parent on rollback anyway. Nested transition boundaries, hydration, and adopted DOM still log every entry.Rollback now sweeps
transaction.createdafter replaying the journal and unmounts any Block the attempt created that is still live, fixing leaks when a skipped Block was never linked (e.g. a portal that suspended before its slot registered, or an@ifarm swapped mid-render).Adds regression tests for those portal, arm-swap, and transition-held-boundary cases. Measured wins: ~8% less heap on a large recursive mount and ~13% faster cold portal-swarm mount; open/close on committed trees is unchanged.
Reviewed by Cursor Bugbot for commit 62d71e9. Bugbot is set up for automated code reviews on this repo. Configure here.