Repository navigation
perf(signals): skip re-rendering adopted readers whose live values are unchanged - #1862
Merged
Merged
Conversation
…e unchanged After a hydration commit, releasing the adopted server values notified every Block that read a signal while hydrating, so each one rendered again in the same task even when the live value still equalled the server value. Parents render their children, so a section-level read rendered the whole section twice. Release now offers each historical read to its subscribers before notifying them. When the consumer's committed render alone holds the read, and a live read would present the same value, the consumer moves the read to the live node without rendering. A snapshot read also compares status and activity. Targeted binding reads use their own channel and are dropped, because the binding keeps its own live subscription. Every other subscriber, and every changed read, is notified as before. The consumer-side move is a standalone function that hydration registers. Only bundles that adopt native reads include it. 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 20:39
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)
54 other measured values are unchanged. Public-import reachability bundles (bytes)❌ 3 value(s) exceed their committed budget. Reduce the growth, or raise the budget in a separate pull request that names the bytes and the reason (CONTRIBUTING.md, "Size budgets").
100 other measured values are unchanged. |
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]>
…doption-release-unchanged-reads
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]>
trueadm
added a commit
that referenced
this pull request
Oct 7, 2026
Conflicts: the 87 react-parity manifests and the user-apps-v1 manifest record the lockfile hash, which #1860 (react-alien-signals port) changed. pnpm sync regenerated them. The merged lockfile needs no change from `pnpm install --lockfile-only` and still holds no TypeScript 7.0.2. Also takes #1862 and its hydrate-frame budget raise (#1863). This branch changes no bundled code, so its budgets stay main's. 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]>
This was referenced Oct 7, 2026
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
After a hydration commit,
releaseNativeAdoptionsreleases each adoption frame. Releasing a frame (AdoptionFrameImpl.release→untrack(notify)→scheduleNativeRead) notified every Block that read a signal while hydrating, so each one rendered again in the same task. That happened even when the live value still equalled the server value. Parents render their children, so a section-level read rendered the whole section twice.Release now renders a reader again only when something it read changed.
{value$}reads through a separate historical channel. On an unchanged release that read is dropped rather than moved, because the binding already holds its own live subscription. The component therefore never starts depending on the signal.rebaseNativeRead, whichownNativeAdoptionregisters.Performance
benchmarks/app-frame-hydration(from #1857, run from a local copy and not part of this diff), measured withnode benchmarks/app-frame-hydration/run.mjs 20 --base=<origin/main 188d60b38d>. Head/base ratios are over 20 interleaved pairs, with bootstrap 95% CIs, at 4× CPU throttle:frame-live-sectionsframeRenders now equal Blocks in both scenarios. Every sample still verifies that every server element is adopted, that no recoverable error is raised, and that a delegated click re-renders a native-read arm. That click is the semantic control: it only works if the moved reads are subscribed live.
Size. Only
hydrate-framein the minimal suite grows: +1,146 raw, +488 gzip, +249 brotli. Every app and JSX budget is byte-identical. That is over the +32 headroom, so the raise is in budget-only #1863, which must merge first.Validation
pnpm format:check(scopedpnpm format:files:checkon every changed file passes)pnpm typecheck(scopedpnpm typecheck:fileson the changed sources, tests and.tsrxfixtures passes)pnpm test(left to CI)signals-hydration.test.tsinoctane-signals,octane-signals-prodandoctane-signals-strong.hydration/streamed-query-hydrate.test.tsandhydration/direct-signal-bindings.test.tsinoctaneandoctane-prod.hydration/initial-document-signals.test.ts.signals-native-seeds,signals-serializationandsignals-inspectioninoctane-signals-node.packages/octane/tests/signals*set and the hydration signal files also passed across the five signals and octane projects.New regression tests assert render-time side effects and DOM, not internals:
completechanged.Each test was seen failing against a deliberate break:
Risk / follow-ups
hydrate-framebudget, so whichever lands second recomputes from main.beginAdoptionsubscribers keep the old notify path. A comparison that throws also falls back to notifying.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Touches hydration adoption release and native read subscription wiring; incorrect rebasing could skip needed renders or break live updates, though tests cover unchanged/changed/query/stream/binding cases.
Overview
Hydration adoption release no longer forces every component that read a signal during hydration to render again when live state still matches the server.
On
AdoptionFrameImpl.release, each historical read subscriber can be rebased viaregisterNativeReadRebase/rebaseNativeRead: ifunchangedLiveReadfinds the live value (and snapshot metadata when applicable) still matches what was presented, the native read consumer swaps its committed subscription from the historical source to the live one without scheduling a render. Changed reads—early edits, newer query results, pending selections, later stream yields, or snapshotcompletechanges—still notify and re-render as before.Targeted bindings (
{value$}) read through a separate historical channel (historicalBindingRead); on unchanged release those reads are dropped rather than moved, so the component body never gains a render dependency on that signal.Docs and a patch changeset describe the behavior; new hydration/stream tests assert render counts and side effects for unchanged vs changed adoption paths.
Reviewed by Cursor Bugbot for commit 746a716. Bugbot is set up for automated code reviews on this repo. Configure here.