Repository navigation
perf(octane): ship render rollback and suspension only with entries that can drop a render - #2256
Merged
Merged
Conversation
…hat can drop a render Every root render recorded an undo journal and every bundle shipped suspension handling. The journal state now lives in drivers.ts behind the ROOT_ROLLBACK capability, which use, lazy, Suspense, @Try, Hydrate, hydration, native reads, ViewTransition and renderer regions install as they load. Without it every journal write and the suspension path fold away, and a dropped render (an uncaught error, an unmount) is discarded with its root. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e installation Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
October 28, 2026 01:38
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website | f9dbbb8 | Commit Preview URL Branch Preview URL |
Oct 28 2026, 02:09 AM |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website-mcp | f9dbbb8 | Commit Preview URL Branch Preview URL |
Oct 28 2026, 02:09 AM |
Contributor
Benchmark report
Compares js-framework: 1k/10k row operations
All 20 timed operations (18 without a verdict)
Work counters (an increase fails this check):
50 other measured values are unchanged. Application bundle size (bytes)
14 other measured values are unchanged. Public-import reachability bundles (bytes)
37 other measured values are unchanged. |
The joined single-file runtime kept runtime.ts's re-export of rollback-entries.ts, which imported the runtime modules again, so a harness that loads the joined text bundled two runtimes. Each entry that renders and can drop the render now declares its public binding in its own module as a pure-annotated rollbackEntry() call, and internal callers use the implementation. The flag moves to rollback-flag.ts, a leaf module like hydration-flag.ts, so a load-time write can never reach it before it is initialized under any bundler's module order. lazy() keeps its no-side-effects factory and installs when it is called. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
6 of 7 tasks
trueadm
added a commit
that referenced
this pull request
Oct 28, 2026
…hat-stream #2256 now guards discardFrontierBlock's Suspense retry lookup with ROOT_ROLLBACK, so neither application retains it; the creator-installed check holds them to that. Co-Authored-By: Claude Opus 5.5 <[email protected]>
6 of 9 tasks
trueadm
added a commit
that referenced
this pull request
Oct 28, 2026
… creators (#2257) * perf(octane): install commit, owner and native-read leaves from their creators Applications that never use effects, refs, Effect Events, Activity or Suspense hides, controlled selects, transitions, signals or hydration no longer ship the runtime that serves them: - Effect slots install EFFECT_HOOKS, which gates effect-render retirement, the deletion walk over effect slots and the passive hand-offs. - Every producer of commit-phase callbacks installs COMMIT_WORK: effect slots, Effect Events, commit actions, ref attaches and detaches, and controlled forms. Without it a commit takes its fast path outright, and the capture splice, discard and aborted-ref collection skip those lists. - Renderer signal-owner tests read `signalDocumentEnabled || registerRootOptions` before `renderOwner.signalOwner`: makeRoot is the only owner constructor, and only those two can give a root an owner. - The public owner APIs set a sticky explicitSignalOwners flag. Event authority recording and dispatch test it with the signal binding and document flags, and the renderer re-enters recorded owners through runInSignalOwner, which leaves the flag unwritten, so the cycle that kept them in every bundle folds. - Native-read batches are gated on the engine's batch-hook registration at their call sites; signal promotions on the transition root driver, since the promotion queue resets itself and never folds. - applyRefValue becomes a named function expression; its recursion alone kept it. A fresh-runtime test pins each installer; bundle-size gates assert that the js-framework and chat-stream builds retain none of these declarations while the other Octane builds in the run retain each one. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(octane): install commit work for external-store checks in hidden Activity A store check queued inside a hidden Activity has no accompanying effect slot: enqueueEffect returns before creating one there. As the first commit work a runtime saw, its capture splice skipped the check and left the consumer queued, so after the reveal no later tear check was enqueued. enqueueStoreSync installs COMMIT_WORK itself again. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(bundle-size): gate signalRetryBoundary out of js-framework and chat-stream #2256 now guards discardFrontierBlock's Suspense retry lookup with ROOT_ROLLBACK, so neither application retains it; the creator-installed check holds them to that. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- 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
run.mjs, gzip): js-framework octane-tsrx 28,883 → 26,357 (−8.7%), octane-jsx 53,287 → 50,191; chat-stream 33,135 → 30,495 (−8.0%); todomvc −2,665; weather −2,728; bindings app −3,517; threadline (oxc) −2,719.run-minimal: every journal-free scenario −1.2 to −3.1 kB gzip (hooks-state 21,101 → 19,566; cli-spa-starter 27,083 → 24,734).suspense-transitiongrows +13.9 kB only because its fixture now renders a keyed list, so that the control retains the list journal.render-errorsclient to retaining none of the rollback declarations. Thesuspense-transitioncontrol must retain every one.Why
Every root render opened a transaction and recorded an undo journal (
journalUndo,journalBag,journalObjectOnce,journalForSlot, …) so it could be rolled back.bagDoneand the commit loop passedcarefulwhenever a journal was open, so every render took the careful path. But only some features can drop a render: suspension, a hydration attempt, native-read validation, and a ViewTransition hold. In an app without them a render either commits or goes with its root's teardown, and nothing needs undoing.Changes
Capability. The journal state (
TRANSITION_JOURNAL*,OPS_CHECKPOINT,ROOT_RENDER_ROLLBACK) moves fromrender.ts/engine.tsintodrivers.ts, above every reader, with its only writers there:enterRootJournal/exitRootJournal(frames),openJournalWindow/closeJournalWindow(nested boundary windows), andmarkRootRenderRollback.ROOT_ROLLBACKis a boolean thatinstallRootRollback()sets. Without an installer nothing assigns any of it, so oxc folds every guard. The rule measured in the real bundle: a never-assigned slot folds only in truthiness tests.!== null,> 1and=== 1reads keep their code, so everyTRANSITION_JOURNAL !== nullguard becomes a truthiness test, and depth reads sit behind one.Who installs it.
use, compileduseBatch,Suspense,@try(tryBlock),Hydrate,ViewTransition, renderer regions/* @__PURE__ */ rollbackEntry(impl)in its own modulelazylazy()factoryinstallHydrationDriverhydrateRoot/ hydration startensureNativeReadDriverenableNativeReadCollectionensureViewTransitionDriver__vtSeenmodule hintEach rendering entry's public binding is a pure-annotated
rollbackEntry(impl)call in its own module, so a bundle keeps the call, and installs the rollback as the module loads, exactly when it keeps the entry. Internal callers use the implementation (tryBlockImpl,useImpl), so the runtime's own boundaries don't install it. A call-time install insideuse()would be too late: the firstuse()in an update render would find earlier writes unjournaled. The flag lives insrc/rollback-flag.ts, a leaf module likehydration-flag.ts, so a load-time write never reaches it uninitialized, whatever module order a bundler uses.The generic cases, decided per case.
rollbackRootRenderwithout the journal only discards. It marks the render aborted, drops its ops and hook folds, unmounts what it created, and discards its capture.root.unmount()during a render, and a disposed owner: the root is torn down. Discard.root.renderfrom a commit callback): it never rolled back; the remaining ops are dropped as before.switchToCatch/switchErrorToCatchdrop the body's ops and unmount it, soErrorBoundaryneeds no journal. A frontier flip's local unwind is journal-only: without a journal, the boundary that catches the error, or its root, tears the Block down.Suspension.
handleRenderError's suspense branch, the thrown-thenable conversion inrenderBlockInner, the renderable-hole andChildrenthenable unwraps, the list-row warm retention and the retry-owner producers all readROOT_ROLLBACK.Fixes the split surfaced. The keyed-list clear path and
beginDetachedBoundaryRenderreadTRANSITION_JOURNAL_BAGS!in every root render. They now test the journal first, and the leaf journal writers guard themselves.Divergence (documented in
docs/differences-from-react.md)In a bundle that keeps no entry that can suspend, a thenable thrown during render or rendered as a child is an ordinary render error. The nearest error boundary catches it, or the root unmounts. React suspends on it. Libraries in the ecosystem throw raw promises only when
React.useis missing, and Octane's bindings getuse.Validation
pnpm format:check— CIpnpm typecheck— CI;pnpm typecheck:filesover every changed runtime file passes locallypnpm test— CI (local runs are limited to targeted files on this shared machine); 13 rollback/suspense/transition files, 342 tests pass in--project octanenode benchmarks/bundle-size/run-minimal.mjsandrun.mjs octane-tsrx octane-jsx: pass, base and headrender-errorsexecuted in jsdom gives the same snapshot with the journal installed (control build importinguse). Breaking the list-clear guard fails the gate; breaking the replacement unmount fails the snapshot.node scripts/split-runtime.mjs check: 0 violationsperf-review:node scripts/perf-review-scan.mjs→ no candidates. Hot paths touched:beginRootRender/endRootRender(per root frame),bagRecord/bagDone,slotNext/listNext,reconcileKeyed/updateSurvivor,renderBlockInner, and theevt*handler bundles (per render or bag). Every new check is one truthiness read of adrivers.tsslot, which folds away without the journal. With the journal, a few journal guards now read the slot once more. No hot-record fields were added:RootRenderFrameloses six fields (the journal keeps its own frame stack), andRootRenderTransactionkeeps its fields, withlog/bagsallocated by the first journaled frame.BlockImplis untouched. No new allocation, scheduling hop or DOM work.pair.mjs, 30 pairs: work counters 26 equal, 14 lower (−1/−2 calls per op), none higher; DOM mutations equal. Timing head/base: tsrx update 0.936, select 0.973, swap 0.993, remove 0.978, select_lots 0.969, others 1.000; jsx update 0.928, select 0.900, swap 0.923, remove 0.936, select_lots 0.913, others 0.98–1.0.--base(installs the journal through hydration and native reads; esbuild-minified, so both trees run all their code): work identical (1,653 Blocks, renders and renderBlock entries), client +179 B gzip. 20 pairs: every cold, longest-task and busy row has its interval inside ±3% (frame cold 1.007, live-sections 1.010, plain 1.000, boundaries 0.996). Warm: frame 1.017 [0.998–1.052], plain 1.000, boundaries 1.002. frame-live-sections warm reproduces at 1.035 [1.012–1.054] at 40 pairs, while frame warm reads 1.000 [0.982–1.018] at 40. A CDP profile of 120 warm live-sections hydrations per tree shows no hotspot (self time 3,488 ms head vs 3,543 ms base), and repeated minified passes average +0.9% with mixed signs. Not slower by the ±3% rule, but reported under risk.concise-code: runtime +513 −381, mostly import moves and the mechanical guard conversion. New files:src/rollback-flag.ts(the flag; a leaf module, so entries can set it at load under any bundler), andbenchmarks/bundle-size/render-rollback-gates.mjswith therender-errorsfixture (the gate). Alternatives weighed: (1) call-time install insideuse()and boundary creation: smaller, but the firstuse()in an update render would leave earlier writes unjournaled, so a static install was needed. (2) A compiler-emitted module installer: misses plain.tscallers ofuse. (2b) A separate entries module re-exported fromruntime.ts: the joined single-file runtime harness bundled the runtime twice through it. (3) A separateabortRootRender: it cost every journaled app 235 B raw, so the discard lives inrollbackRootRenderbehind the driver test. Bytes: see Summary; journaled apps +95 to +180 B gzip.Risk / follow-ups
use(Context)-only apps and catch-only@trydirectives install rollback:useandtryBlockare aliased whole. The compiler could routeuse(Context)and catch-only@tryto non-installing entries.signal-owners.tsrenderBlockkeepsisSuspenseException(87 B) behind a runtime-data test. That is the signals session's hunk; noted for it.rollbackRootRender, and the entry aliases.frame-live-sectionswarm hydration reproduces at 1.035 [1.012–1.054]. It sits inside the ±3% rule and has no profiled hotspot, but the median repeated twice; the PR bench report is the next data point.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.Note
Medium Risk
Changes core client render commit/rollback and suspension gating; journal-free bundles diverge from React on thenables, though behavior is gated and covered by new bundle-size and runtime tests.
Overview
Render rollback and client suspension are now opt-in via tree-shaking, instead of every root render always recording an undo journal.
A new
ROOT_ROLLBACKflag (rollback-flag.ts) is set only when a bundle keeps an entry that can drop a render—public APIs likeuse,useBatch,Suspense,@try, andHydratewrap implementations withrollbackEntry, whilelazy, hydration, native-read validation, and ViewTransition callinstallRootRollback. The transition journal and related state move intodrivers.tsand stay unallocated when the flag never flips, so minifiers can strip journal writers, replay, and suspension paths from minimal apps (roughly 2–3 kB gzip on js-framework and chat-stream per the changeset).Runtime behavior without the journal is intentionally leaner: uncaught errors and failed root replacements tear down without replay; thrown or child thenables are ordinary render errors (not Suspense), matching the new docs note vs React. Error boundaries and root teardown still work without the journal.
Validation adds
render-errorsminimal fixture,render-rollback-gates.mjs, and source-map gates so suspense-transition retains rollback symbols while journal-free apps and benchmarks do not.Reviewed by Cursor Bugbot for commit f9dbbb8. Bugbot is set up for automated code reviews on this repo. Configure here.