Repository navigation
perf(octane): stop shipping Suspense in hydrating bundles without Suspense - #1803
Conversation
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)
54 other measured values are unchanged. Public-import reachability bundles (bytes)
99 other measured values are unchanged. |
|
This now conflicts with
Passing the four functions as parameters from
After that:
Also note that #1792 (bench sizes measured with Vite 8's default minifier) is about to re-cut every budget, so measure after it lands. |
#1784 rewrote renderInitialSuspenseHydration, and hydration now reaches the boundary machinery from more places: the dehydrated-boundary fallback (clientRenderDehydratedTry -> renderDehydratedTry -> mountTry) and two HydrationCapability sites (adoptServerCatch, fallBackServerCatch). Re-apply this branch's goal on top: tryBlock, which alone creates a TrySlot, installs a TRY_OPS table once hydration has started, and every hydration-side caller goes through it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
hydrate-root's budget drops from 166,889 raw / 52,659 gzip to 137,746 raw / 44,082 gzip (-29,143 / -8,577) now that hydrating bundles without a Suspense or @Try boundary no longer ship the boundary machinery. Values are min(main, measured + headroom); deferred-hydration, which renders a boundary, pays for the indirection and is raised in a separate budget-only pull request. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… overage (#1811) - deferred-hydration (raw 230,846 -> 230,980, gzip 72,314 -> 72,387): #1803 routes hydration's boundary operations through a table that tryBlock installs, so hydrating bundles without Suspense drop about 8.6 kB gzip. A hydrating bundle that renders a boundary pays for the indirection. - todo framework/total raw (+43 each): main already measures 115,067 raw against a 115,056 budget. #1808, merged after #1792 re-derived the budgets under oxc, adds a few bytes to input-handling paths. #1803 does not change todo; the framework gzip is identical with either runtime. Values are measured + 32. Co-authored-by: Claude Opus 5.5 <[email protected]>
…on-reachability # Conflicts: # benchmarks/bundle-size/minimal-budgets.json
|
I took this over at the maintainer's request and reworked it on top of #1784 (adbdd29). The goal is the same, but hydration now reaches the boundary operations through a 🤖 Addressed by Claude Code |
Take #1811's budgets: its todo raw raise matches this branch's measurement, and its deferred-hydration row is kept as main has it so #1803 still fits. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Take main's budgets after #1803. Re-recording with this branch's runtime ratchets every value to main's (#1803 already cut them to measured + headroom), and deferred-hydration keeps main's row. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
hydrateRootbundles no longer ship the Suspense boundary machinery unless the application renders a Suspense /@tryboundary. The minimalhydrate-rootscenario drops from 54,277 to 45,357 B gzip (−8,920, −16%).Why
HydrationCapabilityconstructor installsrenderInitialSuspenseHydrationso that client-only Suspense does not ship the hydrator. That function, however, callsmountTry,switchToCatch,createTryBodyandsetTryBranchdirectly, so every hydrating bundle retained them and everything they reach (hidden reveal, Activity hiding, catch switching, pending arms): about 30 kB raw.tryBlocknow passes those four operations to the hydrator at its only call site. The hydrator is still installed by the capability, so neither direction regresses: client-only Suspense does not gain the hydrator (run-minimal.mjsreachability gate holds), and hydration without Suspense no longer gains Suspense.Bytes (
run-minimal.mjs, committed budgets vsorigin/main8aeb6c0e5)hydrate-rootdeferred-hydrationsuspense-transition(client-only)root-static,cli-spa-starterWith #1792's
minify: 'oxc'the same change takeshydrate-rootfrom 51,707 to 43,249 B gzip. No budget raised (budget-raises.mjs --base origin/main).Alternatives measured and rejected: making the hydrator call the four functions directly and having the capability set a flag, or routing through a capability method, either kept the hydrator in client-only Suspense bundles (+870 B gzip on
suspense-transition, and the reachability gate fails) or kept Suspense in hydrating bundles. Passing an ops object instead of positional arguments cost about 40 B more on Suspense bundles.Changes
packages/octane/src/runtime.ts:renderInitialSuspenseHydrationtakescreateTryBody,setTryBranch,mountTryandswitchToCatchas parameters;tryBlockpasses them.--write-budgets; changeset added.Validation
pnpm typecheck:files packages/octane/src/runtime.tspnpm vitest run --project octane --project octane-prod: 42,039 passed, 1 failed (behavior-roottextarea retirement, the same full-suite load flake as on main; 293/293 in isolation).switchToCatchfails 10 tests in the Suspense/try hydration files; breakingmountTryfails 18 inunclosed-rangeandmarkerless-arm-retry; skipping the hydrator fails 56 across the Suspense hydration files. No new test was needed: behavior is unchanged and existing tests pin every routed call.run-minimal.mjs --budgets,run.mjs --budgets octane-tsrx octane-jsx,budget-raises.mjs --base origin/mainpnpm sync,pnpm format:files:checkpnpm test(left to CI)Risk / follow-ups
deferred-hydration, +12 B gzip on the whole-API ceiling, and −8 B gzip onsuspense-transition, all within budget.HydrationCapability(27.7 kB raw) in full. Per-site recovery inside it is being deleted by fix(octane): handle hydration mismatches like React 19 (boundary/root client-render fallback) #1784.Rework on top of #1784 (2026-10-06)
#1784 (the React 19 hydration fallback) rewrote
renderInitialSuspenseHydration. Hydration now reaches the boundary machinery from more places than the original parameter passing covered: the dehydrated-boundary fallback (clientRenderDehydratedTry→renderDehydratedTry→mountTry), andHydrationCapability.adoptServerCatch/fallBackServerCatch.The goal is the same, with a different mechanism.
tryBlock, the only place aTrySlotis created, installs aTRY_OPStable (createTryBody,setTryBranch,mountTry,switchToCatch) oncehydrationStartedis set, and every hydration-side caller goes through it. The guard folds out ofcreateRootbundles, so they are unchanged; the todo app's framework gzip is identical with or without this change.Current numbers (oxc, after #1792):
hydrate-root(esbuild probe)hydrate-rootbudget (run-minimal, oxc)deferred-hydration(renders a boundary)The
deferred-hydrationraise landed separately in budget-only #1811. Every other budget is min(main, measured + headroom).Validation on the merged head:
octane+octane-prod: 42,490 tests pass.run-minimal --budgets,run.mjs --budgets octane-tsrx octane-jsxandrun-hydration-free.mjspass.budget-raises.mjs: no raise.Provenance
agent-authored)Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Touches core hydration and Suspense/try routing in
runtime.tswith no intended behavior change; regressions would show up as hydration or boundary mismatches rather than compile failures.Overview
Hydrating clients that never render Suspense or
@tryno longer pull in Suspense boundary machinery (mountTry, catch switching, Activity/hidden-reveal paths). The minimalhydrate-rootbudget drops by roughly 9 kB gzip (~16%).In
runtime.ts, hydration paths that used to callcreateTryBody,setTryBranch,mountTry, andswitchToCatchdirectly now go through a lazyTRY_OPStable.tryBlock—the only place that creates aTrySlot—installs those four functions once hydration has started, so plainhydrateRoottrees never statically reference that code. Behavior is intended to be unchanged when a boundary is actually rendered;deferred-hydrationand client-only Suspense scenarios stay within existing reachability gates.Bundle-size budget JSON files and an octane patch changeset reflect the new measurements.
Reviewed by Cursor Bugbot for commit adbdd29. Bugbot is set up for automated code reviews on this repo. Configure here.