Repository navigation
perf(octane): keep server seed serialization out of client signal bundles - #2035
Merged
Merged
Conversation
…dles Every graph source named `node.owner.serializeRead(...)`, and ScopeImpl implemented it as a class method. A bundler cannot drop a method of a class it keeps, so every client that reads signals shipped the server's seed serializer (serializeScopeRead, scopeSeedEntry and encodeSignalValue), although only the server read driver ever serializes a source. Graph sources now call a serializer that read-protocol.ts holds and only createNativeServerReadDriver supplies, as hydration supplies the NativeAdoptionMiss class. The serializer moves to native-read-seeds.ts beside serializeNativeSeedReads, its only consumer, and reaches the graph through its registration (candidateGraph), so the server renderer still loads no graph in applications without signals. The public scope.serialize() keeps using scopeSeedEntry from there. A production rolldown + oxc split-chunk app's signals chunk drops 2,134 raw / 480 gzip bytes; hydrate-frame drops 2,143 / 490. Signal-free bundles are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
October 13, 2026 10:32
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
View logs |
octane-website | f2d7dd3 | Oct 13 2026, 11:05 AM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
View logs |
octane-website-mcp | f2d7dd3 | Oct 13 2026, 11:05 AM |
11 of 12 tasks
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)
74 other measured values are unchanged. Public-import reachability bundles (bytes)
107 other measured values are unchanged. |
Every hydrating client imports native-read-seeds.ts, so its new imports reordered modules and moved signal-free bundles by a few bytes (+7 raw on root-static-specialized, +20 on binding-radix-vite). The serializer moves to its own module that only the engine and the server read driver import; signal-free rows are byte-identical to main again. Co-Authored-By: Claude Opus 5.5 <[email protected]>
5 of 7 tasks
trueadm
marked this pull request as draft
October 13, 2026 11:09
7 of 8 tasks
1 task done
trueadm
marked this pull request as ready for review
October 13, 2026 12:03
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.
Note
Paused (draft), measurements kept. Byte-tuning of signal integration is paused while #2031 (thin signals core) rewrites seeds and adoption. The measured result stays as evidence for #2031 item E: removing
serializeReadfromScopeImplkeeps the server seed serializer out of client signal bundles, −2,134 raw / −486 gzip on the signals chunk with signal-free rows byte-identical.Summary
Every client bundle that reads signals shipped the server's seed serializer. Graph sources serialized through
node.owner.serializeRead(...), andScopeImplimplemented that as a class method. A bundler cannot drop a method from a class it keeps, soserializeReadkeptserializeScopeRead,scopeSeedEntryandencodeSignalValuein the client. Only the server read driver ever serializes a source.nativeReadSerializer(read-protocol.ts). OnlycreateNativeServerReadDriversupplies it, the same way hydration supplies theNativeAdoptionMissclass throughsupplyNativeAdoptionMiss.serializeScopeReadandscopeSeedEntrymove unchanged fromsignals/engine.tsto a newsignals/seed-serialization.ts, which only the engine (for the publicscope.serialize()) and the server read driver import. They reach the graph through its registration (candidateGraph.assertAlive,candidateGraph.ScopedNode), so the server renderer still loads no graph in apps without signals. A first revision put them innative-read-seeds.ts, but every hydrating client imports that module, and its added imports reordered modules and moved signal-free bundles by a few bytes. The second commit splits them out, and signal-free rows are byte-identical to main again.GraphOwner.serializeReadis removed. The publicscope.serialize()still usesscopeSeedEntry, so apps that call it keep it.Part of #2031 (item E, seeds and adoption): this removes
serializeReadfromScopeImpl, which is half of the class move that item measures.Bytes
After merging main at c8256d8 (#2033), against that main plus #2032's scenario:
The earlier measurement against d37bd28:
node benchmarks/bundle-size/run-minimal.mjs, based37bd284d3. Thesplit-shellrows come from #2032's scenario, copied into both trees for the measurement:These rows are byte-identical to base in raw and gzip: hydrate-root, deferred-hydration, suspense-transition, root-static-specialized, component-owned-effects, binding-radix-vite and binding-usehooks-ts-vite.
node benchmarks/bundle-size/run.mjs octane-jsx: the signal app-shell row drops 511 gzip (125,051 → 124,540), while the rows app and the ceiling are byte-identical (54,021 and 174,796 gzip).Validation
Targeted tests, all projects (octane, octane-prod, octane-signals, -signals-prod, -signals-strong, -signals-node):
signals-native-seeds,signals-pending-promotion-graph,signals-hydration,hydration/direct-signal-bindings,hydration/signal-instance-identity,signals-native-collection,signals-pending-stream,signals-streams,streamed-signal-cancellation,native-read-empty-branches,signals-parallel-use,signals-deferred-values,behavior-root,signals-dom-bindings. 33 files, 1,779 tests pass.Regression evidence: the preserved behavior is that server seeds reach the client and hydration adopts them. Existing suites pin it. Removing the driver's
supplyNativeReadSerializercall fails 350 tests insignals-hydration,hydration/direct-signal-bindingsandhydration/signal-instance-identitywithnativeReadSerializer is not a function.pnpm typecheck:fileson the six changed modulespnpm format:files:check,pnpm sync(no generated changes)pnpm test: not run locally; left to CI.hydration/native-condition-demand.test.tstimes out onevi.waitForcase per run on this loaded machine on both base and head, a different case each time.perf-review:Perf review:
perf/server-only-seed-serialization(d37bd28..d213d1c)Scan:
node scripts/perf-review-scan.mjsfound 2 candidates.Hot paths touched:
createGraphSource(signals/graph.ts:861): itsserializemember now reads a module binding instead of calling an owner method. It runs per server serialization of an observed source, never on the client. The source literal's keys and order are unchanged.createNativeServerReadDriver(native-read-server.ts:24): supplies the serializer once per driver, which is created once per server process.packages/octane/src/signals/graph.ts:869Dismissed candidates:
packages/octane/src/signals/seed-serialization.ts:53,58[conditional-shape]: code moved verbatim fromengine.ts. These are server-only wireSignalSeedEntryobjects whose omitted keys are part of the JSON format. They are not hot records.Not checked: compiled output, which is unchanged because no compiler file changed.
concise-code:signals/seed-serialization.ts, holding only the moved functions; keeping them out ofnative-read-seeds.tskeeps signal-free bundles byte-identical. New exports:nativeReadSerializerandsupplyNativeReadSerializer(read-protocol), andscopeSeedEntryandserializeScopeRead(seed-serialization). All are moved code or have exactly one caller each.engine.ts. Rejected: the server renderer would load the engine and graph in apps that never create a signal.serializeReadonScopeImpl.prototypefrom the server. Rejected: the server would need a reference toScopeImpl, which means importing the engine.native-read-seeds.ts. Rejected: that module's added imports reordered modules in every hydrating client (+7 to +20 raw on signal-free rows in the first CI report).Risk / follow-ups
NativeReadSource.serializeoutside the server read driver must supply the serializer first. Today the driver'sserializeis the only one, and a missing supply fails loudly with aTypeErrorrather than producing wrong seeds.HydrationCapabilitymembers have the same class-method cause, but most can't move. Their callers are client-reachable behindhydratingguards that esbuild never folds, so moving them would grow esbuild/Rspack createRoot-only bundles. Only three methods whose sole caller isactivateHydrateBoundaryare being moved (~0.4 KB), in a separate session.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.Note
Low Risk
Refactor for bundle reachability only; serialization logic is moved unchanged and the server driver must still supply the serializer (missing supply fails loudly in tests).
Overview
Client signal bundles no longer include server-only seed serialization (~2.1 kB raw / ~0.5 kB gzip). Runtime behavior for hydration and
scope.serialize()is unchanged.Graph
NativeReadSource.serializenow calls an injectablenativeReadSerializerinread-protocol.tsinstead ofScopeImpl.serializeRead, which bundlers could not tree-shake off the client.createNativeServerReadDriverregistersserializeScopeReadat startup viasupplyNativeReadSerializer.serializeScopeReadandscopeSeedEntrymove verbatim intoseed-serialization.ts(imported by the engine for public serialization and by the server driver for native reads).GraphOwner.serializeReadis removed from the owner API.Reviewed by Cursor Bugbot for commit f2d7dd3. Bugbot is set up for automated code reviews on this repo. Configure here.