Repository navigation
perf(hydration): measure shell overhead, retain server ranges and opt in native seeds - #2033
Merged
domgan-oai merged 2 commits intoOct 13, 2026
Merged
Conversation
…ptional signal seeds
domgan-oai
marked this pull request as ready for review
October 13, 2026 10:24
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)
64 other measured values are unchanged. Public-import reachability bundles (bytes)
92 other measured values are unchanged. |
This was referenced Oct 13, 2026
1 task done
This was referenced Oct 13, 2026
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
Hydrating the production shell currently costs 23,280 B gzip beyond its createRoot twin. This implements the measurement and first safe reductions for #2028: add reported-only shell_client_ twins, opt in native seed materialization/early capture only for signal hydration, retain adopted server anchors rather than walking and rewriting the complete owner tree after hydration, and share marker parsing with streaming.
This PR does not close #2028. It reduces the Oxc shell hydration increment to 21,260 B, still above the ~5 kB goal. It covers measurement, signal ownership, and post-hydration compaction removal. Range lending/remainders, per-value mismatch settlement, the separate boundary retry machinery, and HydrationCapability removal remain necessary further steps. No @Try semantics are changed here.
The subsequent issue breakdown confirms full marker unification must precede the capability collapse, and boundary retries should follow #2029. Retaining adopted anchors alone does not remove the current framed/unframed/lent adoption distinctions.
React 19.3 controls remain unchanged (Oxc 65 B total increment). Oxc wins 2,020 B total; esbuild hydrate wins 1,706 B but its createRoot bundle grows 75 B. Measurements use the same shell fixture, Vite config, and exact base runtime snapshot d37bd28, with provenance assertions for the base modules.
Decisions: retain SSR's explicit anchors (option B); keep liteRanges because suspended replay still reads them; keep generic immutable initialDocumentSignals snapshot before an engine import. Signals register availability in the renderer-free protocol; only hydrating runtime paths activate the native parser and early capture bridge, before or after a signal module loads. This keeps Node-only engine consumers DOM-free and tiny scalar and createRoot consumers free of hydration setup. Late retry validation is inside the root transaction and all late/deferred seed materialization validates the root's expected document scope. Positional use() seed decoding is independent of native signals.
Validation
pnpm typecheckpassed in CI at 4c3c715, including strict Three and no-DOM engine consumers. Scoped core typecheck also passed locally.run-hydration-free.mjspasses all 14 client-only scenarios and three positive controls, including createRoot-signals esbuild and Vite.hydrate-rootandhydrate-framegates pass.node --test benchmarks/pr-report.test.mjs benchmarks/size-review.test.mjs scripts/bundle-size-workflow.test.mjs: 35/35.node benchmarks/bundle-size/run.mjs octane-jsx, matched Octane/React shell builds (Oxc and esbuild);node benchmarks/bundle-size/run-minimal.mjs hydrate-root hydrate-frame.node benchmarks/hydration-range-compaction/run.mjs 5: 64/512 wrappers pass adopted leaf, live click, server anchor retention, full unmount. Comment counts are kept in this benchmark, outside consumer tests.node benchmarks/app-frame-hydration/run.mjs 10 --base=<exact-base-snapshot>: real Chromium 4x CPU, 1,156 elements adopted and 1,653 blocks/renders unchanged in both scenarios; cold head/base ratios 0.836 (95% 0.816–0.860) frame and 0.870 (0.819–0.905) live sections. Warm 0.761/0.756. Jitless production calls down 61,092 in each. Same SSR bytes, live signals/events, clean unmount.pnpm sync: ran immediately before publication and included all resulting changes. Generation through bindings, package inventory and parity lockfiles reports current; remaining sync is blocked on importing svelte/compiler in the repository's Prettier config. Frozen install with registry failed on locked legacy-javascript metadata and Svelte 5.57.2 HTTP 403. No lockfile/security configuration changes were made. Validate in CI with a complete install.Risk / follow-ups
Current-head CI and benchmarks are green. Full local sync remains incomplete as described above; it still needs a machine with the locked Svelte dependency. Additional explicit server comments are retained; their memory cost is offset by removal of the compaction graph in the measured frame. Legacy counted pairs are still accepted for existing binding/stream protocols. Changeset is patch because the public API and hydration contracts are unchanged. This is an initial measured part of #2028, not the complete architecture rewrite.
Related open PRs: #2035 separately removes server-only signal seed serialization from client bundles. Both edit signals/engine.ts, signals/native-read-seeds.ts and signals/read-protocol.ts, so integrate those edits and rerun the signal/bundle suites if it lands first. #2032 adds a multi-chunk Rolldown shell to run-minimal; this PR adds matched hydrateRoot/createRoot twins to run.mjs. They share only benchmarks/README.md and answer different measurement questions.
Provenance
agent-authored)Origin: Codex task · host
com-79386.Need help on this PR? Tag
@codesmith-botwith what you need.Note
Medium Risk
Core hydration and native-signal adoption paths changed (range retention replaces compaction), though the public API is unchanged and behavior is heavily regression-tested.
Overview
Hydration no longer runs a post-pass that merged nested server range markers — the large
coalesceHydratedRangespath,hasAdjacentRangePair, and end-of-hydrationcoalesce()calls are removed. Adopted SSR comment pairs and their runtime owners stay in place through hydration and updates.Native signal seed work is opt-in via the signals module:
nativeSignalHydrationflips on when the engine loads;ownNativeAdoptioncan defer manifest parsing until then;initialDocumentSignalssnapshots when signals are absent. Root hydration wires early signal hydration throughstartEarlySignalHydrationinstead of always materializing native manifests at entry.Benchmarking adds
shell_client_*bundle-size rows (same app shell viacreateRoot+index-client.html) so PRs can report hydrate-minus-client JS overhead; the hydration-range benchmark now asserts retained physical pairs instead of compaction to one pair.Tests drop compaction-count expectations in favor of adopted nodes, edited fields/refs, and clean unmount; marker multiplicity parsing moves to
stream-protocolfor shared streaming/hydration behavior.Reviewed by Cursor Bugbot for commit 4c3c715. Bugbot is set up for automated code reviews on this repo. Configure here.