Skip to content

perf: keep native signal transition policy out of ordinary roots - #1139

Merged
domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:codex/perf-lazy-native-transition-driver
Sep 19, 2026
Merged

domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:codex/perf-lazy-native-transition-driver

Conversation

@domgan-oai

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

Copy link
Copy Markdown
Contributor

Summary

Ordinary roots retain the native signal Action queue, preparation, retry, timeout, and publication policy even when the signals model is absent. Move that policy into a coordinator registered by the model and instantiate it when the renderer acquires its first signal Action frame. Keep the renderer's journals, commit wave, and scheduling primitives in their existing owner.

The registration remains live: signals may first load after an async Action awaits, and presentation consumers may receive handles through props without importing signals themselves. No import-name or type-based signal-free proof is introduced.

Refs #1118 and #1130; continues the unused-signals size work in #1135.

Measurements

Matched production bundles against main 330bb0878b42dbc445659c5ea40494067c4ef296, using identical frozen fixtures, lockfile, compiler, and toolchain (Node 24.19.0, Vite 8.1.5, esbuild 0.28.1, Alien 3.2.0). Whole-bundle gzip bytes:

Entry Main This PR Delta
Ordinary root, Vite 62,583 61,598 -985
State hooks, Vite 65,394 64,402 -992
Context, Vite 68,606 67,583 -1,023
Hydration, Vite 81,503 80,485 -1,018
Suspense + transition, Vite 78,571 77,594 -977
Deferred hydration, Vite 93,135 92,103 -1,032
Public createRoot export, esbuild 61,565 60,603 -962
Standalone signals engine, esbuild 12,889 14,480 +1,591
Native signals application, esbuild 78,310 78,887 +577
Signals SSR application, esbuild 31,888 33,468 +1,580
Standalone signals engine, Vite 14,457 16,270 +1,813
Signals SSR application, Vite 35,443 37,282 +1,839

Ordinary SSR stays at 17,728 gzip bytes. The engine remains free of renderer value imports. The new coordinator emits zero bytes in ordinary client closures; the compiled native Action control retains and executes it.

Complete paired audit, source hashes, and reproducible Vite controls.

Validation

The validation commands above ran in ready-for-review CI at cc21ab461, in addition to the local checks below. Draft-only skipped jobs are excluded from this evidence.

  • pnpm format:check (repo-wide, CI)
  • pnpm typecheck (repo-wide, CI, including the new Node-only model program)
  • pnpm test (CI: all four Node 24 shards plus the dedicated browser, React parity, and integration lanes)
  • Owning signals/model/rendering/native collection/unified bindings and hydration tests: 521 passed across 23 test files, including development, production, and Strong modes.
  • Action/transition/Suspense/ref lifecycle checks: 360 passed across 17 test files, including the expanded late-import and surviving-root tests.
  • Real Vite + Chromium native collection tests: 4 passed in development and production.
  • node --test benchmarks/scoped-signals/bundle-boundaries.test.mjs: 18 passed, including ordinary-root emitted-byte guards, a real compiled native Action control, and 100 fixed-source primitive/opaque controls.
  • Publication-discard mutant: the lifecycle tests rejected it with 15 failures across all three modes; restored the exact measured source afterward.
  • Scoped formatting, pnpm sync, changeset validation, and git diff --check.
  • Package build (runtime JS, declarations, compiler, and import verification).
  • Six existing minimal-import fixtures: production builds, semantic controls, and coordinator reachability guards passed; existing ordinary-entry caps remain exceeded.
  • New Node-only model typetest: exact fixture passes main, rejects a renderer-type leak with 2,242 errors, and passes the final neutral generic ports. Wired into pnpm typecheck.

Independent self-review checked rollback, reentrant queues, ref publication, pending boundary timeouts, urgent writes, and disposal. The moved policy matches the previous implementation after translating renderer ports.

Remaining regression against the original integration baseline

A second matched audit compares the exact parent of #1069, 1ed5d2ab9c6291b734a70a102c78b25c8bcdb3d1, its squash 5ead1ff2c, and this PR at cc21ab461. The baseline already includes the earlier scoped signals, ViewTransition and native styles. These are reconstructions using the same current installed lockfile/toolchain and byte-identical authored fixtures, rather than historical-lock builds. All 26 production semantic executions pass.

No-signals consumer Pre-#1069 gzip This PR gzip Remaining delta
Static root 54,306 61,598 +7,292 / 13.43%
State hooks 57,211 64,402 +7,191 / 12.57%
Context 57,492 67,583 +10,091 / 17.55%
Hydration 69,639 80,485 +10,846 / 15.57%
Suspense + transition 67,599 77,594 +9,995 / 14.79%
Deferred hydration 80,206 92,103 +11,897 / 14.83%

The original regression in #1130 is therefore still substantial. This PR's approximately 1 KB gzip saving against current main is a partial reduction, not recovery to the pre-integration baseline. A diagnostic using the parent compiler on both runtimes still leaves 10.64–13.43% growth; current compiler helper selection accounts for a further 2,242–2,902 gzip bytes in four scenarios. The older compiler is only an attribution control because it lacks the new automatic opaque-handle binding contract.

Risk / follow-ups

This is a focused ordinary-client reduction. Both bundlers retain the graph's live coordinator registration in standalone signals and signal-using SSR bundles, producing the size increases above. Removing the registration with a PURE annotation also removes required activation from combined bundles; moving it solely to native collection would break props-only and post-await model Actions.

Native Action preparation now calls renderer primitives through one coordinator host table created on first use. A warmed synchronous happy-dom smoke checked 96,000 Actions with correct publication and stable identities: median 44.66 ms on main versus 45.04 ms here, with overlapping timing ranges. Browser CPU and SSR throughput were not measured; no speed improvement is claimed. The full reported unused-signals regression remains open, and the existing ordinary-entry budgets are already exceeded on main. This PR leaves those budgets unchanged and reports matched deltas separately from budget compliance.

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
Refactors transition commit/rollback and suspense timeout paths behind lazy coordinator wiring; behavior is intended to match prior logic but touches core rendering and native signal Actions.

Overview
Moves native signal transition orchestration (queue, preparation, retry, publication) out of the ordinary client renderer into a new transition-coordinator module registered by the signals model. The renderer keeps thin delegates and lazily constructs the coordinator on the first signal Action frame, with renderer hooks passed through a neutral runtime port table.

Ordinary createRoot bundles no longer emit transition candidate/action/coordinator code (~1 kB gzip in audited fixtures); standalone signals and signal SSR closures retain the coordinator and grow accordingly. Bundle-boundary and minimal-import guards now include transition-coordinator.ts.

Lifecycle coverage expands for late signal import after an async Action, nested startTransition staged reads, and props consumers surviving peer root unmount. CI adds a Node-only signals engine typetest without DOM/renderer types.

Reviewed by Cursor Bugbot for commit cc21ab4. 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 18, 2026
@domgan-oai
domgan-oai marked this pull request as ready for review September 18, 2026 23:38
@domgan-oai
domgan-oai merged commit 873f4d2 into octanejs:main Sep 19, 2026
52 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