Skip to content

perf: specialize compiler-owned split Hydrate templates - #1155

Merged
domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:codex/perf-split-hydrate-templates-20260919
Sep 19, 2026
Merged

domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:codex/perf-split-hydrate-templates-20260919

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Default code-split Hydrate templates without an authored fallback reuse the existing private compiled-child policy in production DOM output. The compiler now carries extraction-owned tag provenance into both the render call and its warm plan, so the public Hydrate dependency no longer retains general returned-value/descriptor rendering for this proven case.

Why

Split extraction generates its own loader and children override. The previous admission check correctly declined authored overrides but also declined these compiler-owned props. Specializing only the render call is insufficient: the generated warm plan independently references public Hydrate.

Changes

  • Certify exact original tag identities on the prepared extraction AST and reuse the existing lexical Hydrate-import proof in both render and warm calls. No runtime or public ABI changes.
  • Retain general rendering for authored fallback including explicit undefined/null, spreads, children/private overrides, shadowed/opaque callers, independent/static boundaries and unsupported modes. Forwarded renderable/signal holes retain their policies.
  • Add public preload/adoption/retry/draft/event/cleanup regressions, frozen-AST/source-map checks and deterministic complete-bundle guards explicitly wired into ci:workflow:test.
  • Add a patch changeset and reproducible paired bundle evidence.

Validation

  • Matched main929 complete esbuild closure: 90,273→63,235 gzip bytes (-27,038, 30.0%); actual Vite split initial entry: 89,744→62,770 (-26,974). Deferred chunk remains separate. Explicit fallback control has identical bundle SHA.
  • All seven existing minimal consumers and 15 public engine/client/SSR/used-signals closures have identical whole-output SHA/raw/gzip/Brotli. The original split={false} deferred fixture remains unchanged.
  • 298 existing Hydrate compiler results, four new compiler artifact tests, 24 public-test results across normal/production projects, and 247 neighboring deferred/frozen-AST/emit results pass (counts overlap).
  • Actual pnpm ci:workflow:test: 212/212 pass, including the new guards.
  • Eight actual Vite ESM/native Chromium production spot-checks (four main/candidate pairs) preserve authentic SSR adoption, trusted activation, IDs, drafts/focus/caret, next updates, pending retirement, fallback/descriptor output and cleanup. Warning/error/pageerror capture starts before navigation and is empty.
  • Four meaningful mutants fail: public warm callee, lost extraction admission, authored fallback admitted, null empty-pending body. Exact source restored.
  • Scoped source/test/TSRX typechecks, changed-file formatting, changeset validation, pnpm sync, and diff checks pass with no unrelated generated changes.
  • Repository-wide pnpm test, pnpm typecheck, and pnpm format:check were not run locally; targeted checks above were used.
  • Current-head full CI pending publication.

Evidence and reproduction: benchmarks/scoped-signals/results/2026-09-19-split-hydrate/report.md and benchmarks/scoped-signals/split-hydrate-size-audit.mjs.

Risk / follow-ups

This is production DOM compiler specialization of an already shipped runtime policy. Compiler-owned AST identity is private and fails closed if rewrites lose it. The real non-null empty pending body and shared preload/strategy/Suspense/error/abort/retry/adoption/transition lifetime remain. No CPU speed claim or budget-cap change; generic returned-value/descriptor graph deletion contributes to the measured savings, and prior engine/SSR tradeoffs remain in main. This does not prove full issue1118 regression recovery or cover arbitrary exported Context/opaque callers. Native checks are bounded spot-checks, not broad browser qualification.

Related to #1118. Adds a CI-wired guard relevant to #1130 §2.1 without claiming its compound checklist is complete.

Full current-head CI and Cursor Bugbot are green for d558849ff371b77e32ffb839f799c97575c7f1a4.

Provenance

  • An agent produced this diff (agent-authored)

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Note

Medium Risk
Compiler-only output specialization on hydration boundaries affects production bundle shape and warm-plan codegen; admission is gated but wrong classification could change hydration or pending behavior.

Overview
Production DOM compilation now routes default code-split Hydrate templates (no authored fallback) through the private __HydrateCompiled path in both the render call and the warm plan, so bundles no longer pull in general public Hydrate child/descriptor rendering for that compiler-owned case. The hydrate-boundaries extraction pass records certified tag identities on the prepared AST; compile.js consumes that set when emitting component and warm-child calls. Authored fallbacks, spreads, overrides, shadowed tags, dev/HMR/server modes, and related cases still use the general route.

Adds a patch changeset, paired bundle audit tooling and evidence (~30% gzip reduction on the matched consumer), CI-wired split-hydrate-boundary guards, compiler AST/source-map tests, and hydration lifecycle regressions. deferred-boundary.test.mjs now expects compiled specialization when split={false} is omitted (default split). Runtime source is unchanged.

Reviewed by Cursor Bugbot for commit d558849. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent perf PR: performance work labels Sep 19, 2026
@domgan-oai
domgan-oai marked this pull request as ready for review September 19, 2026 18:59
@domgan-oai
domgan-oai merged commit 0b48d5d into octanejs:main Sep 19, 2026
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent perf PR: performance work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant