Skip to content

perf(octane): validate serialized signal owners without the graph bridge - #2083

Merged
trueadm merged 3 commits into
octanejs:nextfrom
openai-oss-forks:codex/next-single-scope-signal-reads
Oct 15, 2026
Merged

trueadm merged 3 commits into
octanejs:nextfrom
openai-oss-forks:codex/next-single-scope-signal-reads

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Serializing a retained signal owner currently goes through the graph bridge just to check whether the owner is retired. Call the same assertAlive guard directly from scopeSeedEntry. Keep it available from graph.ts for existing consumers; serializeScopeRead still uses the bridge where it needs graph traversal for SSR. The error, seed format, suspension and disposal behavior are unchanged.

This is the smaller alternative requested in review. Controlled production Oxc runs showed the removed inline-Candidate optimization saved one Map per single-scope render and helped a sampled-style fixture (−3.4%), but a real second-scope read regressed by +4.6% with 16 signals and +14.1% with 128. Baseline-vs-baseline controls were near zero. Those gains did not justify the multi-scope regression, so this PR now has no native-read-client.ts diff. Independently extracted from #2036, against next.

Validation

  • 139 targeted tests: native collection and stack-overflow cleanup, public seed serialization, retired-owner/disposal handling, and event ownership in the relevant signals dev/prod/node and Octane projects.
  • 46 bundle and reachability gate tests.
  • Scoped typecheck and formatting of the 3 changed signal source files.
  • pnpm sync and git diff --check.
  • PR bench on c50a7ed passed; all 64 work counters unchanged, all 20 js-framework timings within noise.
  • c50a7ed: 32/32 hosted checks green, including all Node 24, React parity, website, standalone Chromium work/cleanup and provenance checks. Full CI.

Risk / follow-ups

No runtime hot-path change remains. This removes a dependency edge for seed ownership validation only; consumers that still need graph serialization may retain the graph bridge. PR-only hosted comparison: next 4ae77f2 → PR merge f94d19b of c50a7ed, before #2090 landed. Full JavaScript gzip: TSRX 31,551 → 31,551 B and JSX 55,431 → 55,431 B. Threadline Oxc 53,221 → 53,221 B / esbuild 60,319 → 60,319 B; Pagecraft Oxc 171,565 → 171,565 B / esbuild 186,925 → 186,925 B. Wayfinder −34 B. JSX full signal shell 107,135 → 107,147 B (+12 B); client shell −4 B; hydrate-frame +13 B; combined split-shell −6 B. This is effectively bundle-neutral in the full apps; the older +110 B shell/Map change is gone. No new size target is claimed. #2090 does not conflict with this PR, but the hosted benchmark's merge parent predates that split.

Provenance

  • An agent produced this diff (agent-authored)

Implementation: Codex task · host com-79386.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.


Note

Low Risk
Refactor only: same retired-owner check, with a narrower import path during seed serialization; SSR graph serialization still uses the bridge.

Overview
Moves assertAlive from graph.ts into errors.ts and re-exports it from the graph module so existing imports keep working.

When copying retained owners during scopeSeedEntry serialization, validation now calls assertAlive directly instead of graphBridge.assertAlive, so that path no longer depends on the transition graph bridge (and its optional transition ops) just to throw ScopeDisposedError on retired scopes. serializeScopeRead still uses the bridge for graph-node walks and SSR checks.

Patch changeset notes the same ownership-validation behavior with a lighter dependency edge.

Reviewed by Cursor Bugbot for commit c50a7ed. 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 Oct 15, 2026
@github-actions
github-actions Bot marked this pull request as draft October 15, 2026 12:35
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

  • 🔴 bundle-size: 11 value(s) increased
  • 🔴 bundle-reachability: 8 value(s) increased

Compares 4ae77f2f0, the merge commit's first parent (main has moved 1 commit(s) past the pull request's recorded base a8ac6e2b1) with f94d19bc2 on the same runner. Any increase in a js-framework work counter fails this check; byte changes are a report. Wall time is a report: base and head samples alternate in one browser, and an operation is called slower or faster only when the 95% confidence interval of its ratio excludes ±3%. Workflow run

js-framework: 1k/10k row operations

All 20 timed operations (20 without a verdict)
target operation base ms head ms head/base 95% CI
octane-tsrx run 2.292 2.308 ±0.0% −0.0% … +4.4% ⚪ within noise
octane-tsrx replace 4.600 4.692 +2.1% −4.2% … +2.2% ⚪ within noise
octane-tsrx add 2.058 2.083 ±0.0% ±0.0% … +4.8% ⚪ within noise
octane-tsrx update 0.090 0.089 −1.5% −2.6% … −0.0% ⚪ within noise
octane-tsrx select 0.005 0.005 +0.5% ±0.0% … +1.1% ⚪ within noise
octane-tsrx swap 0.015 0.015 −1.1% −2.7% … ±0.0% ⚪ within noise
octane-tsrx remove 0.012 0.012 −1.0% −3.6% … +2.1% ⚪ within noise
octane-tsrx runlots 18.883 19.683 +2.1% −1.3% … +4.1% ⚪ within noise
octane-tsrx select_lots 0.006 0.005 −1.8% −5.0% … −0.6% ⚪ within noise
octane-tsrx clear 38.292 38.667 +1.3% +0.3% … +2.0% ⚪ within noise
octane-jsx run 3.042 3.050 −1.6% −3.2% … +0.0% ⚪ within noise
octane-jsx replace 5.042 5.133 +2.0% −3.8% … +4.8% ⚪ within noise
octane-jsx add 2.808 2.825 +3.5% ±0.0% … +3.7% ⚪ within noise
octane-jsx update 0.160 0.160 −1.5% −2.2% … +0.0% ⚪ within noise
octane-jsx select 0.079 0.079 ±0.0% −0.3% … +0.6% ⚪ within noise
octane-jsx swap 0.120 0.121 ±0.0% −0.6% … +2.3% ⚪ within noise
octane-jsx remove 0.107 0.108 −0.3% −1.3% … +1.3% ⚪ within noise
octane-jsx runlots 23.842 22.908 −2.6% −4.3% … −0.9% ⚪ within noise
octane-jsx select_lots 0.824 0.839 +1.1% −0.3% … +4.1% ⚪ within noise
octane-jsx clear 39.858 39.525 +0.0% −0.9% … +1.8% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

target metric base head Δ
octane-tsrx wayfinder_js_raw 437,944 437,972 +28 (+0.0%) 🔴
octane-tsrx wayfinder_js_gzip 144,869 144,835 −34 (−0.0%) 🟢
octane-tsrx wayfinder_js_brotli 125,908 125,812 −96 (−0.1%) 🟢
octane-jsx shell_js_raw 327,046 327,050 +4 (+0.0%) 🔴
octane-jsx shell_js_gzip 107,135 107,147 +12 (+0.0%) 🔴
octane-jsx shell_js_brotli 92,620 92,676 +56 (+0.1%) 🔴
octane-jsx shell_app_gzip 770 764 −6 (−0.8%) 🟢
octane-jsx shell_app_brotli 668 673 +5 (+0.7%) 🔴
octane-jsx shell_fw_raw 325,953 325,957 +4 (+0.0%) 🔴
octane-jsx shell_fw_gzip 106,365 106,383 +18 (+0.0%) 🔴
octane-jsx shell_fw_brotli 91,952 92,003 +51 (+0.1%) 🔴
octane-jsx shell_client_js_raw 278,594 278,577 −17 (−0.0%) 🟢
octane-jsx shell_client_js_gzip 90,691 90,687 −4 (−0.0%) 🟢
octane-jsx shell_client_js_brotli 79,058 79,087 +29 (+0.0%) 🔴
octane-jsx shell_client_app_gzip 764 767 +3 (+0.4%) 🔴
octane-jsx shell_client_app_brotli 667 665 −2 (−0.3%) 🟢
octane-jsx shell_client_fw_raw 277,493 277,476 −17 (−0.0%) 🟢
octane-jsx shell_client_fw_gzip 89,927 89,920 −7 (−0.0%) 🟢
octane-jsx shell_client_fw_brotli 78,391 78,422 +31 (+0.0%) 🔴

74 other measured values are unchanged.

Public-import reachability bundles (bytes)

target metric base head Δ
hydrate-frame raw 340,275 340,276 +1 (+0.0%) 🔴
hydrate-frame gzip 109,959 109,972 +13 (+0.0%) 🔴
hydrate-frame brotli 94,917 94,949 +32 (+0.0%) 🔴
split-shell raw 391,083 391,087 +4 (+0.0%) 🔴
split-shell gzip 128,257 128,251 −6 (−0.0%) 🟢
split-shell brotli 111,031 111,078 +47 (+0.0%) 🔴
split-shell-runtime gzip 102,393 102,392 −1 (−0.0%) 🟢
split-shell-runtime brotli 87,775 87,787 +12 (+0.0%) 🔴
split-shell-signals raw 65,386 65,390 +4 (+0.0%) 🔴
split-shell-signals gzip 20,786 20,784 −2 (−0.0%) 🟢
split-shell-signals brotli 18,815 18,819 +4 (+0.0%) 🔴

112 other measured values are unchanged.

@trueadm
trueadm marked this pull request as ready for review October 15, 2026 13:06

@trueadm trueadm left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. The change is small and CI is green. One concern before merging into next, which is a size-focused branch: the benchmark report (run 38741491717) shows bytes going up with no measured speed-up.

  • Size: shell_ full +110 B gzip (106,365 → 106,475), shell_client +72, full_fw +70, hydrate-frame +87, split-shell +72, split-shell-signals +80.
  • Speed: every js-framework operation is within noise, and no work counter moved.

The win here is one fewer Map per signal-reading render, but nothing we benchmark exercises that. Could you add a measurement that shows it? For example, the scoped-signals bench or a focused allocation counter (hook-memo style) for a component reading one scope, with the Map allocation gone and no regression in multi-scope reads. If the gain is real there, the bytes are easier to justify.

Two smaller notes:

  • getCandidate now does an instanceof Map check on every read. That's probably fine, but the per-read cost on the multi-scope path is worth confirming in that same bench.
  • Moving assertAlive into errors.ts to keep serialization off the graph bridge is a nice separate win. If the Map change doesn't hold up, it could land on its own.

Reviewed with Claude Code

@domgan-oai domgan-oai changed the title perf(octane): avoid grouping allocations for single-scope signal reads perf(octane): validate serialized signal owners without the graph bridge Oct 15, 2026

@trueadm trueadm left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for narrowing this to the owner-validation move. It's size-neutral, and serialization no longer reaches the graph bridge only to check that an owner is alive. All 30 checks are green on c50a7ed. Approving.

Reviewed with Claude Code

@trueadm
trueadm merged commit c4cbd55 into octanejs:next Oct 15, 2026
33 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.

2 participants