Repository navigation
perf(runtime): enter each Block's signal owner in place during render - #1857
Merged
Merged
Conversation
Production SSR and cold Chromium hydration of a ~1,940-Block signal-enabled app frame, shaped after a production app-frame hydration audit: small wrapper components, @if arms, @for rows, and forwarded style props, compiled with native reads and the document signal owner. Fresh browser contexts at 4x CPU throttle, warm repeats, jitless call and heap counters, and an optional paired --base=<checkout> comparison. Co-Authored-By: Claude Opus 5.5 <[email protected]>
renderBlock entered a Block's signal owner through a callback frame that re-entered renderBlock, resolving the same owner twice and allocating a closure per render. Enter it in place with the synchronous owner swap the server already uses, installed with the signal document so signal-free apps do not retain it, and restore it when the render returns, throws, or suspends. Host carriers keep the callback frame. Scopes keep their resolved owner in a field instead of a WeakMap. Co-Authored-By: Claude Opus 5.5 <[email protected]>
2 of 5 tasks
trueadm
marked this pull request as ready for review
October 7, 2026 19:52
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website-mcp | 8cde271 | Commit Preview URL Branch Preview URL |
Oct 07 2026, 07:54 PM |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website | 8cde271 | Commit Preview URL Branch Preview URL |
Oct 07 2026, 07:53 PM |
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)
8 other measured values are unchanged. Public-import reachability bundles (bytes)
36 other measured values are unchanged. |
…creating Blocks With unset native styles written without a Block, the frame hydrates about 1,650 Blocks. Refresh the suite's description and the changeset figures, re-measured against main with 50 paired samples. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
added a commit
that referenced
this pull request
Oct 7, 2026
Raise-only budgets for #1857, measured on its head and merged as max(main, measured + 32). Signal-free apps grow about +155 raw / +37 gzip and bundles that can reach the signal capability about +256 raw / +70-111 gzip, for 1.7% faster cold and 3.8% faster warm hydration of a ~1,940-Block signal-enabled app frame. Co-authored-by: Claude Opus 5.5 <[email protected]>
trueadm
added a commit
that referenced
this pull request
Oct 7, 2026
Conflicts: app-budgets.json and minimal-budgets.json. #1858 raised budgets ahead of #1857 (in-place Block signal owners, still open), so take its values in every conflicting row; lowering them here would undo a raise #1857 depends on. That includes hydrate-frame (365,194 raw), which clears the over-budget failure main had. This branch keeps its lower bindings app gzip and one app brotli, rows #1858 left alone. Until #1857 lands, the tight-budget check measures well under the raised rows, so shard 1's "Verify every bundle budget" step is expected to fail here, as on any PR in that window. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brotli shrank by 2-34 bytes in todo, root-chained-jsx, root-callback-local and binding-base-ui-esbuild, so their committed budgets now sit more than 256 bytes above the measurement. Record the new floors; no budget rises. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 7, 2026
The MCP server's benchmark tool mirrors the unified runner's suite list, and its sync test failed once bench.mjs gained app-frame-hydration. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 7, 2026
trueadm
added a commit
that referenced
this pull request
Oct 7, 2026
#1858 raised 65 budgets ahead of #1857 (in-place Block signal owners), which is still open: it is behind main, fails format:check under #1399's formatter, and its own ratchet is off by 2 gzip bytes. Until it lands, every push to main enforces the downward ratchet against those unfilled raises, so main 21f911d (#1399) failed test shard 1/4 at "Verify every bundle budget": cli-spa-starter raw budget 101,976 must ratchet to 101,825. Rewrite every budget with run-minimal.mjs and run.mjs --write-budgets on main 21f911d (measured + 32 raw/gzip, + 256 brotli): 65 lowerings, no raises, the same 65 entries #1858 raised. #1857 re-lands its raise in a budget-only change immediately before it merges. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
added a commit
that referenced
this pull request
Oct 7, 2026
Takes 96c4096, which ratchets the bundle budgets back to main's measurements until #1857 lands. Shard 1 failed "Verify every bundle budget" here (cli-spa-starter raw 101976 against 101793 measured) for the same reason. Measured locally on this branch, every minimal, app and JSX row equals main's new budgets, so nothing else changes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
added a commit
that referenced
this pull request
Oct 7, 2026
…e raise Main 96c4096 lowered hydrate-frame back to 364,918 / 112,855 / 96,725. Recompute the raise from what CI measured for #1862's head (366,032 / 113,311 / 96,797) plus the standard headroom: 366,064 raw, 113,343 gzip and 97,053 brotli. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hain update The new TSRX formatter wraps the app-frame fixture's JSX holes and the owner test's act call; server HTML for both scenarios is byte-identical. The new compiler shrinks five measured values, so their budgets move to the new floors. No budget rises. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ydration-block-entry # Conflicts: # benchmarks/bundle-size/app-budgets.json # benchmarks/bundle-size/minimal-budgets.json
trueadm
added a commit
that referenced
this pull request
Oct 7, 2026
…eads (#1863) Budget-only raise for #1862. That change lets hydration skip rendering a native signal reader again when its live value is unchanged. hydrate-frame, the only minimal scenario that hydrates with native signal reads, grows by +1,146 raw, +488 gzip and +249 brotli. Each value is the current budget plus that delta, so the raise from #1858 for #1857 is kept. Co-authored-by: Claude Opus 5.5 <[email protected]>
3 of 4 tasks
trueadm
added a commit
that referenced
this pull request
Oct 7, 2026
Takes #1857 (in-place Block signal owners). No conflicts, and no lockfile or budget changes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
added a commit
that referenced
this pull request
Oct 7, 2026
With #1857 (in-place Block signal owners) and #1862 (unchanged adoption reads) on main, this branch's hydrate-frame measures 364,278 raw, 112,866 gzip and 96,483 brotli. The budget is that measurement plus headroom: 364,310 / 112,898 / 96,616. That is below main's 366,064 / 113,343 / 97,053, so it lowers rather than raises. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
added a commit
that referenced
this pull request
Oct 7, 2026
#1857 (b6c040c) merged without the budget-only raise that 96c4096 took back while it was pending, so main is over its committed byte budgets again. This restores that raise as measured on main b6c040c with run-minimal.mjs and run.mjs --write-budgets (measured + 32 raw/gzip, + 256 brotli): 61 raises and 4 brotli lowerings, budget files only. - cli-spa-starter raw 101,825 -> 101,976 (+151), the same value #1858 set - signal-free roots and apps about +151 to +168 raw, +37 to +58 gzip - signal-capable bundles (root-static, bindings, Base UI, Radix, Apollo) about +255 to +312 raw, +70 to +115 gzip - brotli lowered 2 to 34 bytes on four rows the owner frame shrank Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
added a commit
that referenced
this pull request
Oct 7, 2026
Takes 31724a3, which re-lands the in-place Block signal owner budgets now that #1857 is on main. Shard 1 failed with cli-spa-starter at 101,944 raw bytes against the walked-back 101,825; the re-landed budget is 101,976. No conflicts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 7, 2026
domgan-oai
pushed a commit
that referenced
this pull request
Oct 7, 2026
…1869) Budget-only raise, landing ahead of #1861 per CONTRIBUTING "Size budgets". main 43b60d9 measures deferred-hydration at exactly its 69,610 gzip budget (#1857 and #1859 filled the headroom). #1861 stops development hydration reporting an empty style attribute that an early binding left behind, and measures 69,612 gzip there (-14 raw, +2 gzip). 69,642 is main's measured + 32, the highest value the ratchet accepts against main, so no other pull request fails the ratchet while #1861 is open. Co-authored-by: Claude Opus 5.5 <[email protected]>
domgan-oai
pushed a commit
that referenced
this pull request
Oct 7, 2026
…#1851) * perf(signals): install the public Scope surface only from createScope Owner scopes that the runtime creates for compiled signal declarations never reach application code, yet every signal application shipped the whole public Scope implementation: serialization, inspection, trace recording and the imperative derived$/get/set/isPending/batch/action methods. ScopeImpl keeps one class shape. createScope installs the public-only methods on its prototype the first time it runs, and only a debug scope installs trace recording. The server's native-read driver installs the read serializer, so clients never ship it. beginAdoption stays a method: hydration resolves it through the owner, and importing the engine from the hydration path would pull the engine into applications without signals. An internal OwnerScope type omits the installed members, so internal code that reaches for one fails to typecheck. Signal applications are 871 to 1,118 B smaller gzipped; applications without signals are byte-identical. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(signals): keep native-read serialization off the server's import path The server's native-read driver imported the engine to install the read serializer. That loaded the engine, and its top-level batch-hook registration, on every server render, including applications without signals, and Node's strip-only TypeScript loader rejects the engine's parameter property (register-hook direct server scripts failed). serializeRead is a ScopeImpl method again, reached through the owner as on main, so the server path and graph.ts match main. The server-render budget returns to main's value. Signal applications are now 489 to 652 B smaller gzipped; applications without signals stay byte-identical. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(hydration): read local scope state without the public inspect() native-deferred-local-hook-diagnostics reached through a useSignal$ handle's internal owner and called inspect(). Runtime-created scopes no longer carry the public Scope surface unless the program calls createScope, and these cases never do. Read the adoption leases and node count that inspect() reported from the scope directly. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(signals): hand out whole Scopes from the public owner routes Runtime-created owner scopes reach application code: derived$ and query$ run authored callbacks under them, so the public currentSignalOwner() returns one, and a host SignalOwnerEnvironment carries them. Both are typed SignalOwner, which narrows to Scope, but without an earlier createScope the scope lacked inspect(), get() and the other installed methods. currentSignalOwner and installSignalOwnerEnvironment exported from octane/signals now install the public Scope methods before an owner can escape; the runtime keeps owner-context's engine-free versions. octane/server's carrier must stay engine-free, so SignalOwnerEnvironment now carries owners as SignalOwnerIdentity values: a carrier stores and returns them but cannot narrow them to Scope. Carriers that store SignalOwner values compile unchanged. bundle-boundaries builds each route in its own program without createScope (the review's currentSignalOwner probe and a carrier that calls the owner it carries); both fail with "inspect is not a function" without this change. A type test pins the identity-typed carrier. Co-Authored-By: Claude Opus 5.5 <[email protected]> * perf(bundle-size): lower the hydrate-frame budget for the lighter signal scope hydrate-frame (added on main by #1855) hydrates signal reads, so it ships the signal engine. Against 188d60b's sources it is 2,030 B raw, 488 B gzip and 437 B brotli smaller with this branch's engine, and no other minimal scenario moves. The new budget is main's budget minus that delta, because this machine measures main's own hydrate-frame 4 B over its budget. Co-Authored-By: Claude Opus 5.5 <[email protected]> * perf(bundle-size): re-measure hydrate-frame with #1857 and #1862 merged With #1857 (in-place Block signal owners) and #1862 (unchanged adoption reads) on main, this branch's hydrate-frame measures 364,278 raw, 112,866 gzip and 96,483 brotli. The budget is that measurement plus headroom: 364,310 / 112,898 / 96,616. That is below main's 366,064 / 113,343 / 97,053, so it lowers rather than raises. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
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
A production app-frame hydration audit found frame hydration was the page's only long task. The audit counted 1,930
renderBlockInnercalls and 3,839renderBlockcalls. With signals enabled, every Block gets its own owner fromscopeSignalOwner, sorenderBlocknearly always re-entered itself throughrunWithSignalOwner(owner, () => renderBlock(block)). Each re-entry allocated a closure and resolved the same owner again.This PR adds a benchmark that reproduces that shape and removes the double entry.
benchmarks/app-frame-hydration(new suite, registered inbench.mjs):octane/signals, so it compiles with native reads and runtimestylebindings, under the document signal owner.--base=<checkout>interleaves another checkout per round and reports the paired ratio with a bootstrap 95% CI.framecreated 1,938 Blocks: 1,146 component, 717 control-flow (about 272 of themstyle={undefined}bindings) and 74@forrows. That ran 1,997renderBlockInnerand 3,994renderBlockcalls, against the audit's 1,930 and 3,839.mainthe frame hydrates 1,653 Blocks: 1,146 component, 432@ifarms and 74 rows. That is 1,703renderBlockInnerand 3,406renderBlockcalls.renderBlockenters the Block's owner in place, using the synchronous owner swap the server renderer already uses. It restores the caller's owner in its existingfinally, so a return, throw or suspension all restore it.enableSignalDocumentassignalOwnerFrame, so apps that never enable signals do not retain it.installSignalOwnerEnvironmentkeeps the callback frame, as does a root givensignalOwnerwithout the signal document.SCOPE_SIGNAL_OWNERSWeakMap to a pre-declaredScope.signalOwnerfield (BlockImpl and ScopeImpl), so each lookup is a field read.Results
The
app-frame-hydrationrun interleaves head andorigin/main188d60b (with #1854 and #1855) round by round in the same Chromium, over 50 pairs at 4× throttle. Server HTML is byte-identical between the two.frame(leaf signal reads)frame-live-sections(section-level reads)Deterministic counters for one cold
framehydration, measured in jitless Chromium:renderBlockentriesscopeSignalOwnercallsrunWithSignalOwnercallsBefore #1854/#1855 landed, two 30-pair runs against 7e6bda5 measured
framecold 0.975 and 0.983, and warm 0.963 and 0.962.Reproduce with
node benchmarks/app-frame-hydration/run.mjs 50 --base=<checkout of origin/main>.Size
This PR changes no budget file. Its bytes are re-landed by the budget-only #1865, which must merge immediately before this PR. #1858 first raised them, and
mainratcheted them back in 96c4096 while this PR was open. #1865 carries the full measured set for this branch merged withmain96c4096: 61 raises and 5 brotli lowerings, so the budget step here then passes exactly. Signal-free apps grow by about +155–168 raw / +37–58 gzip (rowsframework: +155 / +37). Bundles that can reach the signal capability grow by about +255–312 raw / +70–115 gzip.I shrank the first cut (+334 raw / +64 gzip on
rows) three ways:finallywith no extratry.enableSignalDocument.The field change is +94 raw and 0 gzip of the signal-free raise. Removing the rest from signal-free apps needs the #1801 "signal flag modules" reachability work.
Candidates evaluated and not taken
renderBlockInnerbehind flags: urgent-transition driver, warm-episode bookkeeping,$$ctxReads/$$ctxDirectclears, and theNATIVE_BLOCK_RETRIESlookup.renderBlockInnerself time, which is under 0.1 ms of a ~105 ms profiled hydration.renderBlockInnercold self time lands on theblock.body(...)call line itself.--no-lazy,--no-lazy-feedback-allocation,--no-sparkplugand--no-maglev.BlockImplpre-declares its expandos, so its shape is stable.--trace-deoptover one cold hydration shows Maglev optimizingrenderBlockInnermid-hydration, then deoptimizing once ("wrong map").BlockImplfields invalidate dependent code once per field (createBlock,ifBlock,journalRootSlot,scopeSignalOwner). That is one-time warmup, 16 deopts per cold hydration.JOURNAL_RENDERfor fresh Blocks. Rejected: hydration keeps every journal entry by design (ROOT_DISCARD_STAMPis −1 while hydrating), because rollback keeps adopted hosts.Validation
packages/octane/tests/signal-render-owner-frame.test.tsrx, new, in theoctaneandoctane-prodprojects (6/6 each). It covers:origin/main's runtime too. I confirmed it fails when the restore is removed (5/6), when owners are not entered (6/6), when the carrier is bypassed (1/6), and when the owner is not cached (4/6).octane:event-signal-owner,event-signal-owner-retirement,stable-event-authority,hydration/signal-instance-identity,hydration/signal-declaration-owner,hydration/document-signal-ownerandhydration/direct-signal-bindings(757/757).pnpm typecheck:filesfor the changed sources and test;octane-tsc -p benchmarks/app-frame-hydration/tsconfig.json.pnpm format:files:checkfor the changed files;pnpm syncleaves the tree clean.BUDGET_BASEset tomain, both of CI's budget commands pass (run-minimal.mjs --budgets --ratchetandrun.mjs --budgets --ratchet octane-tsrx octane-jsx). The budgets are this branch's own--write-budgetsoutput.pnpm format:checkpasses repo-wide under fix: update the TSRX toolchain to @tsrx/core 0.5 and the new formatter #1399's formatter.pnpm test/pnpm typecheck/pnpm format:check: left to CI per the local-load rule.Risk / follow-ups
releaseNativeAdoptionsnotifies every Block that read a signal while hydrating, even when the live value equals the server value. Those Blocks re-render in the same task, which is deliberate today. With section-level reads (frame-live-sections) that takes 1,703 renders to 3,078 for the same 1,653 Blocks, about +8 ms cold at 4×. Skipping the notify when nothing changed would remove it. That belongs to the native-read adoption code, as a separate PR.structuralSignalInstanceKeyalways allocates a visitedSetand a token array, even when the parent key is already resolved. That is about 100 KB per hydration and an easy follow-up.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Changes core render and signal-owner threading for every signal-enabled Block; behavior is heavily tested but touches hydration, Suspense retry, and owner retirement paths.
Overview
Signal-enabled rendering no longer re-enters
renderBlockthroughrunWithSignalOwneron almost every Block.renderBlocknow swaps into each Block's signal owner in place viasignalOwnerFrame(wired whenenableSignalDocumentruns), and restores the caller's owner infinallyon return, throw, or suspend. Host carriers frominstallSignalOwnerEnvironmentand roots without the signal document still use the callback path.Resolved per-scope owners move from
SCOPE_SIGNAL_OWNERSto ascope.signalOwnerfield onScope/BlockImpl, so lookups are plain field reads.A new
app-frame-hydrationheadless-Chromium benchmark (~1,650 Blocks, signals on every module) SSR-renders an app-frame-shaped fixture, measures cold/warm hydration at 4× CPU throttle, and optionally pairs against another checkout. It is registered inbench.mjs, the benchmarks README, and the MCP server list.signal-render-owner-frame.test.tsrxlocks owner enter/restore behavior across nested Blocks, errors, Suspense, and host carriers.Reported impact on that benchmark: one
renderBlockentry per render (was ~2), fewer production calls and ~161 KB less hydration allocation, with modest cold/warm speedups vs the prior runtime.Reviewed by Cursor Bugbot for commit 393bf8b. Bugbot is set up for automated code reviews on this repo. Configure here.