Skip to content

perf(ssr): label @try binding arms without a per-call closure - #1644

Merged
trueadm merged 1 commit into
mainfrom
fix/ssr-try-arm-slot
Oct 3, 2026
Merged

trueadm merged 1 commit into
mainfrom
fix/ssr-try-arm-slot

Conversation

@trueadm

@trueadm trueadm commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The weekly ssr-final-replay guard try_closures (target stream-32-1, reference wave-budget, maxRatio 1) breaches on main. The target measures 14,784 closure-expression evaluations under ssrTry against a 13,728 budget: exactly one more per call across 1,056 calls. The breach went unnoticed because the suite's harness crashed until the weekly triage fixed it.

Cause. git bisect run over the suite's own stream-32-1 output, from the budget's origin 13604b9 (2026-09-14, 13,728), names 53db436 (#1582, renderer-free island activation). That commit gave ssrTry a slot arrow that labels a presentation-binding view's arm (0 content, 1 pending, 2 catch). ssrTry evaluated the arrow on every call, including every boundary that passes no binding marker.

Changes

  • The labeller is now the module-level ssrTryArm(content, arm, bindingMarker), and the five call sites pass bindingMarker.
  • MARKERS is still read at call time, so the emitted HTML is byte-for-byte the same.

Validation

  • node benchmarks/ssr-final-replay/work.mjs, with the weekly triage's harness fix applied locally (uncommitted; it is not part of this PR):
    • stream-32-1 try_closures goes 14,784 → 13,728, equal to the wave-budget reference;
    • every other per-call target drops by its try_calls count;
    • the suite's output and negative controls pass, and it exits 0.
  • Existing behavior-root tests from feat(islands): renderer-free island activation and islands-only routes #1582 pin the arm labels, and I checked that they catch a broken hoist:
    • "adopts and switches @Try arms from imported async reads" and "claims a streamed @Try fallback before its segment arrives" both fail when the marker is dropped;
    • the first also fails when the pending arm is labelled 0;
    • all 8 @try behavior-root tests pass on this change (vitest --project octane -t "@try").
  • pnpm typecheck:files and pnpm format:files:check on the changed files.
  • pnpm sync makes no changes on this base (none of its generators read runtime.server.ts).
  • Not run locally: the full pnpm test, pnpm typecheck and pnpm format:check, which are left to CI.

Risk / follow-ups

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. Autofix is disabled.


Note

Low Risk
Refactor-only SSR emit path with unchanged HTML contract; risk is limited to subtle marker/arm labelling bugs, which existing @try behavior tests are meant to catch.

Overview
Hoists the presentation-binding arm labeller out of ssrTry so server @try / Suspense boundaries no longer allocate a per-call slot closure.

The inline arrow that wrapped content with binding markers (0 / 1 / 2) is replaced by module-level ssrTryArm, with bindingMarker passed at each of the five return paths. MARKERS is still consulted at emit time, so hydration markers and HTML stay byte-for-byte the same; the win is one fewer closure evaluation per boundary per SSR pass (fixing the try_closures guard breach from #1582).

Adds an octane patch changeset documenting the optimization.

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

#1582 (53db436) gave ssrTry a `slot` arrow that labels a
presentation-binding view's arm. ssrTry evaluated that arrow on every call,
even when no binding marker was passed. The ssr-final-replay work suite counts
closure expressions evaluated under ssrTry. Its stream-32-1 target rose from
13,728 to 14,784, exactly one more per call across 1,056 calls, which breaches
the wave-budget guard.

The labeller is now the module-level ssrTryArm(content, arm, bindingMarker).
MARKERS is still read at call time and the emitted HTML is unchanged.
stream-32-1 measures 13,728 again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@trueadm
trueadm marked this pull request as ready for review October 3, 2026 07:55
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent perf PR: performance work labels Oct 3, 2026
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Benchmark report

🟢 No size increases and no timing regressions outside noise.

Compares 11a9da935 with 5d7488402 on the same runner. Timing verdicts require a change beyond the combined margin of error (at least 5%) and one 0.1ms timer tick, with the fastest sample also moving beyond that margin. Workflow run

js-framework: 1k/10k row operations (ms, lower is better)

All 20 timed operations (20 within noise)
target operation base head Δ noise
octane-tsrx run 3.32 3.26 −1.8% ±7% ⚪ within noise
octane-tsrx replace 6.76 6.26 −7.4% ±12% ⚪ within noise
octane-tsrx add 3.23 3.26 +0.9% ±15% ⚪ within noise
octane-tsrx update 0.29 0.37 +27.6% ±42% ⚪ within noise
octane-tsrx select 0.13 0.14 +7.7% ±67% ⚪ within noise
octane-tsrx swap 0.34 0.33 −2.9% ±38% ⚪ within noise
octane-tsrx remove 0.34 0.35 +2.9% ±51% ⚪ within noise
octane-tsrx runlots 28.83 27.86 −3.4% ±11% ⚪ within noise
octane-tsrx select_lots 0.31 0.21 −32.3% ±95% ⚪ within noise
octane-tsrx clear 39.08 38.17 −2.3% ±9% ⚪ within noise
octane-jsx run 3.49 3.52 +0.9% ±7% ⚪ within noise
octane-jsx replace 7.24 6.68 −7.7% ±28% ⚪ within noise
octane-jsx add 3.11 3.07 −1.3% ±8% ⚪ within noise
octane-jsx update 0.56 0.58 +3.6% ±41% ⚪ within noise
octane-jsx select 0.36 0.39 +8.3% ±42% ⚪ within noise
octane-jsx swap 0.59 0.63 +6.8% ±33% ⚪ within noise
octane-jsx remove 0.56 0.61 +8.9% ±26% ⚪ within noise
octane-jsx runlots 27.59 27.68 +0.3% ±7% ⚪ within noise
octane-jsx select_lots 2.28 2.17 −4.8% ±21% ⚪ within noise
octane-jsx clear 40.67 39.89 −1.9% ±10% ⚪ within noise

Application bundle size (bytes)

No changes across 45 measured values.

Public-import reachability bundles (bytes)

No changes across 105 measured values.

trueadm added a commit that referenced this pull request Oct 3, 2026
The waived guards now have owner PRs: ssr-final-replay try_closures (#1644),
root-transactions equal_reads (#1643) and codegen-size gzip compiled/source
(#1645). #1645 rebaselines the same codegen-size entry, so this branch no
longer edits it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@trueadm
trueadm merged commit 648a8d2 into main Oct 3, 2026
51 of 54 checks passed
@trueadm
trueadm deleted the fix/ssr-try-arm-slot branch October 3, 2026 08:28
trueadm added a commit that referenced this pull request Oct 3, 2026
…nd re-judge them (#1646)

* ci(bench): triage the weekly ratio-guard breaches so new ones show

The weekly Bench job (`bench.mjs --quick --ratios`) was red with 81 ratio
breaches, 4 suites that wrote no numbers and 4 harness gate failures, so a new
breach was invisible. Every item is now a fix or a rebaseline.

- Harness drift, fixed. Each harness had stopped producing numbers when runtime
  source it anchors on changed:
  - ssr-final-replay: a second suspended loop since 2026-09-29.
  - root-transactions/contracts: staged-DOM text and attribute journaling since
    2026-09-15.
  - signal-dom-bindings: a second native style Block allocation site since
    2026-09-23.
  - codegen-size: the server runtime's lazy streamed-signals chunk since
    2026-09-16.
  - recursive-context: counted a pure-call annotation and trailing newlines as
    output growth.
- Rebaselined, with numbers in each note: five cross-framework bundle-size
  ratios and the workerd script-size ratio. The absolute app and server-render
  budgets are now the ratchet. Lynx's no-worklet byte caps from 2026-08-17 are
  reset to measured + 32, with the background program pinned exactly.
- Fix pending, with dated waivers that expire 2026-10-24, each with an owner
  task:
  - three exact counters the revived harnesses exposed (one extra closure per
    ssrTry, 128 live text reads per 128 unchanged compiled updates, compiled
    output at 1.295x its source);
  - Lynx create ratios and the re-entrant transport gate;
  - superlinear hydrate boundary preparation;
  - Octane Three versus R3F size and frame dispatch;
  - two timing regressions near the timer floor;
  - ten quick-mode timing guards whose samples are noise-bound;
  - the scoped descriptor shape change.
- bench.mjs supports a guard `waiver` ({ reason, expires }). A waived breach
  prints and does not fail, and fails again once the date passes.
  HARNESS_FAILURE_ALLOWLIST now also covers a suite whose harness writes no
  numbers.

The budget breaches (57) clear when the budget reset lands.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(benchmarks): pair and lengthen the timing samples behind waived ratio guards

Twelve timing guards breached in weekly quick runs without a verdict. Their
samples sat near Chromium's 100 µs clock or under two-sample noise, and each
target ran its whole block minutes after the other side of its guard.

- benchmarks/lib/paired.mjs: rotating per-round visit order and a ~20 ms
  sample calibration shared by the harnesses below.
- js-framework-reorder, memo-wall, svg-dashboard, spa-navigation: every
  target's page stays open in one browser and each sample round visits all
  targets; short ops repeat until a sample takes about 20 ms (clicks,
  hook invocations, op batches, and summed navigation legs).
- activity caught-reveal: a sample reveals several independent hidden roots
  in one window, with the small case revealing eight times as many roots so
  both cases do equal work; the cases alternate per round.
- ssr-workerd: an untimed priming spawn per target, then paired cold-spawn
  rounds; quick mode runs six rounds instead of two.
- bench.yml: a `suites` dispatch input to run selected suites.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(benchmarks): collect garbage before every timed spa-navigation leg

The untimed return leg mounts a whole route, and its collection landed
inside the next timed teardown: nav_teardown samples ran at 17-45% rme.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(benchmarks): re-judge the twelve waived timing guards with paired samples

Two quick CI runs of the paired, ~20 ms harness and same-runner A/B runs
against the commits that set each guard decided every waiver:

- Passing, waiver removed: activity reports, ssr-workerd
  cold_spawn_to_first_byte, svg-dashboard pan_zoom, memo-wall
  parent_rerender_equal_A and octane-jsx mount, spa-navigation
  nav_teardown and nav_mount (no Octane change since #674 on one runner).
- Rebaselined: svg-dashboard icon_swap 1.2 -> 1.6, because #983's esbuild
  minification made React 15% faster while Octane stayed flat.
- Confirmed Octane regressions, waiver kept and pointed at the fix:
  js-framework-reorder rotateb (1.41x per click since #639), memo-wall
  one_change_B (1.5x) and ctx_through_wall_B (1.44x), and svg-dashboard
  tooltip_swarm (1.31x since #635).
- The rotateb note claimed React moves every survivor; it moves one. A new
  rotatef guard covers the LIS-vs-lastPlacedIndex differentiator (0.043x).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(benchmarks): rebaseline spa-navigation nav_mount to its CI baseline

The 1.2 ceiling came from a local 0.94x reading. On CI runners #674 itself
measures 1.15x and head 1.09-1.16x, so the ceiling left 3% of quick-mode
headroom; 1.35 keeps a margin while still catching per-node mount growth.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* ci(bench): drop the three weekly waivers that now have fix PRs

The waived guards now have owner PRs: ssr-final-replay try_closures (#1644),
root-transactions equal_reads (#1643) and codegen-size gzip compiled/source
(#1645). #1645 rebaselines the same codegen-size entry, so this branch no
longer edits it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* ci(bench): leave lynx-render to its owner fix

The lynx-render transport gate failure and the create_1k/create_10k ratio
breaches both trace to #885's JSON-encoded transport and now have an owner
fix. Its branch re-notes those two guards, so this branch drops their waivers
and the suite's allowlist entry instead of editing the same entries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* ci(bench): keep harness failures unwaivable and leave descriptor shapes to their owner

Waiving a suite that throws before it writes numbers would hide any crash in
that suite, not only the known shape change, and skip all of its guards. The
scoped-descriptor-shapes defect has an owner fix in progress. That fix re-pins
the harness's expected keys, so narrowing the waiver here would edit the same
assertion. HARNESS_FAILURE_ALLOWLIST is empty again, and a thrown suite failure
always fails the job. Dated waivers remain only on individual ratio guards.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* ci(bench): leave the Three guards to their owner fixes

three-renderer frame_1k_subscribers and the two three-bundle-size ratios have
owner PRs (#1651, #1652) that re-note and ratchet those entries, so this branch
drops their waivers instead of editing the same entries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(benchmarks): point the four kept timing waivers at their attributed fixes

rotateb and ctx_through_wall_B clear with #1655 and #1656; one_change_B's
per-row remainder and tooltip_swarm's scoped-descriptor accessor reads each
have their own fix task.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(benchmarks): point parent_rerender_equal_A's note at its per-commit journal fix

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
trueadm added a commit that referenced this pull request Oct 3, 2026
…1641)

* ci(bench): triage the weekly ratio-guard breaches so new ones show

The weekly Bench job (`bench.mjs --quick --ratios`) was red with 81 ratio
breaches, 4 suites that wrote no numbers and 4 harness gate failures, so a new
breach was invisible. Every item is now a fix or a rebaseline.

- Harness drift, fixed. Each harness had stopped producing numbers when runtime
  source it anchors on changed:
  - ssr-final-replay: a second suspended loop since 2026-09-29.
  - root-transactions/contracts: staged-DOM text and attribute journaling since
    2026-09-15.
  - signal-dom-bindings: a second native style Block allocation site since
    2026-09-23.
  - codegen-size: the server runtime's lazy streamed-signals chunk since
    2026-09-16.
  - recursive-context: counted a pure-call annotation and trailing newlines as
    output growth.
- Rebaselined, with numbers in each note: five cross-framework bundle-size
  ratios and the workerd script-size ratio. The absolute app and server-render
  budgets are now the ratchet. Lynx's no-worklet byte caps from 2026-08-17 are
  reset to measured + 32, with the background program pinned exactly.
- Fix pending, with dated waivers that expire 2026-10-24, each with an owner
  task:
  - three exact counters the revived harnesses exposed (one extra closure per
    ssrTry, 128 live text reads per 128 unchanged compiled updates, compiled
    output at 1.295x its source);
  - Lynx create ratios and the re-entrant transport gate;
  - superlinear hydrate boundary preparation;
  - Octane Three versus R3F size and frame dispatch;
  - two timing regressions near the timer floor;
  - ten quick-mode timing guards whose samples are noise-bound;
  - the scoped descriptor shape change.
- bench.mjs supports a guard `waiver` ({ reason, expires }). A waived breach
  prints and does not fail, and fails again once the date passes.
  HARNESS_FAILURE_ALLOWLIST now also covers a suite whose harness writes no
  numbers.

The budget breaches (57) clear when the budget reset lands.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* ci(bench): drop the three weekly waivers that now have fix PRs

The waived guards now have owner PRs: ssr-final-replay try_closures (#1644),
root-transactions equal_reads (#1643) and codegen-size gzip compiled/source
(#1645). #1645 rebaselines the same codegen-size entry, so this branch no
longer edits it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* ci(bench): leave lynx-render to its owner fix

The lynx-render transport gate failure and the create_1k/create_10k ratio
breaches both trace to #885's JSON-encoded transport and now have an owner
fix. Its branch re-notes those two guards, so this branch drops their waivers
and the suite's allowlist entry instead of editing the same entries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* ci(bench): keep harness failures unwaivable and leave descriptor shapes to their owner

Waiving a suite that throws before it writes numbers would hide any crash in
that suite, not only the known shape change, and skip all of its guards. The
scoped-descriptor-shapes defect has an owner fix in progress. That fix re-pins
the harness's expected keys, so narrowing the waiver here would edit the same
assertion. HARNESS_FAILURE_ALLOWLIST is empty again, and a thrown suite failure
always fails the job. Dated waivers remain only on individual ratio guards.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* ci(bench): leave the Three guards to their owner fixes

three-renderer frame_1k_subscribers and the two three-bundle-size ratios have
owner PRs (#1651, #1652) that re-note and ratchet those entries, so this branch
drops their waivers instead of editing the same entries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

1 participant