Repository navigation
perf(octane): install commit, owner and native-read leaves from their creators - #2257
Conversation
… 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]>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website | 8d6cdaa | Commit Preview URL Branch Preview URL |
Oct 28 2026, 09:49 AM |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website-mcp | 8d6cdaa | Commit Preview URL Branch Preview URL |
Oct 28 2026, 09:47 AM |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Hidden stores skip commit work
- Added installCommitWork() at the store-sync drain initialization in useSyncExternalStore's mount path, so COMMIT_WORK is set even when the companion useEffect is skipped in a hidden Activity subtree.
Or push these changes by commenting:
@cursor push 09b67a5972
Preview (09b67a5972)
diff --git a/packages/octane/src/runtime/engine.ts b/packages/octane/src/runtime/engine.ts
--- a/packages/octane/src/runtime/engine.ts
+++ b/packages/octane/src/runtime/engine.ts
@@ -126,6 +126,7 @@
MANUAL_HOOK_DRIVER,
noop,
COMMIT_WORK,
+ installCommitWork,
EFFECT_HOOKS,
} from './drivers.js';
import {
@@ -4589,6 +4590,7 @@
const scope = CURRENT_SCOPE!;
let inst = scope.hooks?.get(subs.inst) as StoreInst<T> | undefined;
if (inst === undefined) {
+ installCommitWork();
drainStoreSyncs = drainQueuedStoreSyncs;
// MOUNT — create the stable cell once (useEffectEvent's mount-once pattern).
// forceUpdate schedules the block directly (identical to a useState setter,You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit fb41716. Configure here.
…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]>
Benchmark report
Compares js-framework: 1k/10k row operationsAll 20 timed operations (20 without a verdict)
Work counters (an increase fails this check):
44 other measured values are unchanged. Application bundle size (bytes)
13 other measured values are unchanged. Public-import reachability bundles (bytes)
33 other measured values are unchanged. |
…d-commit-work # Conflicts: # benchmarks/bundle-size/run.mjs # packages/octane/src/runtime/block.ts # packages/octane/src/runtime/component-slots.ts # packages/octane/src/runtime/engine.ts # packages/octane/src/runtime/hooks.ts # packages/octane/src/runtime/hydration-presentation.ts # packages/octane/src/runtime/refs.ts # packages/octane/src/runtime/render.ts # packages/octane/src/runtime/suspense.ts
…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]>


Summary
Applications that never use effects, refs, Effect Events, Activity or Suspense hides, controlled selects, transitions, signals or hydration no longer ship the commit, capture, signal-owner and native-read code that serves them. Each piece now installs from the API that creates its work, behind a sticky module flag that hot paths test by truthiness, so oxc folds the code away when the installer is tree-shaken (the
drivers.tspattern from #2246 and #2249).Every leaf below was reachable but never executed in Chromium precise coverage of
benchmarks/js-framework/octane-tsrxandbenchmarks/chat-stream/octane-tsrx(main d44d6d9). Its retaining reference was traced through the production bundle's source map before it moved.finishEffectRender, deletion walk over effect slots (runEffectCleanupCallback), passive hand-offs (drainPassiveEffects,cancelPostPaint)effectSlots !== nulland passive queue lengths: runtime dataEFFECT_HOOKS, set byinstallEffectDrivers(the only creator of effect slots)commitEffectsslow path,drainCommitRefs,drainEffectEventCommitActions,finishEffectCommit,placeCommitRefs, the capture splice/discard loops for effects, events, actions, refs and stores, aborted-mount ref collection (collectVisibleSubtreeRefs)COMMIT_WORK, set by effect slots,useEffectEvent,enqueueEffectEventCommitAction(Activity, Suspense reveal, linked state, signal control adoption), the Suspense hide action, ref attach/detach and controlled formsapplyRefValuetakeSignalRetryVisit,runWithBlockSignalOwner,discardSignalRetryItem,clearSignalRetryOwners,retireRendererSignalOwnerrenderOwner?.signalOwner !== undefined: runtime datasignalDocumentEnabled || registerRootOptions:makeRootis the onlyRootRenderOwnerconstructor, and only the signal document or an options root can give it an ownersetEventHandlerowner branch,queueEventOwner,fireEventSlot's owner frame,runWithSignalOwner,currentExplicitSignalOwner),retireUnownedSignalScopesynchronousOwner, whichrunWithSignalOwnerwrites, which dispatch referenced, which recording gatedexplicitSignalOwners, set only by the public owner APIs; the renderer re-enters a recorded owner throughrunInSignalOwner, which leaves it unwrittenbeginNativeEventBatch,closeNativeEventBatch,beginNativeBatch/endNativeBatch/runNativeBatchcallersbeginNativeBatchfolded toreturn null, but folded return values never reach callersnativeBatchHooks(registered once by the signal engine)promotePendingSignalsTRANSITION_ROOT_DRIVER, which installs the pending-signal hostisAdoptionControlbrand checkPUBLISH_SUSPENSE_COMMIT,hydrationStartedDeliberately left in place (reachable from paths every app can take):
drainLayoutUpdates: a commit's DOM writes can dispatch native events synchronously (blur on removal), whose handlers schedule work for the same flush.reportEffectError: commit-phase errors from compiled bag ops route through it.renderCleanupsand nested-capturerenderedBlocksin the capture splice/discard: 14 producers across hydration, signals, Suspense and the cross-rendererscheduleRenderCleanupAPI. A follow-up could funnel them through one installer.isRendererHydrationStyle:hydration-free-gates.mjsdocuments it as a client path.drainHydrationRenderPhaseUpdates: the first mount's render-phase update drain (also documented there).captureRenderPhaseUpdate,blockIsAncestorOf,runEffectLifecycleCallback: generic render-phase updates, tree walks and scope cleanups.Bundle size
node benchmarks/bundle-size/run.mjs octane-tsrx octane-jsxin this checkout and in a main d44d6d9 checkout, same session (client JS, gzip-9; oxc minifier unless noted):js_gzipjs_rawchat_js_gziptodo_js_gzipweather_js_gzipjs_gzipExamples built with Vite's default minifier (
vite build, client JS summed): relay 54,149 → 53,162 (−987), cartlane 97,661 → 97,362 (−299), wayfinder 119,481 → 119,432 (−49), signal-chat 156,798 → 156,996 (+198, +0.13%).After merging main 8f5d432 (#2256, render rollback behind
ROOT_ROLLBACK),run.mjs octane-tsrxagainst an 8f5d432 checkout, same session, gzip: js-framework 26,358 → 24,100 (−2,258, −8.57%), chat-stream 30,497 → 28,293 (−2,204, −7.23%), todomvc −2,230, threadline (oxc) −1,021, weather −939, bindings −228, pagecraft (oxc) −190, wayfinder −60; shell +188, shell_client +71, threadline (esbuild) +175, pagecraft (esbuild) +161. With #2256'sROOT_ROLLBACKguard ondiscardFrontierBlock, chat-stream also dropssignalRetryBoundary, which the gate list now includes.The CI benchmark report on this PR agrees with these rows and adds the public-import reachability scenarios: 81 values shrink (cli-spa-starter −2,085 B gzip, root-static-specialized −2,087, root-static −2,054, root-chained-jsx −2,034); 26 grow: the every-feature hydrating split-shell (+249 gzip), split-shell-runtime (+233), split-shell-signals (+20), the esbuild-minified binding scenarios (+119 to +151), and server-render (+7, the
runWithSignalOwner/runInSignalOwnersplit). Its js-framework work counters are all −7.The growth rows are expected: an application that installs every feature keeps all the gated code plus the gates and installers (about 335 B raw in the shell, the largest piece being the 38 B
runWithSignalOwner/runInSignalOwnersplit), and esbuild never folds a never-written flag, so its rows pay for the gates without the savings.Performance
Same session, base = main d44d6d9 checkout with its own install, alternating base/head.
pair.mjs, 30 pairs, run twice. Work counters (the CI gate): every operation makes 7 fewer production calls in both dialects (e.g. tsrxcalls_update2,975 → 2,968,calls_select76 → 69); DOM mutations identical; all 40 counters identical between the two runs. Wall time, second run: every head/base median within ±3% (tsrx 0.982–1.016, jsx 0.976–1.000). The first run's jsxclear1.202 [1.123, 1.223] did not reproduce (0.994 [0.988, 0.996]); nothing on that path changed beyond three module-flag reads per row.update_nodeps(3 µs, at the timer floor). Its effect/ref counter gate passed on every round for both trees.--quick, 4 alternating rounds via--source-root): Octane rows geomean 1.0157 with log-sd 0.087; the unchanged alien-signals control rows in the same runs: 1.0157, log-sd 0.088, so the drift is run noise.--base, 30 pairs: every paired CI includes 1.0 or lies below it (frame hydrate_cold0.991 [0.981–1.008],frame-plain longest_task_cold0.993 [0.989–0.999]); blocks, renders, renderBlock entries and heap bytes identical. Its esbuild client grows +166 B gzip (frame) and +124 (frame-plain), as above.Hot-path reads are truthiness tests of sticky module flags. The root-owner tests add one flag read to the existing
signalDocumentEnabled ||test, and signal-free apps skip the owner work entirely (setEventHandlerdrops from six reads to three,fireEventSlotskips twoinstanceofchecks and acurrentSignalOwner()call). Three cold or once-per-scope sites combine two to four flags (runScopeCleanupsputsregisterRootOptionsfirst).Validation
pnpm format:check: not run repo-wide;pnpm format:files:checkon every changed file passespnpm typecheck: not run repo-wide;pnpm typecheck:fileson every changed runtime file passes (the new test shares_server-fixture.ts's existing strict-mode errors withdescriptor-host-capability.test.ts)pnpm test: left to CI. Locally:octaneproject over the related suites (Suspense, hydration, signals, forms, portals, view transitions, effects, refs, Activity, signal owners: 255 files, 9,626 tests on the final commit), theoctane-signalsproject (31 files / 421 tests), and the new file inoctaneandoctane-prod(24 tests), all passing. That run caught a missed producer (enqueueEffectEventCommitAction), now installed and covered.commit-callback-capability.test.ts, a fresh runtime per case (layout, insertion and passive effects, callback and object refs, Effect Events, external store, controlled select, Suspense re-suspend hide, Activity hide/reveal, an external store mounted in a hidden Activity then torn during a commit, explicit owner with and without a carrier). All 13 cases also pass on main. Removing each installer fails its case:COMMIT_WORKfrom effects (3 cases),EFFECT_HOOKS(4), ref attach (2), Effect Events, controlled forms, the Suspense hide action, commit actions (Activity), the external-store check,runWithSignalOwner's flag, the carrier's flag (1 each).node benchmarks/bundle-size/run.mjs octane-tsrxpasses with the new gate, and fails with'finishEffectRender'when theEFFECT_HOOKSguard is removed;node benchmarks/bundle-size/run-minimal.mjs(every scenario, including the production behaviour snapshots) passes.pnpm sync: no generated changesperf-review:node scripts/perf-review-scan.mjs→ no candidates. Hot paths touched:renderBlock/renderBlockInner(per render),setEventHandler(per handler bind),fireEventSlot/dispatchDelegated(per event),unmountScope/runScopeCleanups(per scope unmount),commitEffects/commitRootRenders/spliceOffscreenCapture(per commit). No new fields, allocations, closures or scheduling; each change adds sticky module-flag truthiness reads or removes work. Evidence: js-framework work counters (−7 calls per op, DOM equal) and the timing A/Bs above.concise-code: src +312 −152 (runtime +312 −152; about 60 of the added lines re-indent thesetEventHandlerowner block and the capture splice loops under their gates). New file: the fresh-runtime test. New exports:COMMIT_WORK,installCommitWork,EFFECT_HOOKS(drivers),explicitSignalOwners,runInSignalOwner(owner-context), each with callers. Alternatives rejected: one driver object holding the commit slow path (needs the same installers plus an indirect call per commit); a single combined signal flag written fromsignals/(signals cannot assign adrivers.tsbinding, and foldingregisterRootOptionsinto event authority would keep the event-owner code in every createRoot-with-options app); gatingisAdoptionControlat its 16 call sites instead of inside it (24 B residue accepted). The Fragment-ref install was removed as redundant (every FragmentInstance queues a ref attach); the external-store install stays, since a hidden Activity registers no subscription effect (Bugbot, fixed in da2bc18).Risk / follow-ups
COMMIT_WORK; the comment oncommitEffects' fast path and on the flag says so, and the fresh-runtime test pattern shows how to pin it.renderCleanupsproducers (14 sites) could share one installer to drop the remaining capture splice/discard residue (~150 B raw in jsf); follow-up.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.Note
Medium Risk
Changes touch core commit, unmount, event dispatch, and rollback paths behind new flags; regressions would show up as missing effects/refs or wrong signal owner context, though broad test and bundle reachability gates reduce that risk.
Overview
Effect-free, ref-free apps ship a much smaller Octane client runtime by lazy-installing commit phases, offscreen capture splice work, signal-owner retirement, and native-read/event batches only when the APIs that need them run first.
The runtime adds sticky module flags—
COMMIT_WORK,EFFECT_HOOKS,explicitSignalOwners, and guards onTRANSITION_ROOT_DRIVER,hydrationStarted,nativeBatchHooks, and root-owner prefixes—so oxc can drop unreachable bodies when installers never execute. Producers callinstallCommitWork()(effects, refs, Effect Events, uSES, controlled forms, Suspense/Activity commit actions, etc.); signal dispatch splitsrunWithSignalOwnerfrom internalrunInSignalOwnerso renderer-only paths do not pull in the public owner API.Benchmarks and tests lock this in:
run.mjsasserts js-framework and chat-streamoctane-tsrxbuilds retain none of a long list of creator-installed declarations, while feature-heavy Octane targets must still retain each symbol for the source-map oracle;run-minimal.mjsextends effect controls. Newcommit-callback-capability.test.tsruns fresh runtimes per feature to prove each installer still wires behavior correctly.Reviewed by Cursor Bugbot for commit 8d6cdaa. Bugbot is set up for automated code reviews on this repo. Configure here.