Repository navigation
perf(octane): move the hydration-only HydrationCapability methods to module functions (#2028) - #2082
Merged
Merged
Conversation
…module functions (#2028) A method's name ships in every bundle that keeps it, since no minifier mangles property names; a module function's is mangled. Every method that no client-only code calls becomes a function of the capability, `name(h, …)`, declared after the class: 21 of the 75. Client-only code is measured, not assumed: an esbuild bundle of every runtime export but Hydrate and the hydrateRoot entry points keeps no HydrationCapability, and the TypeScript references of each method, resolved through its type, place every caller of these 21 outside that bundle. The other 54, called from childSlot, componentSlotLite, the branch, list and try blocks, the host writers or useThenable, stay methods: esbuild never folds `hydrating`, so a function named there would ship in client-only bundles, where a method leaves with its class. holds and awaitsCommit stay too, called through HYDRATION_PASS?.; parseSeeds was parseSeedJson, which its callers now call, and the diagnostic holds take no capability. failure becomes hydrationFailure, as a local of that name shadows it at a caller. The fields the functions read lose `private`. The hydration-free gate lists the 21 functions with the class, so a createRoot bundle that maps into any of them fails it. shell_ full and base_hydrate shrink 634 B raw (84 to 102 B gzip), and hydrateRoot bundles 634 to 803 B raw (107 to 239 B gzip). Every Vite and esbuild createRoot row is byte-identical in raw size. Cold hydration pairs flat against the previous step. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
October 15, 2026 12:27
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website | ad47772 | Commit Preview URL Branch Preview URL |
Oct 15 2026, 12:46 PM |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website-mcp | ad47772 | Commit Preview URL Branch Preview URL |
Oct 15 2026, 12:45 PM |
Contributor
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)
76 other measured values are unchanged. Public-import reachability bundles (bytes)
102 other measured values are unchanged. |
…e render-write ledger (#2028) adoptText moved from a HydrationCapability method to a module function, so the writer ledger's 'HydrationCapability.adoptText' entry no longer matched it and check-render-writes reported its nodeValue write as unclassified. 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
HydrationCapabilitymethods that no client-only code calls to module functionsname(h, …), declared right after the class. Hydrating bundles shrink about 0.6–0.8 kB raw; every createRoot bundle keeps its exact raw size.next.Why
hydrating, so a function called from code a client-only bundle keeps would ship in that bundle, where a method leaves with its class. So only methods with no client-reachable caller can move.Changes
Hydrate,__HydrateCompiled,hydrateRoot,__hydrateVoidRoot,createIndependentHydrateActivator) keeps noHydrationCapability. TypeScript's language service resolves every reference to each method through its type, and the callers of these 21 all lie outside that bundle:passSeeds, discardSeeds, holdDiagnostics, releaseDiagnostics, cursorIn, rendersAgain, fragmentRoots, adoptOrDefer, defer, claimDeferred, takeDeferred, hydrationFailure, thrownWhileAdopting, adopt, skipForeign, claimRoots, unclaimedText, framedContent, renderBeforeMismatch, adoptText, settleTexts.
holdsandawaitsCommitstay too, because they're called throughHYDRATION_PASS?..parseSeedsonly wrappedparseSeedJson, which its two callers now call directly.holdDiagnosticsandreleaseDiagnosticstake no capability.failurebecomeshydrationFailure, because a local of that name shadows it at one caller.private, which is TypeScript-only.benchmarks/bundle-size/hydration-free-gates.mjslists the 21 functions next to the class, so a createRoot bundle that maps into any of them fails the hydration-free gate.Validation
pnpm typecheckpnpm format:check: not run repo-wide;pnpm format:files:checkon both changed files passes.pnpm test: not run repo-wide. The fulloctane,octane-prod,octane-signals,octane-signals-prodandoctane-signals-strongfamily ran with the render-write guard:run-hydration-freeon Rolldown and esbuild passes, andhydration-free-gates.test.mjspasses 11/11.Survivor check: none of the 21 appears in the class-free all-exports esbuild bundle above (2,106 names, no class).
Hydration probe audit (
scripts/hydration-probe-audit.mjs): every family 0/0 except roots, 104/104.app-frame-hydration, 20 pairs againstnext: cold head/base 0.999, 0.990, 0.995 and 0.986 for frame, live-sections, plain and boundaries.Bytes against
next:perf-review:node scripts/perf-review-scan.mjs --diffon this diff finds no candidates. No hot-path changes:concise-code: src +496 −492 in runtime.ts (a move), plus 23 gate lines.Risk / follow-ups
next, so this PR targetsnext.refactor/runtime-split-tool) needs to reruncheck --suggestto place the 21 new top-level functions in itshydrationmodule.Provenance
agent-authored)Need help on this PR? Tag
@codesmith-botwith what you need.Note
Low Risk
Behavior-neutral structural refactor on hydration-only paths; createRoot bundle size and runtime semantics are intended to stay the same per validation in the PR.
Overview
Twenty-one hydration-only
HydrationCapabilitymethods become module-level functions (passSeeds,adopt,settleTexts,hydrationFailure, etc.) that take the capability as their first argument. Call sites switch fromhydration.foo()tofoo(hydration, …);parseSeedsis dropped in favor of directparseSeedJsoncalls. Several class fields loseprivateso those helpers can read pass state. This is a move-only refactor aimed at smaller hydrate bundles (mangleable function names vs fixed method names); createRoot bundles are unchanged.The hydration-free bundle gate now lists all 21 top-level functions so a client-only build cannot accidentally retain them.
render-writers.mjstracksadoptTextas a top-level writer instead ofHydrationCapability.adoptText.Reviewed by Cursor Bugbot for commit ad47772. Bugbot is set up for automated code reviews on this repo. Configure here.