Skip to content

perf(octane): skip the warm-plan stack restore when a render registered no plan - #1666

Merged
trueadm merged 4 commits into
mainfrom
perf/warm-plan-checkpoint-guard
Oct 3, 2026
Merged

trueadm merged 4 commits into
mainfrom
perf/warm-plan-checkpoint-guard

Conversation

@trueadm

@trueadm trueadm commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

renderBlockInner and the lite component path (componentSlotLite) restore the warm-plan stack on every exit with ACTIVE_WARM_PLANS.length = warmPlanCheckpoint. Most renders register no plan, so the length is usually unchanged. A V8 line profile of repeated memo-wall __oneChangeB attributed about 5% of samples to that line, on this build and on the #639-era build (73b22fd).

Both sites now compare first:

if (ACTIVE_WARM_PLANS.length !== warmPlanCheckpoint)
	ACTIVE_WARM_PLANS.length = warmPlanCheckpoint;

The behavior is unchanged, because the store did nothing whenever the lengths were equal.

Evidence

Paired same-runner A/B against main (ac729dc): Bench run 37119169008 on scratch/ab-warm-plan-guard. That branch is never merged, and its only packages/ difference from main is this guard.

  • Harness: the memo-wall and recursive-context octane-tsrx fixtures are built from both trees, and each build is served twice. Every op calibrates one ~20 ms batch, and each sample round visits all four pages in rotating order.
  • Two kinds of estimate: head/base and head2/base2 measure the change. base2/base and head2/head compare a build with itself, so they show the noise.
  • Runs: three runs of 60 rounds each, giving six change estimates and six same-build estimates per op.
  • Semantic gate: every page runs the identical op sequence, so the final DOM hash and render probes must match across all four pages. They matched for every op in every run.
suite op change, pooled same-build, pooled change, 6 estimates same-build, 6 estimates
memo-wall one_change_B 0.865 [0.854, 0.873] 1.012 0.83–0.93 0.97–1.11
memo-wall ctx_through_wall_A 0.947 [0.944, 0.952] 0.990 0.92–0.99 0.95–1.02
memo-wall ctx_through_wall_B 0.951 [0.943, 0.957] 0.996 0.92–0.98 0.98–1.02
recursive-context update_root 0.953 [0.949, 0.958] 0.992 0.92–0.97 0.96–1.01
recursive-context update_partial 0.960 [0.955, 0.967] 0.990 0.95–0.98 0.97–1.01
recursive-context partial_cycle 0.984 [0.979, 0.987] 1.005 0.97–1.01 0.98–1.02
recursive-context remount 0.972 [0.965, 0.978] 1.016 0.94–1.04 0.96–1.06
memo-wall remount 1.010 [1.005, 1.019] 1.000 1.00–1.04 0.99–1.03
memo-wall one_change_A 0.995 [0.985, 1.005] 0.990 0.93–1.06 0.93–1.03
memo-wall parent_rerender_equal_A/B 1.000 1.000 1.00 1.00

The ratios are head/base, so values below 1 mean the guard is faster. The bracketed intervals are bootstrap intervals over all 360 pairs. They ignore correlation within a run, so the six-estimate ranges are the more honest spread.

  • Clear wins: every op in bold has all six change estimates below the same-build range. one_change_B gains the most because each op on this build enters 1,000 de-opt list item renders. Once perf(octane): update a same-component de-opt list item without entering its render #1664 lands, those items skip their render, and that gain should shrink. The context and recursive-context wins come from ordinary component re-renders.
  • No change: the memo bails render nothing and stay at exactly 1.000.
  • No clear effect: mount, partial_cycle and one_change_A stay inside the same-build spread. memo-wall remount reads 1.010 pooled, but its range (1.00–1.04) overlaps its same-build range (0.99–1.03), so no regression is shown.
  • js-framework (benchmarks/js-framework/pair.mjs, 40 pairs, with a head-vs-head A/A run): every op stays inside the A/A spread.
    • Its exact work counters are identical on both sides: 64 of 64 calls_*, dom_* and mount counters match.

Bundle bytes: bundle-size and bundle-reachability were built locally against both sources. Every client bundle grows by +17 raw bytes. gzip moves −5 to +22 and brotli −59 to +129, which is minifier noise. Server bundles are unchanged.

Validation

  • pnpm format:check: not run. pnpm format:files:check passed on the changed files.
  • pnpm typecheck: not run. pnpm typecheck:files passed on the new test and fixture.
  • pnpm test: left to CI.
  • targeted tests: vitest run --project octane packages/octane/tests/warm-plan-checkpoint.test.ts passes. The same file plus parallel-use.test.ts and warm-plan-reentrancy.test.ts (67 tests) passed during the break checks.

The new test, warm-plan-checkpoint.test.ts, mounts a frame whose plan warms a leaf. A descendant then re-renders alone and suspends. That must not run the finished frame's plan, which would request the leaf again. The test covers a full frame and a lite frame.

  • Full-frame guard inverted (===): both cases fail and start leaf:1 twice.

  • Lite-path guard inverted alone: the tests stay green, and so do parallel-use and warm-plan-reentrancy. That restore is redundant today, for two reasons:

    • A lite render always sits inside a full renderBlockInner frame (including @try bodies, which render through renderBlock). That frame restores to an equal or lower checkpoint before any later episode.
    • Within one episode, re-running a plan only claims cache entries that already exist.

    So inverting the lite-path guard cannot change what a consumer sees.

Risk / follow-ups

  • The scratch harness and its results stay on scratch/ab-warm-plan-guard, which is not to be merged.
  • The PR bench's own paired js-framework run will report on this PR as well.

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
Micro-optimization with identical semantics when stack length is unchanged; new tests guard warm-plan scoping on suspend paths.

Overview
Render exit no longer always writes ACTIVE_WARM_PLANS.length. On both the main render path (renderBlockInner) and the lite component path, the runtime used to reset the warm-plan stack on every frame exit even when most renders never push a plan. It now restores only when ACTIVE_WARM_PLANS.length !== warmPlanCheckpoint, which is a no-op when lengths already match but avoids the cost of redundant length stores on hot paths.

A changeset notes measurable wins on memo-wall and context-heavy benchmarks. Regression coverage adds a fixture plus tests (full and lite frames) that assert a finished frame’s warm plan does not keep warming sibling/leaf requests when a descendant re-renders alone and suspends—behavior that depends on the checkpoint restore still happening when the stack actually grew.

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

…ed no plan

renderBlockInner and the lite component path restored the warm-plan stack on
every exit by storing ACTIVE_WARM_PLANS.length, although most renders register
no plan and leave the length unchanged. A V8 line profile of repeated memo-wall
one_change_B attributed about 5% of samples to that store. Both sites now
compare first.

Paired same-runner A/B against main (three runs, each build served twice, so
every op has six A/B and six same-build estimates): memo-wall one_change_B
0.87x, ctx_through_wall_A/B 0.95x, recursive-context update_root 0.95x and
update_partial 0.96x, all six estimates below the same-build spread. Memo bails
that render nothing stay at exactly 1.00x; mount and js-framework stay inside
the same-build spread, and js-framework work counters are identical. +17 raw
bytes per client bundle.

The test pins that a frame's warm plan ends with its render: a descendant that
later re-renders alone and suspends must not start the frame's other requests
again. Inverting the full-frame guard makes both cases start the leaf request
twice.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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
@trueadm
trueadm marked this pull request as ready for review October 3, 2026 11:41
@blacksmith-sh

This comment has been minimized.

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

  • 🔴 bundle-size: 32 value(s) increased within budget
  • 🔴 bundle-reachability: 53 value(s) increased within budget

Compares 425a32a5f, the merge commit's first parent with 075c45c23 on the same runner. A byte value over its committed budget or any increase in a js-framework work counter fails this check. 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.750 2.725 ±0.0% −3.2% … ±0.0% ⚪ within noise
octane-tsrx replace 5.408 5.358 −3.7% −7.7% … +0.9% ⚪ within noise
octane-tsrx add 2.433 2.425 −3.8% −4.0% … ±0.0% ⚪ within noise
octane-tsrx update 0.135 0.130 −1.1% −6.5% … +6.6% ⚪ within noise
octane-tsrx select 0.005 0.006 −1.1% −3.1% … +2.7% ⚪ within noise
octane-tsrx swap 0.035 0.035 +0.5% −1.4% … +2.1% ⚪ within noise
octane-tsrx remove 0.018 0.018 −0.8% −3.3% … +2.6% ⚪ within noise
octane-tsrx runlots 26.592 26.300 +1.0% −1.2% … +6.4% ⚪ within noise
octane-tsrx select_lots 0.006 0.006 −3.9% −5.4% … −3.0% ⚪ within noise
octane-tsrx clear 41.750 40.217 −0.1% −2.4% … +3.9% ⚪ within noise
octane-jsx run 3.300 3.483 +0.0% −0.0% … +3.1% ⚪ within noise
octane-jsx replace 6.308 6.375 −3.0% −7.0% … +3.3% ⚪ within noise
octane-jsx add 2.933 2.917 ±0.0% −0.0% … +3.2% ⚪ within noise
octane-jsx update 0.249 0.245 −0.0% −0.7% … +1.4% ⚪ within noise
octane-jsx select 0.120 0.121 +1.3% +1.0% … +1.6% ⚪ within noise
octane-jsx swap 0.216 0.230 +1.1% ±0.0% … +1.4% ⚪ within noise
octane-jsx remove 0.164 0.164 ±0.0% −0.6% … +1.2% ⚪ within noise
octane-jsx runlots 26.850 26.900 −0.4% −1.6% … +2.7% ⚪ within noise
octane-jsx select_lots 1.395 1.379 −1.5% −3.5% … +0.9% ⚪ within noise
octane-jsx clear 45.683 45.200 −1.3% −2.6% … −0.2% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

target metric base head Δ
octane-tsrx js_raw 125,251 125,268 +17 (+0.0%) 🔴
octane-tsrx js_gzip 41,375 41,386 +11 (+0.0%) 🔴
octane-tsrx js_brotli 36,542 36,483 −59 (−0.2%) 🟢
octane-tsrx app_gzip 2,562 2,564 +2 (+0.1%) 🔴
octane-tsrx app_brotli 2,226 2,224 −2 (−0.1%) 🟢
octane-tsrx fw_raw 117,739 117,756 +17 (+0.0%) 🔴
octane-tsrx fw_gzip 38,813 38,822 +9 (+0.0%) 🔴
octane-tsrx fw_brotli 34,316 34,259 −57 (−0.2%) 🟢
octane-tsrx todo_js_raw 140,728 140,745 +17 (+0.0%) 🔴
octane-tsrx todo_js_gzip 46,441 46,460 +19 (+0.0%) 🔴
octane-tsrx todo_js_brotli 40,816 40,762 −54 (−0.1%) 🟢
octane-tsrx todo_app_brotli 2,118 2,122 +4 (+0.2%) 🔴
octane-tsrx todo_fw_raw 135,618 135,635 +17 (+0.0%) 🔴
octane-tsrx todo_fw_gzip 43,964 43,983 +19 (+0.0%) 🔴
octane-tsrx todo_fw_brotli 38,698 38,640 −58 (−0.1%) 🟢
octane-tsrx chat_js_raw 139,848 139,865 +17 (+0.0%) 🔴
octane-tsrx chat_js_gzip 46,341 46,348 +7 (+0.0%) 🔴
octane-tsrx chat_js_brotli 40,693 40,690 −3 (−0.0%) 🟢
octane-tsrx chat_app_brotli 2,635 2,641 +6 (+0.2%) 🔴
octane-tsrx chat_fw_raw 133,195 133,212 +17 (+0.0%) 🔴
octane-tsrx chat_fw_gzip 43,362 43,369 +7 (+0.0%) 🔴
octane-tsrx chat_fw_brotli 38,058 38,049 −9 (−0.0%) 🟢
octane-tsrx weather_js_raw 176,826 176,843 +17 (+0.0%) 🔴
octane-tsrx weather_js_gzip 57,788 57,799 +11 (+0.0%) 🔴
octane-tsrx weather_js_brotli 50,315 50,388 +73 (+0.1%) 🔴
octane-tsrx weather_app_brotli 7,556 7,587 +31 (+0.4%) 🔴
octane-tsrx weather_fw_raw 150,147 150,164 +17 (+0.0%) 🔴
octane-tsrx weather_fw_gzip 48,754 48,765 +11 (+0.0%) 🔴
octane-tsrx weather_fw_brotli 42,759 42,801 +42 (+0.1%) 🔴
octane-tsrx bindings_js_raw 718,810 718,827 +17 (+0.0%) 🔴
octane-tsrx bindings_js_gzip 240,407 240,399 −8 (−0.0%) 🟢
octane-tsrx bindings_js_brotli 204,738 204,676 −62 (−0.0%) 🟢
octane-tsrx bindings_app_gzip 121,728 121,716 −12 (−0.0%) 🟢
octane-tsrx bindings_app_brotli 101,836 101,713 −123 (−0.1%) 🟢
octane-tsrx bindings_fw_raw 362,889 362,906 +17 (+0.0%) 🔴
octane-tsrx bindings_fw_gzip 118,679 118,683 +4 (+0.0%) 🔴
octane-tsrx bindings_fw_brotli 102,902 102,963 +61 (+0.1%) 🔴
octane-jsx js_raw 227,064 227,081 +17 (+0.0%) 🔴
octane-jsx js_gzip 72,457 72,458 +1 (+0.0%) 🔴
octane-jsx js_brotli 62,728 62,757 +29 (+0.0%) 🔴
octane-jsx app_brotli 2,505 2,494 −11 (−0.4%) 🟢
octane-jsx fw_raw 218,605 218,622 +17 (+0.0%) 🔴
octane-jsx fw_gzip 69,521 69,522 +1 (+0.0%) 🔴
octane-jsx fw_brotli 60,223 60,263 +40 (+0.1%) 🔴

10 other measured values are unchanged.

Public-import reachability bundles (bytes)

target metric base head Δ
cli-spa-starter raw 115,043 115,060 +17 (+0.0%) 🔴
cli-spa-starter gzip 38,817 38,827 +10 (+0.0%) 🔴
cli-spa-starter brotli 33,943 33,972 +29 (+0.1%) 🔴
root-static-specialized raw 76,977 76,994 +17 (+0.0%) 🔴
root-static-specialized gzip 25,537 25,548 +11 (+0.0%) 🔴
root-static-specialized brotli 22,763 22,744 −19 (−0.1%) 🟢
root-chained-jsx raw 84,303 84,320 +17 (+0.0%) 🔴
root-chained-jsx gzip 27,865 27,867 +2 (+0.0%) 🔴
root-chained-jsx brotli 24,820 24,834 +14 (+0.1%) 🔴
root-static raw 203,303 203,320 +17 (+0.0%) 🔴
root-static gzip 64,638 64,639 +1 (+0.0%) 🔴
root-static brotli 56,047 56,059 +12 (+0.0%) 🔴
root-static-local raw 76,980 76,997 +17 (+0.0%) 🔴
root-static-local gzip 25,524 25,536 +12 (+0.0%) 🔴
root-static-local brotli 22,753 22,755 +2 (+0.0%) 🔴
hooks-state raw 89,041 89,058 +17 (+0.0%) 🔴
hooks-state gzip 29,538 29,549 +11 (+0.0%) 🔴
hooks-state brotli 26,319 26,346 +27 (+0.1%) 🔴
prop-attributes raw 95,655 95,672 +17 (+0.0%) 🔴
prop-attributes gzip 31,695 31,691 −4 (−0.0%) 🟢
prop-attributes brotli 28,173 28,142 −31 (−0.1%) 🟢
context raw 109,129 109,146 +17 (+0.0%) 🔴
context gzip 36,057 36,061 +4 (+0.0%) 🔴
context brotli 31,956 31,944 −12 (−0.0%) 🟢
hydrate-root raw 173,265 173,282 +17 (+0.0%) 🔴
hydrate-root gzip 54,916 54,922 +6 (+0.0%) 🔴
hydrate-root brotli 47,933 47,896 −37 (−0.1%) 🟢
deferred-hydration raw 236,613 236,630 +17 (+0.0%) 🔴
deferred-hydration gzip 74,795 74,791 −4 (−0.0%) 🟢
deferred-hydration brotli 64,567 64,562 −5 (−0.0%) 🟢
suspense-transition raw 165,071 165,088 +17 (+0.0%) 🔴
suspense-transition gzip 52,970 52,972 +2 (+0.0%) 🔴
suspense-transition brotli 46,374 46,352 −22 (−0.0%) 🟢
component-owned-effects raw 81,491 81,508 +17 (+0.0%) 🔴
component-owned-effects gzip 26,822 26,826 +4 (+0.0%) 🔴
component-owned-effects brotli 23,890 23,924 +34 (+0.1%) 🔴
binding-hooks raw 87,556 87,573 +17 (+0.0%) 🔴
binding-hooks gzip 29,298 29,295 −3 (−0.0%) 🟢
binding-hooks brotli 26,095 26,094 −1 (−0.0%) 🟢
binding-base-ui-vite raw 213,534 213,551 +17 (+0.0%) 🔴
binding-base-ui-vite gzip 68,212 68,234 +22 (+0.0%) 🔴
binding-base-ui-vite brotli 59,093 59,222 +129 (+0.2%) 🔴
binding-base-ui-esbuild raw 211,479 211,496 +17 (+0.0%) 🔴
binding-base-ui-esbuild gzip 68,150 68,166 +16 (+0.0%) 🔴
binding-base-ui-esbuild brotli 59,105 59,194 +89 (+0.2%) 🔴
binding-radix-vite raw 215,466 215,483 +17 (+0.0%) 🔴
binding-radix-vite gzip 68,752 68,749 −3 (−0.0%) 🟢
binding-radix-vite brotli 59,634 59,624 −10 (−0.0%) 🟢
binding-radix-esbuild raw 213,370 213,387 +17 (+0.0%) 🔴
binding-radix-esbuild gzip 68,753 68,763 +10 (+0.0%) 🔴
binding-radix-esbuild brotli 59,663 59,623 −40 (−0.1%) 🟢
binding-mantine-hooks-vite raw 96,138 96,155 +17 (+0.0%) 🔴
binding-mantine-hooks-vite gzip 31,872 31,874 +2 (+0.0%) 🔴
binding-mantine-hooks-vite brotli 28,306 28,351 +45 (+0.2%) 🔴
binding-mantine-hooks-esbuild raw 95,741 95,758 +17 (+0.0%) 🔴
binding-mantine-hooks-esbuild gzip 32,014 32,030 +16 (+0.0%) 🔴
binding-mantine-hooks-esbuild brotli 28,486 28,455 −31 (−0.1%) 🟢
binding-apollo-client-vite raw 358,526 358,543 +17 (+0.0%) 🔴
binding-apollo-client-vite gzip 112,298 112,310 +12 (+0.0%) 🔴
binding-apollo-client-vite brotli 98,049 98,015 −34 (−0.0%) 🟢
binding-apollo-client-esbuild raw 361,463 361,480 +17 (+0.0%) 🔴
binding-apollo-client-esbuild gzip 114,490 114,495 +5 (+0.0%) 🔴
binding-apollo-client-esbuild brotli 99,812 99,741 −71 (−0.1%) 🟢
binding-usehooks-ts-vite raw 96,919 96,936 +17 (+0.0%) 🔴
binding-usehooks-ts-vite gzip 32,111 32,120 +9 (+0.0%) 🔴
binding-usehooks-ts-vite brotli 28,582 28,587 +5 (+0.0%) 🔴
binding-usehooks-ts-esbuild raw 96,507 96,524 +17 (+0.0%) 🔴
binding-usehooks-ts-esbuild gzip 32,251 32,261 +10 (+0.0%) 🔴
binding-usehooks-ts-esbuild brotli 28,647 28,665 +18 (+0.1%) 🔴

36 other measured values are unchanged.

@vercel
vercel Bot temporarily deployed to Preview – octane-website October 3, 2026 13:26 Inactive
@vercel

vercel Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated
octane-website Skipped Skipped Oct 3, 2026 1:26pm UTC
octane-website-mcp Skipped Skipped Oct 3, 2026 1:26pm UTC

Request Review

@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp October 3, 2026 13:26 Inactive
trueadm added a commit that referenced this pull request Oct 3, 2026
Main gained #1685, which raised 51 budgets for the useLayoutSnapshot
commit-phase priority fix (#1686), and #1681/#1665. Re-measured on main
425a32a: each of #1663, #1664 and #1666 merged alone, and all three
plus #1686 merged together. Each budget is the larger of main's value and
the largest measured value plus 32 (raw/gzip) or 256 (brotli), so the
three perf PRs and #1686 can land in any order.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm added a commit that referenced this pull request Oct 3, 2026
…nd warm-plan perf PRs (#1687)

Three open runtime perf pull requests fail the PR bench byte gate on main
12c32ec, and landing any two of them stacks past the 32-byte headroom:

- #1664 (de-opt survivor fast path): +809 raw / +290 gzip
  in the bindings app framework chunk, which #1676 did not raise because
  #1639 added that budget key first; +20 raw in every compiled-only app.
- #1666 (warm-plan length guard): +17 raw in every client
  bundle, two `!==` guards.
- #1663 (scoped-value read-once): +2 raw / +30-70 gzip in
  descriptor-renderer bundles, a compression shift from the restructured
  childSlot reads.

Main had already spent part of the headroom: bindings framework gzip
measured exactly its budget and deferred-hydration raw had 8 bytes left.

Each budget is set to the largest value measured across each PR merged
alone with main and all of them merged together (plus #1665, which moves
none of these values), plus 32 for raw and gzip and 256 for brotli. Only
values one of those trees exceeds change.

Co-authored-by: Claude Opus 5.5 <[email protected]>
@trueadm
trueadm merged commit 414e192 into main Oct 3, 2026
30 checks passed
@trueadm
trueadm deleted the perf/warm-plan-checkpoint-guard branch October 3, 2026 19:59
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