Skip to content

perf: omit control writers from ordinary text and attribute bindings - #1141

Merged
domgan-oai merged 3 commits into
octanejs:mainfrom
openai-oss-forks:codex/perf-split-signal-binding-writers
Sep 19, 2026
Merged

domgan-oai merged 3 commits into
octanejs:mainfrom
openai-oss-forks:codex/perf-split-signal-binding-writers

Conversation

@domgan-oai

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

Copy link
Copy Markdown
Contributor

Summary

A normal compiled text or attribute binding retains the shared value/checked writer and control-adoption machinery even when the application does not use signals or form controls. Split the shared writer policies so the bundler can omit those unselected control paths. Text/attribute subscriptions and cleanup remain shared; the public compiler-helper ABI stays unchanged.

Each binding replaces its existing kind field with a shared policy reference, without a new per-binding allocation. Scalar writers preserve their cache tokens, and bound text retains its adopted Text node across documents. Value/checked policies retain native edits, hydration adoption, pending retries and controlled textarea behavior.

Refs #1130 (section 2.1), #1118. This is a partial correction of the unused-signals size regression.

Matched production bundles

Fresh upstream 330bb087, the same authored fixtures, lockfile, Node 24.19.0, esbuild 0.28.1 and Vite 8.1.5 were used for both candidates. All 22 final public bundles reproduce identical hashes and sizes on a repeat build.

Consumer Gzip delta
Ordinary context -1,448 B
Ordinary hydration -1,408 B
Ordinary Suspense/transition -1,400 B
Ordinary deferred hydration -836 B
Ordinary static root, hooks and createRoot export 0
Standalone engine, SSR and used-control SSR 0
Fully used mixed text/input/checkbox/select/textarea client +133 B
Native client +1 B

The compiled plain/control benchmark changes from 80,959/81,321 gzip bytes to 79,770/81,446. It executes both bundled consumers and checks live updates, host/Text identity, native control values and teardown; the original runtime fails the deletion guard.

Validation

  • 452 owning hydration/control tests in development and production, plus 297 signals tests across development, production and Strong compilation.
  • 39 Chromium composition/presentation/native-collection tests and 19 deterministic bundle guards.
  • Package tsgo, scoped file types, scoped formatting, changeset checks and git diff --check.
  • Wrong checked-policy mutant fails all 16 new public cases; after exact restoration, all 34 focused cases pass, including cross-document hydration.
  • Final pnpm sync leaves no generated changes.
  • pnpm format:check (repo-wide CI)
  • pnpm typecheck (repo-wide CI)
  • pnpm test (repo-wide CI)

Local validation was scoped. All 26 jobs in previous-head CI passed at 2826abbe after one same-head failed-job rerun. The initial WebKit fetched-history case timed out at its cached-revision locator; the exact local production case and the unchanged-head CI rerun passed. No source workaround or test relaxation was made; a root cause for that transient failure is not established. Bugbot passed with no actionable threads. Superseded draft checks are not counted as validation.

Risk / follow-ups

Writer dispatch gains one shared-policy indirection. A matched 2,000-row, 80-update workload with 10 warmups and 30 alternating pairs preserves output, identity and drained cleanup. Live update ratio median was 1.031 with IQR 0.903–1.118; no speed improvement or consistent timing regression is established. Browser layout/paint and broad application performance were not measured.

The fully used control client costs 133 gzip bytes, while engine/SSR remain byte-identical. The original pre-#1069 unused-signals regression remains open; this PR does not claim full recovery.

Main integration (2026-09-19)

Merged current main 873f4d2049 without rewriting published history. Signed two-parent merge head: fdec76b6be. Retains the landed context API removal, same-file root/hydration specialization and native transition extraction.

Local merge validation: 372 public development/production results, 111 signal binding/hydration results across development, production and Strong, 88 development/production transition results, and 22 bundle guards passed; effective scoped types, formatting and final sync passed. The initial concurrent run timed out only the cold-module hydration case; both instances and the complete serial repeat pass with the unchanged five-second timeout. No timeout or assertion was changed.

Full previous-integration CI passed all 26 jobs; Bugbot succeeded with no unresolved review threads.

The first main-integration run failed the TanStack Query SSR error case with a missing QueryClient context before client hydration. The owning server/compiler inputs match main, the exact case passed on main, and the unchanged focused three-case suite passes locally. One failed-job rerun was used without changing source, assertions or timeouts; the initial cause is not established.

Main refresh (2026-09-19, second pass)

Merged current main 68a669007b without rewriting published history. Signed two-parent merge head: 9f7cfcdabc. Preserves the landed scalar style, imported/local root and native-event authority changes alongside this PR's writer policies. The sole manual conflict was in the shared bundle guards; main's complete file and this PR's complete writer-control test are both retained.

Local refresh validation: 588 public development/production results covering bindings, hydration, event ownership, transitions and local roots; 165 signal binding/hydration/action results across development, production and Strong; and 23 bundle guards passed. Scoped types, formatting and final sync passed. No source workaround, bundle cap, assertion or test timeout was changed.

The initial refresh run failed the TanStack Query SSR error case with a missing QueryClient context before client hydration. The owning server/compiler/fixture inputs match current main, where the exact case passes, and the unchanged focused three-case suite passes locally with the default timeout. One unchanged-head failed-job rerun was used. No source, assertion or timeout change was made; the initial cause remains unconfirmed.

Full current-head CI passed all 26 jobs; Bugbot succeeded with no unresolved review threads. The PR is open and ready for human review.

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
Touches the hot direct-signal binding path in runtime.ts, but behavior is heavily regression-tested; writer dispatch adds one policy indirection with no intended semantic change.

Overview
Splits direct signal binding dispatch into shared policy objects so text and attribute bindings no longer pull form-control writers and hydration adoption into production bundles, while value/checked bindings keep the full control path.

Bindings now reference a DirectSignalBindingPolicy (with writeBinding, write, and optional control) instead of a bare kind string. Scalar caches, subscriptions, and the public bindSignal* compiler helpers stay the same; writer logic is factored into dedicated helpers like writeDirectSignalAttribute and writeDirectSignalText.

A bundle-boundaries test compares gzip size and live DOM behavior for plain text/attribute-only apps vs apps with inputs/checkbox/select/textarea. Hydration tests cover mixed channels (dev/prod, tsx/tsrx, strong, hydrate) and cross-document adopted text nodes.

Reviewed by Cursor Bugbot for commit fdec76b. 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 00:20
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