Skip to content

perf(octane): share signal graph flags directly - #2097

Merged
trueadm merged 2 commits into
octanejs:nextfrom
openai-oss-forks:codex/next-signal-bridge-owner
Oct 15, 2026
Merged

trueadm merged 2 commits into
octanejs:nextfrom
openai-oss-forks:codex/next-signal-bridge-owner

Conversation

@domgan-oai

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

Copy link
Copy Markdown
Contributor

Summary

Move the signal graph's seven bit masks into a graph-free constants module and let transition promotion import the four it uses directly. This removes the runtime GraphBridge.flags dictionary while preserving synchronous graph/renderer registration and the full bit layout's single owner.

Validation

  • pnpm format:check (scoped format check passed)
  • pnpm typecheck (scoped typecheck passed)
  • pnpm test (full workspace suite not run locally)
  • targeted tests: the public Action/bundle-boundary test passed for graph and renderer placement with both renderer-first and graph-first initialization; eight targeted package tests passed. Setting the shared dirty bit to zero made the staged-value assertion fail; restoring it passed.
  • Perf review: scan found zero candidates. Graph initialization loses one dictionary allocation; per-transition promotion reads static numeric masks without extra dynamic dispatch. No hot fields, per-render allocations, DOM work, or scheduling were added. A matched Signal Chat production build on the live base emitted 22 client JavaScript assets: 477,835→477,663 raw bytes and 159,205→159,117 bytes summed after individually gzip-compressing each asset (−88 bytes). The baseline overlaid the three original source files from the live base into the same checkout; the build asserted all three overlays were used. No runtime timing claim.
  • Concise-code: shipped source +25/−18 across four files, including a seven-line graph-free leaf; the boundary test +45/−33 expands an existing fixture. Putting the masks in transition state would split or misplace ownership; importing the graph into transition code would retain the graph in renderer-only paths. Independent complexity review found the leaf justified.

Risk / follow-ups

The complete-client measurement is one checked-in consumer and one toolchain. The summed independently compressed assets reflect the build's separate delivery artifacts. Current-head CI provides broader coverage.

Provenance

  • An agent produced this diff (agent-authored)

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 of constant wiring and bridge surface only; reactive semantics unchanged, with expanded bundle-boundary tests covering load order and transition promotion.

Overview
Moves reactive graph bitmasks into a graph-free graph-flags module so transition promotion can import REACTIVE_DIRTY, REACTIVE_PENDING, REACTIVE_MUTABLE, and REACTIVE_WATCHING directly instead of reading them from the runtime GraphBridge.flags table.

graph.ts now sources all seven flags from that leaf; registerGraphBridge no longer exposes a flags dictionary, and the GraphBridge type in transition-state.ts drops the flags field accordingly. Behavior and bit layout stay the same—this is a bundle-size / indirection cleanup for renderer-islands paths that load pending.ts without pulling flag plumbing through the bridge.

The bundle-boundaries late-signal Action fixture is async and parameterized by graphFirst so both module load orders (renderer vs graph first) are exercised under default and octane-islands placement, with extra post-release write/subscribe checks. A patch changeset documents the octane bundle overhead reduction.

Reviewed by Cursor Bugbot for commit dab91b5. 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
@domgan-oai
domgan-oai marked this pull request as ready for review October 15, 2026 14:58
@github-actions

Copy link
Copy Markdown
Contributor

Benchmark report

  • 🔴 bundle-size: 2 value(s) increased
  • 🔴 bundle-reachability: 1 value(s) increased

Compares c4cbd556e, the merge commit's first parent with 6801421d5 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

target operation base ms head ms head/base 95% CI
octane-jsx replace 20.183 17.675 −17.2% −25.3% … −9.2% 🟢 faster
All 20 timed operations (19 without a verdict)
target operation base ms head ms head/base 95% CI
octane-tsrx run 5.358 5.242 −0.0% −19.0% … +14.6% ⚪ within noise
octane-tsrx replace 14.408 13.917 −0.1% −11.3% … +14.5% ⚪ within noise
octane-tsrx add 3.442 3.733 +1.7% −6.4% … +26.4% ⚪ within noise
octane-tsrx update 0.115 0.122 +5.5% −1.6% … +17.8% ⚪ within noise
octane-tsrx select 0.008 0.008 −1.0% −8.5% … +12.0% ⚪ within noise
octane-tsrx swap 0.030 0.032 +6.2% −4.3% … +19.7% ⚪ within noise
octane-tsrx remove 0.026 0.027 +6.7% −5.6% … +14.9% ⚪ within noise
octane-tsrx runlots 31.258 30.742 +1.9% −8.8% … +8.5% ⚪ within noise
octane-tsrx select_lots 0.008 0.008 −2.5% −8.7% … +0.9% ⚪ within noise
octane-tsrx clear 71.358 62.725 −2.5% −13.3% … +3.7% ⚪ within noise
octane-jsx run 4.867 5.492 ±0.0% −8.0% … +9.4% ⚪ within noise
octane-jsx replace 20.183 17.675 −17.2% −25.3% … −9.2% 🟢 faster
octane-jsx add 4.975 5.400 −3.7% −12.8% … +18.3% ⚪ within noise
octane-jsx update 0.260 0.246 +1.1% −13.3% … +15.0% ⚪ within noise
octane-jsx select 0.120 0.113 −4.8% −11.4% … +2.1% ⚪ within noise
octane-jsx swap 0.167 0.168 +1.2% −3.3% … +10.4% ⚪ within noise
octane-jsx remove 0.173 0.173 −1.8% −7.9% … +5.1% ⚪ within noise
octane-jsx runlots 32.183 32.658 +0.2% −6.4% … +8.4% ⚪ within noise
octane-jsx select_lots 1.212 1.294 +3.3% −4.2% … +15.7% ⚪ within noise
octane-jsx clear 44.683 45.750 +4.0% −0.5% … +9.0% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

target metric base head Δ
octane-tsrx wayfinder_js_raw 438,498 438,322 −176 (−0.0%) 🟢
octane-tsrx wayfinder_js_gzip 144,659 144,566 −93 (−0.1%) 🟢
octane-tsrx wayfinder_js_brotli 126,303 126,185 −118 (−0.1%) 🟢
octane-jsx shell_js_raw 327,287 327,113 −174 (−0.1%) 🟢
octane-jsx shell_js_gzip 106,687 106,589 −98 (−0.1%) 🟢
octane-jsx shell_js_brotli 92,617 92,500 −117 (−0.1%) 🟢
octane-jsx shell_app_gzip 760 761 +1 (+0.1%) 🔴
octane-jsx shell_fw_raw 326,194 326,020 −174 (−0.1%) 🟢
octane-jsx shell_fw_gzip 105,927 105,828 −99 (−0.1%) 🟢
octane-jsx shell_fw_brotli 91,961 91,844 −117 (−0.1%) 🟢
octane-jsx shell_client_js_raw 278,732 278,558 −174 (−0.1%) 🟢
octane-jsx shell_client_js_gzip 90,296 90,186 −110 (−0.1%) 🟢
octane-jsx shell_client_js_brotli 78,991 78,867 −124 (−0.2%) 🟢
octane-jsx shell_client_app_gzip 769 773 +4 (+0.5%) 🔴
octane-jsx shell_client_app_brotli 670 669 −1 (−0.1%) 🟢
octane-jsx shell_client_fw_raw 277,631 277,457 −174 (−0.1%) 🟢
octane-jsx shell_client_fw_gzip 89,527 89,413 −114 (−0.1%) 🟢
octane-jsx shell_client_fw_brotli 78,321 78,198 −123 (−0.2%) 🟢

75 other measured values are unchanged.

Public-import reachability bundles (bytes)

target metric base head Δ
hydrate-frame raw 340,524 340,353 −171 (−0.1%) 🟢
hydrate-frame gzip 109,376 109,246 −130 (−0.1%) 🟢
hydrate-frame brotli 95,016 94,858 −158 (−0.2%) 🟢
split-shell raw 391,407 391,235 −172 (−0.0%) 🟢
split-shell gzip 127,456 127,365 −91 (−0.1%) 🟢
split-shell brotli 111,091 111,020 −71 (−0.1%) 🟢
split-shell-runtime gzip 101,595 101,596 +1 (+0.0%) 🔴
split-shell-runtime brotli 87,841 87,819 −22 (−0.0%) 🟢
split-shell-signals raw 65,390 65,218 −172 (−0.3%) 🟢
split-shell-signals gzip 20,784 20,691 −93 (−0.4%) 🟢
split-shell-signals brotli 18,819 18,751 −68 (−0.4%) 🟢

112 other measured values are unchanged.

@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.

Approving. Moving the flag masks into a graph-free leaf removes the GraphBridge.flags dictionary and its property reads without changing the bit layout. It also measurably shrinks the signal bundles.

Correctness. The values move unchanged from signals/graph.ts into signals/graph-flags.ts, so the graph still owns the bit layout through a single module. pending.ts now imports only the four masks it needs (DIRTY | PENDING in installable, DIRTY and then MUTABLE | WATCHING in promoteSlots). The leaf imports nothing, so transition promotion doesn't pull the graph into renderer-only paths. I found no remaining graph.flags reader anywhere in packages/.

Tests. The extended bundle-boundaries.test.mjs case now covers both module load orders (graph first and renderer first) for both placements. The added count.set(3) assertion checks that a node promoted with MUTABLE | WATCHING still propagates afterwards. That's the property that would break if a mask were wrong, and your mutation check on the dirty bit confirms the test catches it.

Numbers (benchmark on dab91b5, run 38756231425):

  • All 64 work counters are unchanged.
  • wayfinder_js is −176 raw / −93 gzip.
  • JSX shell_js is −174 / −98, and shell_client_js is −174 / −110.
  • Reachability: hydrate-frame −171 / −130, split-shell −172 / −91, split-shell-signals −172 / −93 (−0.4%).
  • The only increases are shell_app_gzip +1, shell_client_app_gzip +4 and split-shell-runtime gzip +1. These are compression jitter on unchanged app code.
  • One timing verdict is flagged: JSX replace −17.2% faster. I wouldn't credit this change with it, since it doesn't touch the keyed-list path, so please don't cite it as a win.

CI on the current head is fully green: 30 pass, 6 skipped matrix placeholders.

Reviewed with Claude Code

@trueadm
trueadm merged commit a78167b into octanejs:next Oct 15, 2026
77 of 80 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