Skip to content

test(bench): track native-read overhead with a plain app-frame twin - #2037

Merged
trueadm merged 1 commit into
mainfrom
test/app-frame-plain-twin
Oct 13, 2026
Merged

trueadm merged 1 commit into
mainfrom
test/app-frame-plain-twin

Conversation

@trueadm

@trueadm trueadm commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Adds a frame-plain scenario to benchmarks/app-frame-hydration: the same ~1,650-Block frame with no octane/signals import anywhere, reading the same five values through useSyncExternalStore.
  • The run now reports the paired frame/frame-plain ratio, cold and warm, beside the existing head/base ratios, plus each scenario's minified client bytes. That tracks what native reads cost a frame that barely reads a signal.

Why

A production signals-enabled app frame showed that importing octane/signals in every module costs hydration time even where almost nothing reads a signal. On current main (5594cb0, 20 pairs, 4× CPU, headless Chromium):

scenario cold warm Blocks calls (jitless) heap client gzip
frame 62.2 ms 24.5 ms 1,653 221,893 2.99 MB 111,032
frame-plain 46.1 ms 17.8 ms 1,502 144,385 2.32 MB 92,926
frame/frame-plain 1.340 [1.323–1.370] 1.378 [1.354–1.391]

Without a twin the harness could only compare a change with its base, never with the plain-hydration floor.

Changes

  • src/plain/: copies of the four modules that read a signal (composer, header, primitives, sidebar), each reading the store through useSyncExternalStore, plus store.ts, a tiny external store standing in for signal$.
  • run.mjs: a -plain scenario builds with a small Vite plugin (plainTwin). It rewrites the 'octane/signals' specifier in src/ to plain/store.ts, so no module compiles with native reads or signal bindings, and resolves a frame import of a signal-reading module to its plain/ copy. frame.tsrx, state.ts, client.ts and server.ts are shared.
  • A semantic control: the build fails if the twin's server HTML differs from frame's, less the native seed script. Today they match byte for byte.
  • client.ts drains passive effects before the verification click, because useSyncExternalStore subscribes in one. This is outside the timed window and does nothing for the signals frame.
  • Scenario order now rotates per round (roundOrder) so the frame/plain pairs are interleaved like head/base pairs.
  • README and the bench.mjs suite note describe the twin and the drift rule: a change to a signal-reading module belongs in its src/plain/ copy too.

Validation

  • node benchmarks/app-frame-hydration/run.mjs 20 on main: numbers above, all verifications pass (adoption, no recoverable errors, delegated click re-renders the reading arm, clean unmount).
  • --base=<checkout> runs pair both head/base and frame/frame-plain per candidate. Used for the follow-up PRs that cut the gap.
  • octane-tsc -p benchmarks/app-frame-hydration/tsconfig.json: no errors in benchmark files.
  • pnpm format:files:check benchmarks/app-frame-hydration benchmarks/bench.mjs
  • pnpm sync: no generated changes.
  • pnpm test / pnpm typecheck: not run; benchmark-only change.
  • perf-review: not applicable (no runtime, compiler or binding source).
  • concise-code: src +0 −0 (runtime +0 −0); new files: the four plain/*.tsrx twins and plain/store.ts, needed because the twin must read through hooks where the frame reads natively. Alternatives: a full copy of the fixture (~770 lines, every module free to drift) or deriving the twin with a source transform of .get() reads (fragile, hides what is measured). The redirect plugin keeps the shared modules shared, and the server-HTML check catches drift in the copies. Bytes: not applicable.

Risk / follow-ups

  • The suite takes ~1.5× longer (one more scenario and build).
  • Follow-ups that cut the measured gap are separate PRs.

Provenance

  • An agent produced this diff (agent-authored)

🤖 Generated with Claude Code


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


Note

Low Risk
Benchmark and fixture-only changes; no production runtime, compiler, or binding code paths are modified.

Overview
Adds a frame-plain (and matching *-plain) path to the app-frame hydration benchmark so the same ~1,650-Block fixture can be built without octane/signals / native reads, using a Vite plainTwin plugin that swaps in src/plain/store.ts and redirects signal-reading modules to useSyncExternalStore twins.

The harness now defaults to three scenarios, builds signals vs plain client/server variants, fails if plain SSR HTML diverges from signals (minus the native seed script), reports frame/frame-plain paired cold/warm ratios alongside head/base, records clientBytes / clientGzipBytes, and rotates scenario order per round. Verification calls drainPassiveEffects before the sidebar click so the plain twin’s subscriptions are active outside the timed hydrate window.

Docs in README.md and bench.mjs describe the twin and maintenance rule: signal-reading changes need matching src/plain/ copies.

Reviewed by Cursor Bugbot for commit 2d93883. Bugbot is set up for automated code reviews on this repo. Configure here.

frame-plain hydrates the same frame with no octane/signals import, reading the
same store through useSyncExternalStore. The run checks the twin's server HTML
matches frame's less the seed script, and reports the paired frame/frame-plain
ratio plus client bundle bytes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
⚠️ Deployment skipped
View logs
octane-website 2d93883 Oct 13 2026, 11:12 AM

@trueadm
trueadm marked this pull request as ready for review October 13, 2026 11:12
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
⚠️ Deployment skipped
View logs
octane-website-mcp 2d93883 Oct 13 2026, 11:12 AM

@github-actions

Copy link
Copy Markdown
Contributor

Benchmark report

🟢 No byte growth, no added work, and no timing changes beyond ±3%.

Compares 5594cb06e, the merge commit's first parent with 56882b32f 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 3.250 3.200 +0.0% −3.3% … +3.4% ⚪ within noise
octane-tsrx replace 8.658 8.750 −0.7% −11.2% … +8.2% ⚪ within noise
octane-tsrx add 2.433 2.417 −1.9% −4.0% … +2.0% ⚪ within noise
octane-tsrx update 0.128 0.136 +4.0% −0.0% … +7.4% ⚪ within noise
octane-tsrx select 0.006 0.005 −1.3% −2.1% … +0.5% ⚪ within noise
octane-tsrx swap 0.018 0.017 ±0.0% −2.4% … +3.4% ⚪ within noise
octane-tsrx remove 0.016 0.016 −1.3% −4.7% … +1.6% ⚪ within noise
octane-tsrx runlots 27.725 27.942 +1.2% −4.1% … +4.5% ⚪ within noise
octane-tsrx select_lots 0.008 0.008 −0.0% −8.8% … +2.7% ⚪ within noise
octane-tsrx clear 43.192 43.867 −1.9% −4.6% … +0.2% ⚪ within noise
octane-jsx run 3.150 3.092 ±0.0% −2.9% … +1.5% ⚪ within noise
octane-jsx replace 5.842 5.900 +1.8% −2.4% … +5.4% ⚪ within noise
octane-jsx add 3.233 3.233 −0.0% −3.1% … +1.6% ⚪ within noise
octane-jsx update 0.248 0.242 +0.7% −0.7% … +3.1% ⚪ within noise
octane-jsx select 0.122 0.126 +1.4% +1.1% … +2.5% ⚪ within noise
octane-jsx swap 0.168 0.175 ±0.0% −1.4% … +1.4% ⚪ within noise
octane-jsx remove 0.160 0.160 −0.0% −1.3% … +0.0% ⚪ within noise
octane-jsx runlots 30.108 29.750 −1.1% −4.3% … +1.3% ⚪ within noise
octane-jsx select_lots 1.791 1.744 +0.0% −3.6% … +3.1% ⚪ within noise
octane-jsx clear 64.017 64.750 +2.4% −7.7% … +6.4% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

No changes across 93 measured values.

Public-import reachability bundles (bytes)

No changes across 111 measured values.

@trueadm
trueadm merged commit 2bf15a2 into main Oct 13, 2026
50 of 55 checks passed
@trueadm
trueadm deleted the test/app-frame-plain-twin branch October 13, 2026 12:03
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 test PR: tests only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant