Skip to content

test(bench): add a Suspense-bounded app frame and trace its longest task - #2041

Merged
trueadm merged 2 commits into
mainfrom
test/app-frame-boundaries-bench
Oct 13, 2026
Merged

trueadm merged 2 commits into
mainfrom
test/app-frame-boundaries-bench

Conversation

@trueadm

@trueadm trueadm commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

This PR adds benchmarks/app-frame-hydration's frame-boundaries scenario, plus trace-based longest-task and busy-total metrics. It is the gate for hydrating Suspense boundaries after the shell (#2028 step 5; policy decided on #1864). It changes no runtime code.

Why

React 19 hydrates the shell in one task and each server-rendered Suspense boundary in later tasks, so a large page yields between boundaries. Octane hydrates every boundary inside the hydrateRoot task. The frame scenario has no boundaries, so it cannot show the difference. This scenario can, and it gives step 5 a measured bar to beat.

Changes

  • frame-boundaries scenario. The same app frame, with its 11 sections in Suspense boundaries: rail, sidebar header, shortcuts, three nav sections, sidebar footer, header, composer, suggestions and footer. A Settled layout effect in each boundary counts its commit.
  • longest_task_cold and busy_cold ops.
    • Each cold sample is traced from hydrateRoot until every boundary's layout effects have run.
    • The settle point also runs the pending passive effects, so a candidate that runs some of them sooner is not charged for them alone.
    • A task is an outermost main-thread complete event, with its microtask checkpoint folded in. This also catches a task that tracing joined after dispatch, which has no RunTask event.
    • Chromium occasionally drops a long task from a trace. Such a sample shows a longest task shorter than its hydrateRoot call, and reruns, up to three attempts.
    • meta.tasks is the median task count.
  • Early-click gate. Once per scenario, a click on a sidebar section made right after hydrateRoot returns must collapse it.
  • Counted work runs through the last boundary.
  • frame-plain twin from test(bench): track native-read overhead with a plain app-frame twin #2037. BoundedSidebar and Settled also have copies in src/plain/, so the twin build keeps every export frame.tsrx imports. frame-boundaries is in the default scenarios beside frame-plain, and the frame/frame-plain ratio now reads the same per-op samples.
  • Docs. The README and the bench.mjs registry note are updated.

Baseline on main

node benchmarks/app-frame-hydration/run.mjs 15, with Chromium headless, 4× CPU and 15 cold samples per scenario, on main at 5594cb06ea:

scenario hydrateRoot task longest task (median) busy total (median) tasks Blocks / renders
frame 70.1 ms 72.6 ms 72.6 ms 1 1,653 / 1,653
frame-live-sections 69.4 ms 72.0 ms 72.0 ms 1 1,653 / 1,653
frame-boundaries 79.0 ms 82.2 ms 82.2 ms 1 1,674 / 1,674

These were measured on main at 5594cb06ea, before #2037 added frame-plain. After merging current main, a 2-round run passed all four scenarios, frame-plain included, with frame-boundaries still one task (75.2 ms).

On main, frame-boundaries is one long task. Step 5 must reach a longest task under 50 ms at 4× CPU, with busy total flat against this base and frame unchanged.

For comparison, the draft reference implementation #2040 measured 87.7 → 20.5 ms longest task and busy +3.8% in a 15-pair run against main before #2033.

Validation

  • Bench run above. Every sample passed adoption, interaction and unmount verification, and the early-click gate passed for all three scenarios.
  • pnpm format:files on the changed files, and pnpm sync (no generated changes).
  • pnpm typecheck:files on the bench sources. The only errors come from packages/octane/src/runtime.server.ts, server/streamed-signals.ts and error-codes.server.generated.ts, which server.ts pulls in through octane/server. main's own server.ts produces the same 51 errors.
  • Full pnpm test, pnpm typecheck and pnpm format:check were left to CI.
  • perf-review: not applicable. Benchmark only, with no runtime, compiler-output or binding hot path.
  • concise-code:
    • Size: benchmarks +397 −47; no src changes.
    • New files or exports: no new files. New exports are only within the bench fixture: BoundedAppFrame, BoundedSidebar, Settled, hydrateFrameSettled, clickBeforeSettled, and the settle counters in state.ts.
    • Alternative rejected: the prototype's separate slice-probe.mjs, a near-copy of run.mjs. Its tracing is folded into run.mjs instead.

Risk / follow-ups

  • Tracing every cold sample adds a little overhead to hydrate_cold. It is the same for every candidate in a paired run.
  • @octanejs/tanstack-router needed a fix in perf(octane): hydrate server-resolved Suspense boundaries after the shell #2040, because its transitioner assumes its match tree committed before the shell's layout effects. That assumption holds on main, where every boundary hydrates inside the hydrateRoot task. The fix is needed only once boundaries defer, so it belongs with step 5 and is not in this PR.

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 harness only; no production runtime, compiler, or hydration behavior changes.

Overview
Adds a frame-boundaries app-frame hydration scenario and extends the harness so cold samples can be judged on main-thread task shape, not just hydrateRoot time.

The fixture introduces BoundedAppFrame / BoundedSidebar, splitting the same UI into 11 Suspense boundaries with a Settled layout effect that counts boundary commits. hydrateFrameSettled waits for all boundaries (with hydrate-start / hydrate-settled marks), and clickBeforeSettled checks that an immediate sidebar click still works before later tasks run.

run.mjs traces each cold hydration in Chromium, derives longest_task_cold and busy_cold from the trace (with microtask folding and up to three retries when a long task is missing), records median meta.tasks, and runs the early-click gate once per scenario. Counted work and paired comparisons now use the settled hydration path; docs and bench.mjs note the new scenario and ops. No Octane runtime changes—this is the measurement gate for deferring boundary hydration after the shell (#2028 step 5).

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

The frame-boundaries scenario puts the app frame's 11 sections in Suspense
boundaries. Each cold sample is now traced from hydrateRoot until every
boundary's layout effects and the passive effects have run, and reports the
longest main-thread task and the busy total. A sidebar click made right
after hydrateRoot must still collapse its section. On main the scenario
hydrates in one task; it is the gate for hydrating boundaries after the
shell (#2028 step 5): longest task under 50 ms at 4x CPU, busy total flat.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@trueadm
trueadm marked this pull request as ready for review October 13, 2026 12:03
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent test PR: tests only labels Oct 13, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 13, 2026 •

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 c57e379 Oct 13 2026, 12:06 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 13, 2026 •

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 c57e379 Oct 13 2026, 12:06 PM

…pp-frame-boundaries-bench

# Conflicts:
#	benchmarks/app-frame-hydration/README.md
#	benchmarks/app-frame-hydration/run.mjs
#	benchmarks/app-frame-hydration/src/client.ts
#	benchmarks/bench.mjs
@github-actions

Copy link
Copy Markdown
Contributor

Benchmark report

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

Compares 2dfe1c0e0, the merge commit's first parent with 88245a36c 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.100 2.983 +1.6% −3.2% … +5.0% ⚪ within noise
octane-tsrx replace 7.292 7.242 +4.5% −6.6% … +9.6% ⚪ within noise
octane-tsrx add 2.867 2.817 +0.0% ±0.0% … +3.7% ⚪ within noise
octane-tsrx update 0.139 0.133 −0.3% −2.6% … +2.7% ⚪ within noise
octane-tsrx select 0.006 0.006 +0.0% −0.5% … +2.1% ⚪ within noise
octane-tsrx swap 0.021 0.021 +1.9% −3.0% … +6.5% ⚪ within noise
octane-tsrx remove 0.017 0.017 +2.8% +0.4% … +4.7% ⚪ within noise
octane-tsrx runlots 27.192 27.642 +0.5% −0.9% … +3.4% ⚪ within noise
octane-tsrx select_lots 0.007 0.007 −1.0% −1.6% … ±0.0% ⚪ within noise
octane-tsrx clear 54.675 52.700 +0.6% −1.4% … +1.7% ⚪ within noise
octane-jsx run 4.233 4.100 −2.1% −9.3% … +2.6% ⚪ within noise
octane-jsx replace 9.125 8.817 +1.1% −8.3% … +6.8% ⚪ within noise
octane-jsx add 3.658 4.033 +2.8% −2.7% … +5.6% ⚪ within noise
octane-jsx update 0.290 0.277 −0.0% −2.1% … +1.2% ⚪ within noise
octane-jsx select 0.140 0.161 +0.8% −0.5% … +2.9% ⚪ within noise
octane-jsx swap 0.192 0.194 +0.3% −0.5% … +1.9% ⚪ within noise
octane-jsx remove 0.189 0.187 +0.8% −0.5% … +1.8% ⚪ within noise
octane-jsx runlots 31.550 33.650 +1.1% −1.3% … +3.7% ⚪ within noise
octane-jsx select_lots 1.852 1.665 −3.5% −6.5% … −1.5% ⚪ within noise
octane-jsx clear 54.300 53.542 +0.6% −2.2% … +2.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 120 measured values.

@trueadm
trueadm merged commit 951ede7 into main Oct 13, 2026
31 of 33 checks passed
@trueadm
trueadm deleted the test/app-frame-boundaries-bench branch October 13, 2026 12:36
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