Repository navigation
Description
Summary
Octane writes to the live DOM while it renders. Every feature that needs "don't show this yet" (transitions that suspend, Suspense holds and reveals, off-screen swaps, ViewTransition, signal writes inside a transition) has therefore built its own way to hold back or undo those writes. There are nine such mechanisms today. React gets the same behaviour from one commit phase and a work-in-progress tree.
Measured on the shell_ app from #2027 (every feature in use; oxc minify; sourcemap attribution per declaration; gzip figures are the saving from deleting a group's bytes and re-gzipping, which runs about 20% low against a real build):
| Area: transitions, Suspense/try/lazy, journal, off-screen, ViewTransition, signal transitions | raw | gzip |
|---|---|---|
| Octane | 130.5 kB | 39.0 kB |
| React 19.3 (commit phase, Suspense/Offscreen/Activity, throw/ping/retry, lanes, lazy, ViewTransition) | 54.6 kB | 15.5 kB |
That is about 24 kB of the 54.5 kB gzip gap between the two shell_ twins (124.3 vs 69.8 kB). Even with no Suspense, lazy or ViewTransition in use, this machinery costs 14.7 kB gzip of the base app.
Nine mechanisms for one problem
| # | Mechanism | What it hides or undoes | raw | gz |
|---|---|---|---|---|
| 1 | Root undo journal (record + rollback) | binding writes of an attempt that suspends | 7.4 | 2.4 |
| 2 | Deferred root teardown + root commit | removals until the root commits | 4.9 | 1.4 |
| 3 | Keyed-list chain records + row parking | list moves and removals | 4.2 | 1.3 |
| 4 | Boundary journal windows + staged reveal groups | per-boundary reveal batching | 2.5 | 0.8 |
| 5 | Off-screen render + effect capture/splice | new subtrees at swap sites | 4.6 | 1.4 |
| 6 | Transition attempts + held root/sync transitions, replay/rebase, cell staging | single-buffered state during a held transition | 13.7 | 4.0 |
| 7 | Suspense hide (display:none) / reveal / resume |
committed content under a fallback | 10.6 | 3.0 |
| 8 | DOMStage proxy + staged commit capture + deferred layout + ~600–800 inline STAGED_DOM checks |
ViewTransition's render before startViewTransition |
34.4 | 8.3 |
| 9 | Signals transition candidates (SignalActionFrame, transition coordinator) |
signal writes inside a transition | 16.5 | 4.8 |
They overlap:
- During a ViewTransition the journal (1) and
DOMStage(8) are both active, so every write is logged twice: an undo entry plus a forward op whose guard is cancelled throughjournalUndo. StagedCommitCapturewraps anOffscreenCapture(5), andDeferredLayoutCapturemoves the same refs, stores and passives a second time.- Off-screen swaps (5) duplicate deferred root replacement (2) inside root transactions.
- The signals coordinator (9) re-implements the renderer's begin/hold/rollback protocol through a 30-member host interface.
- Hydration builds two more of its own: a DOM undo log and four separate Suspense hydration paths (Hydration: collapse the hydration engine back into the mount path (Ripple/Svelte-style cursor), 23 kB → ~5 kB gzip #2028).
Only part of #7 is React parity that any design keeps: display:none hiding, ref/effect disconnect and reconnect, and the retry throttle. These are React's hideInstance and disappear/reappearLayoutEffects.
Root causes
- Render is the mutation. Writes reach the live DOM during render, so withholding them needs either undo (journal), redirection (off-screen), or interception (
DOMStage, which must answer every read-back of a node the runtime just wrote:parentNode, attributes, text, form ownership, selectors). - State has one copy. React holds a transition as lane-tagged updates on each update queue and simply doesn't process them. Octane has to revert cells, re-render the pending cue against the old inputs, swap memo entries back and forth, harvest warm caches between rounds and then promote. Signals repeat all of this for their own cells.
Target design
- Render writes a withheld op log; commit applies it. Writes go through a small set of write points (about 30) into a flat log in renderer-owned order. Commit applies the log as one batch. A suspended transition drops it, a Suspense reveal applies it, and an off-screen swap becomes a fresh subtree plus a withheld insert. ViewTransition applies the log inside
startViewTransition, split into mutation/layout stages like React'sflushMutationEffects/flushLayoutEffects. - Render stops reading back DOM it wrote. Structure comes from Block ranges and values from bag caches. This is the prerequisite for deleting
DOMStageand its read projection. The keyed reconciler,clearChildContentandcollectBlockRangemust resolve ranges against renderer-owned structure instead of walking live siblings mid-render. - Transition holds come from update queues, not undo. Hook state gets React's model: a base value plus pending updates tagged by batch. Holding a transition means not processing its updates. Signal cells use the same queue, so the signals coordinator and candidate frames go away. A renderer-state journal for thrown-away renders survives only where something still lacks two copies (bag guards, list-chain records).
Estimated effect:
| gzip | |
|---|---|
Fully replaced: journal DOM entries, deferred teardown, row parking, off-screen capture, reveal windows, staged commit/deferred layout, DOMStage, staged-DOM checks |
11.7 kB |
| Partly replaced: rollback/commit core, attempts/holds, reveal/resume, signals coordinator | up to 7.2 kB |
| New code: op log, applier, staged commit | about +2 kB |
| Net | about −10 to −17 kB |
ViewTransition's own logic (naming, measuring, activation, 8.5 kB gzip against React's ~2.6 kB) is separate follow-up work.
Performance (estimated, to be measured). The always-on journal was earlier measured at 10–30% of update time. The op log costs the same one push per write, but drops:
- reading old values back from the DOM (
journalAttr'sgetAttribute) - range snapshots and undo closures
- inserting and moving off-screen markers
- the per-op staged-DOM branch
It adds one dispatch per op at commit. Expected −10% to +5% against today's journaled updates. Urgent updates must not regress.
Plan
Each step lands on its own, with the async-composition, transition, Suspense and ViewTransition suites green and update/mount benches compared against the base:
- Merge duplicate paths inside today's model (low risk, −2 to −3.5 kB gzip).
- Off-screen swaps use root deferred replacement.
- One hold record instead of
HELD_SYNC_TRANSITIONandowner.transition. - One reveal-window system.
- The signals coordinator reuses the renderer's attempt protocol.
- Signal transitions on the update-queue model (−4 to −4.5 kB gzip). Fork semantics stay (decided 2026-10-13; see Signals: thin core — transitions via renderer update queues, commit-time subscriptions, seeds behind hydration (22 kB → ~8–10 kB gzip) #2031): signal cells get the same batch-tagged pending-update queue as hook state.
- No DOM read-back during render. Make the reconciler and writers resolve structure and values from renderer state. Measure update cost.
- ViewTransition on the op log. Delete
DOMStage, the staged-DOM checks and the staged commit/deferred layout captures (−5 to −5.5 kB gzip alone). - Transitions and Suspense on the op log. Delete journal DOM entries, deferred teardown, row parking, off-screen capture and reveal windows, and simplify reveal/resume.
- Holds from update queues. Replace revert, re-render and promote, and keep only the renderer-state journal that is still needed.
Must keep
- Transitions: React semantics. All-or-nothing commit of a transition, committed UI held while it is pending,
isPending, async-action entanglement,useOptimistic. - Suspense: fallbacks,
display:nonehiding with effect and ref disconnect/reconnect, retry throttling, Activity. - ViewTransition:
update/name/class props that change within the same transition still choose the old snapshot correctly (the reason for feat: align ViewTransition with React and add element scopes #1095). - Moves don't disturb nodes: applying the log must not detach and reinsert nodes in ways that reload iframes, pause media or blur focused elements. This is why
DOMStagewithholds rather than applies and reverts. - Focus and selection preservation, controlled inputs, hydration adoption.
- The already-closed divergences in
packages/octane/audit/SUSPENSE_DIVERGENCE.mdstay closed. This design should also close feat: add basic agent skills and MCP scaffold #4's remaining limitation (general transition-wide work in progress: content patched outside a suspended boundary can commit early), moving Octane fully onto React's semantics there.
Decided
- Signal writes inside
startTransitionkeep fork semantics (2026-10-13). The update-queue design must therefore cover signal cells andderived$/query$producers, not only hook state. - DOM writes from render become visible at commit, matching React's timing (2026-10-13). Side effects of those writes therefore run during commit, not mid-render: custom-element
attributeChangedCallback/connectedCallback, MutationObserver records, and anything they do, such as moving focus. Tests that pin the earlier mid-render timing are updated to React's. A prototype showed 4 focus-restoration tests depend on it.
Open questions
- Can urgent renders write eagerly, skipping the log, and handle a thenable thrown mid-render by hiding the primary under its fallback and re-rendering it on resume (React's urgent-suspension rule)? If so, the log is needed only for transitions and ViewTransition, and the urgent path keeps today's speed without the always-on journal.
- Ordering with Hydration: collapse the hydration engine back into the mount path (Ripple/Svelte-style cursor), 23 kB → ~5 kB gzip #2028: hydration's boundary recovery and undo log should land on this commit model rather than being rebuilt first.
- Any scheduling change goes through Investigate microtask megatasks in streams, hydration, actions, and deferred rendering #1864.
Refs: #2027 (benchmark), #2028 (hydration), #1095 (ViewTransition parity), #1864 (scheduling), #1801 (size umbrella), packages/octane/audit/SUSPENSE_DIVERGENCE.md.
🤖 Generated with Claude Code
Activity
trueadm commentedon Oct 13, 2026
Per-render wrapper cost today (
renderBlockInner), for sizing the new commit pathThese are measurements of the function that wraps every Block body render. It holds most of the per-render bookkeeping this issue replaces: the journal push, capture targets, the urgent-transition driver and warm-plan checkpoints. They show what that bookkeeping costs per render today and how V8 treats it on a cold hydration.
Setup.
benchmarks/app-frame-hydration,framescenario (1,653 Blocks, 1,653 renders, signals on). Chromium 149 headless shell, 4× CPU throttle, a fresh browser context per cold sample. A/B runs userun.mjs N --base=<main>(paired ratios, bootstrap 95% CI). Base is main at c4b9932.1. Most of its profiled self time is compilation of what it calls
block.body(...)call line.--js-flags=--no-lazyhas no effect in Chromium;--log-function-eventsstill shows ~450 lazy compiles during hydration.2. The wrapper itself
Array.prototype.pushfor the 4-slot journal entry,blockIsAncestor,contextEpochNow, the native-read driver'sbeginRender/endRender, andisSuspenseException.endRender+isSuspenseExceptionline takes the largest share of the rest;beginRender, and the output-handler check.Which checks fire during the cold hydration (instrumented, 1,653 renders):
WIP_CAPTUREpresent and a root transaction, so effect-event targets come from the captureTRANSITION_JOURNALat depth 1, with aJOURNAL_RENDERpushslots[0].returnedOutputload runsrarerecord, context read maps, effect slots, native retry map, pending/replay, urgent-transition driver, invalid statusOn the hydration path the journal and capture bookkeeping is the common case, not a rare branch. Every render pays it, because hydration runs inside a root transaction. The checks that really are rare total only ~25–30 bytecodes.
3. Tier-up
Sampling
%GetOptimizationStatuson every call gives this timeline:returnedOutputload. That load reads whatever record a Block keeps inslots[0], an open-ended set of shapes.%HaveSameMapshows theslotsarrays themselves are stable.4. How much moving it is worth (paired cold hydration, head/base)
returnedOutputload. A ceiling onlyisSuspenseExceptiononly on failurereturnedOutputload, so it stays in Maglev longerDeterministic counters (Blocks, renders, jitless heap bytes) were identical across all variants. No change was landed.
What this suggests for the new commit path
slots[0].returnedOutput, is enough to drop it out of Maglev for the rest of a cold hydration.JOURNAL_RENDERis today, it runs on every hydration render. Keep its entry shape and push site fixed.trueadm commentedon Oct 13, 2026
A scheduling rule this commit model must support
@trueadm decided the following on 2026-10-13 (#1864), and #2028 step 5 implements it. The full rule, the numbers and the lessons are on #2028; that issue was closed by accident when #2033 merged.
When boundaries hydrate through the client retry path, they follow React 19's schedule:
hydrateRootadopts and commits the shell in one task. Server-resolved Suspense arms stay dehydrated, holding server DOM. They hydrate in later host tasks, in document order, at least one per task within the shared ~5 ms host budget.What this needs from the commit model:
One commit per dehydrated boundary, or per batch of boundaries, in a later task. Each commit runs that boundary's refs and layout effects after the shell's have run, and it never re-renders the parent. The budget-only prototype resumed arms through
scheduleRender(parentBlock)and paid for it:renderBlockInnercallsA synchronous hydrate-and-commit inside an event dispatch. Selective hydration has to finish its commit before the dispatch continues.
Holding an update while the boundary it reaches hydrates first. This is React's bumped-lane
SelectiveHydrationException. The update-queue holds planned in step 6 fit this.Hydrating the arm inside the update's own render failed in perf(octane): hydrate server-resolved Suspense boundaries after the shell #2040. It made the arm read external state that a shell layout effect had already changed, so the arm fell back to client rendering and lost its server DOM.
The reference implementation, #2040, is kept as a draft and won't merge on today's engine. On
frame-boundariesat 4× CPU it took the longest task from 87.7 to 20.5 ms, with busy total +3.8%. It builds three pieces on today's resolved-arm path, and this model would have to rebuild them:tryBlock.That path relies on the undo journal and off-screen capture that steps 5–6 delete: its speculative attempt,
rollback, andcreateOffscreenCapture. So the deferral is better built once, on this model, through #2028 step 5.Two more points from #2040 for this model:
preserveRootCreatedDomcost. An arm committed outside the root's hydrating transaction called it once per created Block, about +5% busy time, until its transaction was markedhydrating. The new model's hydration commits should not pay it.scheduleRender(state.parentBlock), a parent replay, as onmain. A single resume route should cover it too.trueadm commentedon Oct 13, 2026
Superseded by #2043, which describes one vision covering the commit model, one renderer and signals. The decisions recorded here (signal fork semantics, React commit timing) carry over.
perf(octane): hold transitions as queued hook updates (#2029 step 4)