Repository navigation
perf(hydration): keep the binding-marker validator out of client-only bundles - #1637
Merged
Merged
Conversation
… bundles bindSignalText reaches bindingText for every dynamic text hole that may hold a signal handle, and bindingText adopted a binding view's server text range in an inline `hydration !== null && isBlockOpen(...)` branch. That kept isBlockOpen, hydrationMarkerMultiplicity, and the whole dom-binding-protocol validator in apps that never call hydrateRoot. Move the branch into HydrationCapability.adoptBindingText, which only hydrateRoot constructs, so client-only bundles drop it. The body moves unchanged. - run-minimal.mjs asserts that dom-binding-protocol.ts is absent from the non-hydrating renderer scenarios this cleans. - Lower the root-chained-jsx, prop-attributes, and context budgets to bank the saving. - behavior-root.test.ts pins hydration of a binding view's filled and empty text holes in dev and prod. Co-Authored-By: Claude Opus 5.5 <[email protected]>
5 of 6 tasks
Contributor
Benchmark report
Compares js-framework: 1k/10k row operations (ms, lower is better)
All 20 timed operations (19 within noise)
Application bundle size (bytes)
13 other measured values are unchanged. Public-import reachability bundles (bytes)
70 other measured values are unchanged. |
trueadm
marked this pull request as ready for review
October 3, 2026 07:45
This was referenced Oct 3, 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
hydrateRootno longer ship the hydration range-marker validator (dom-binding-protocol.ts, throughisBlockOpen → hydrationMarkerMultiplicity → isBindingOpenComment). Every renderer app with a dynamic{x}text hole that may hold a signal handle paid for it: about −580 to −650 B gzip and −1,597 B raw per app.HydrationCapability.adoptBindingText.bindingTextcalls it throughactiveHydration(), so bundles that never construct the capability drop it. Hydration behavior is unchanged.Why
Review of
85cb387feb..6ea582e37c, finding H1 (P1, size). The compiler emitsbindSignalTextfor ordinary holes, for example… ? htext(...) : bindSignalText(__s, …).bindSignalTextcallsbindingText, whose inlineif (hydration !== null && isBlockOpen(posNode)) { … }branch kept the whole binding-marker prefix and validator reachable. The core-engineering rule puts hydration-only logic inHydrationCapabilitymethods for exactly this reason. #1582 grew the validator with they0–y2check (+24..30 B gzip on every app) and raised theroot-chained-jsxbudget to absorb it. The defect itself is older.#1623 closed the other route, through
mountTry's streamed-boundary check. With both changes, a client-only@tryapp (suspense-transition) also drops the validator.Changes
packages/octane/src/runtime.ts: move the hydrating branch ofbindingTextintoHydrationCapability.adoptBindingText(posNode, text): Text | null, which returns null whenposNodeopens no range. The body moves unchanged.benchmarks/bundle-size/run-minimal.mjs: newmarkerFreeClientScenariosassertion.dom-binding-protocol.tsmust not be emitted forcli-spa-starter,root-chained-jsx,prop-attributes,context,suspense-transition,binding-mantine-hooksorbinding-usehooks-ts. It sits next to the existing per-scenario module assertions, including perf(hydration): keep the streamed-boundary validator out of client-only @try apps #1623'sstreamClaimFreeClientScenarios, becauseverify-reachability.mjsonly receives the built code.benchmarks/bundle-size/minimal-budgets.json:root-chained-jsxis set to ceil32(measured), which recovers feat(islands): renderer-free island activation and islands-only routes #1582's bump and more.prop-attributesandcontextare lowered by the measured saving rounded down to 32, keeping their existing headroom.packages/octane/tests/behavior-root.test.ts: new test, "hydrates a binding view's filled and empty text holes with the ordinary renderer", in dev and prod compile. It pins:octanepatch.Bundle size
node benchmarks/bundle-size/run-minimal.mjs, all scenarios, one run on11a9da935a(main, after #1616, #1619, #1620 and #1623) and one on this branch.The other 23 scenarios are byte-identical, including
capture-only,hooks-state,root-static*,behavior-root-*andbinding-apollo-client-vite. Hydrating bundles pay +74 B raw for the method name and the dispatch.Reachability (
dom-binding-protocol.tsemitted?)event-capture → isRendererStreamBoundaryTemplate → rendererRangeClose)Validation
runtime.ts,node benchmarks/bundle-size/run-minimal.mjs root-chained-jsxfails withREACHABILITY FAIL … a client that never hydrates retained the binding-marker validator(dom-binding-protocol.tslisted). It passes with the fix.node benchmarks/bundle-size/run-minimal.mjs --budgets root-static-local root-chained-jsx hooks-state prop-attributes contextpasses against the re-cut budgets on the rebased branch.suspense-transitionpasses the new assertion. The full suite passes with the assertion in place.adoptBindingTextalways returns null: fails in dev and prod. The server text is duplicated,server labelserver label.<!--]-->in<b>. The existing@tryhydration test stays green here, which is why the new test exists.vitest run --project octane packages/octane/tests/behavior-root.test.ts: 227/227 (on6ea582e37c, before the rebase).vitest run --project octane packages/octane/tests/hydration/independent-island.test.ts: 36/36 (same).pnpm typecheck:files packages/octane/src/runtime.ts: clean. The test file reports only errors that already exist (older lines inbehavior-root.test.tsplus.tsrxfixture noise under plain selection), none in the new test.pnpm format:files:checkon every changed file;pnpm syncleaves no generated changes.pnpm format:check,pnpm typecheck,pnpm test(repo-wide): left to CI.Risk / follow-ups
isBlockOpenstill runs only when a hydration is active.run-minimal.mjsand re-cutroot-chained-jsx/prop-attributes/contextthe same way.bindSignalTextMarkedfor binding-view text would also dropbindingText's presentation path from plain apps. Stubbing that call out bounds the extra saving at −223 B gzip (root-chained-jsx) to −326 B (context), measured with an esbuild probe. It needs a compiler change plus the presentation interceptor that identifiesbindSignalTextby argument position.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Low Risk
Hydration adoption logic is moved unchanged behind a capability method; risk is low with new reachability assertions and a dedicated hydrate test.
Overview
Client-only bundles no longer ship the binding range-marker validator (~580–650 B gzip per app with dynamic
{x}text holes). The hydrating “adopt server text range” path moved out of inlinebindingTextlogic intoHydrationCapability.adoptBindingText, whichbindingTextinvokes only whenactiveHydration()exists (i.e. afterhydrateRoot). Apps that never hydrate can tree-shakedom-binding-protocol.ts; hydration apps pay a small method-dispatch cost.CI adds
markerFreeClientScenariosso bundles for scenarios likeroot-chained-jsx,prop-attributes, andcontextmust not emit that module, and minimal bundle budgets are re-cut to match the measured savings. A new behavior-root test locks in adopting filled and empty binding-view text holes on hydrate, with later updates matching server markup.Reviewed by Cursor Bugbot for commit c4a6052. Bugbot is set up for automated code reviews on this repo. Configure here.