Skip to content

ci(bench): guard the Rspack imported void-root bundle saving - #1841

Merged
trueadm merged 1 commit into
mainfrom
test/rspack-void-root-ratio
Oct 7, 2026
Merged

trueadm merged 1 commit into
mainfrom
test/rspack-void-root-ratio

Conversation

@trueadm

@trueadm trueadm commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #1840, which lets Rspack production builds specialize an imported void root (#1839). The adapter tests guard that the specialization happens, but nothing guarded the bundle saving it exists for. This adds a lane to benchmarks/codegen-size and six ratio guards for that saving.

The new lane, benchmarks/codegen-size/rspack-void-roots.mjs, builds the real OctaneRspackPlugin in production mode with the runtime bundled. The saving is the generic returned-value renderer that the minifier can drop once the root is proven, so an externalized runtime can't show it. Each scenario is built twice from identical authored source and identical loaders:

  • proven: the adapter specializes the root.
  • control: a post loader on the entry, after SWC, routes the root's import through a plain re-export module. The adapter deliberately leaves that edge unproven. In the proven build the same loader runs as a no-op, so the two configurations differ only in its options.

Each build asserts the following before its sizes are reported:

  • The adapter decides the variant. The proven entry calls __createVoidRoot or __hydrateVoidRoot and no longer names the public factory. The control entry keeps the public factory and imports the re-export.
  • Only the root differs. Every module other than the entry is byte-identical across the two variants at seal. That includes the component calls the adapter proves inside the tree, so the delta is the root proof alone.
  • Same behavior. Both variants run in jsdom and must produce identical DOM, with no console errors:
    • hydrate adopts the server <p> in place.
    • tree checks the mount, a keyed update through a second root.render, and unmount.

jsdom is added to the suite through the catalog, with pnpm-lock.yaml updated by pnpm install. The other 88 files are pnpm sync output: the lockfile hash recorded in each parity audit and in the evals manifest.

Measurements

Measured under Node 24.18 and Rspack 2.1.4 on main at b8e55da. Bytes are deterministic: two runs were byte-identical.

Scenario minified gzip brotli
hydrate: the #1839 shape, one hydrateRoot over an imported void leaf 289,043 → 178,334 (0.617×) 86,560 → 52,075 (0.602×) 72,159 → 44,522 (0.617×)
tree: createRoot over 4 imported void components, a keyed @for, and an update 209,250 → 134,160 (0.641×) 65,380 → 42,610 (0.652×) 54,993 → 36,330 (0.661×)

The hydrate pair matches #1840's issue measurement (86,370 → 51,880 gzip). The tree pair saves less than #1840's nested-tree figure (63.4 → 33.7 KB) for two reasons:

Guards

The guards are maxRatio bounds on minified, gzip and brotli for rspack-void-{hydrate,tree}-proven against -control:

  • hydrate: 0.70, 0.68 and 0.70.
  • tree: 0.72, 0.73 and 0.74.

That leaves about 0.08 of headroom for shared runtime growth, while still catching a specialized root that pulls half its saving back in.

Each guard was checked against a deliberate break, then reverted:

  • Making __createVoidRoot use the generic output handler (renderReturnedValue) takes tree to 1.00×, breaching all three tree guards. The DOM check still passes, so only the guard catches this.
  • Making __hydrateVoidRoot use it takes hydrate to 1.00×, breaching all three hydrate guards.
  • Not installing installVoidComponentProofs fails the lane before measurement: hydrate: proven entry lacks __hydrateVoidRoot.

Validation

  • pnpm format:check: not run in full. pnpm format:files:check passes on every authored file.
  • pnpm typecheck: not run. No TypeScript project includes benchmarks/codegen-size/*.mjs.
  • pnpm test: not run. This change only touches the benchmark suite and the lockfile.
  • targeted:
    • node benchmarks/bench.mjs --quick --ratios codegen-size checks 40 guards. All six new guards pass.
    • The one breach is the existing css-modules-client-proven/control minified guard, below. It fails identically on main.
    • pnpm sync leaves the tree clean.

Risk / follow-ups

  • Not caused by this PR: on main, the compiler-only css-modules-client minified guard breaches at 2,294 / 2,582 = 0.888× against maxRatio 0.84. It started with e233e4a (perf(octane): stop shipping the signal binding runtime in apps without signals #1762, which stopped shipping the signal binding runtime in apps without signals). Before that commit the pair was 3,183 / 3,890 = 0.818×. The weekly Bench workflow will report it until it is rebaselined or fixed. It is left to its own PR.
  • The lane adds 4 production Rspack builds to codegen-size, about 5 s.
  • The guards bound ratios, not absolute bytes. Growth in runtime code shared by both variants moves the ratio toward 1.0 slowly. It takes about 21 KB of shared gzip growth to trip the hydrate gzip guard, and about 19 KB for tree.

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
Benchmark harness, ratio baselines, and lockfile/audit metadata only; no production compiler or adapter logic changes in this diff.

Overview
Adds codegen-size regression coverage for the Rspack adapter’s imported void-root specialization (follow-up to #1840): bundle size when the runtime is included and the minifier can drop the generic root renderer.

A new harness rspack-void-roots.mjs builds proven vs control pairs for hydrate (single hydrateRoot over an imported void leaf) and tree (createRoot over four void components with keyed @for and an update). The control reroutes the root import through a re-export the adapter does not prove; all other modules must match at seal. Both variants run in jsdom with identical DOM (and hydration adoption for hydrate). run.mjs wires the new targets and logging; jsdom is added to the suite deps.

baselines/ratios.json gains six same-run maxRatio guards (minified/gzip/brotli × hydrate/tree). benchmarks/README.md documents the rspack-void-* targets.

Lockfile refresh from jsdom: pnpm-lock.yaml and the usual pnpm sync lockfileSha256 updates across parity audit JSON files.

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

Add a codegen-size lane that builds the real Rspack adapter with the
runtime bundled, in two variants from identical authored source: proven,
and a control whose post loader routes the root's import through a
re-export the adapter leaves unproven. Every other module must stay
byte-identical and both variants must render the same DOM in jsdom.

Ratio guards cover minified, gzip and Brotli for the #1839
hydrateRoot shape (gzip 52,075 / 86,560 = 0.60x) and a createRoot tree of
four imported void components with an update (42,610 / 65,380 = 0.65x).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@trueadm
trueadm marked this pull request as ready for review October 7, 2026 10:34
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent ci PR: CI or build pipeline labels Oct 7, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 7, 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 Preview URL Updated (UTC)
✅ Deployment successful!
View logs
octane-website 3433778 Commit Preview URL

Branch Preview URL
Oct 07 2026, 10:48 AM

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Benchmark report

  • 🟡 js-framework: 1 timed operation(s) slower beyond ±3%

Compares b8e55da03, the merge commit's first parent with 473fa9c52 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

target operation base ms head ms head/base 95% CI
octane-jsx select_lots 1.576 1.796 +19.8% +16.2% … +21.9% 🟡 slower
All 20 timed operations (19 without a verdict)
target operation base ms head ms head/base 95% CI
octane-tsrx run 2.400 2.492 +0.0% ±0.0% … +4.3% ⚪ within noise
octane-tsrx replace 6.292 6.033 −2.4% −5.3% … +5.7% ⚪ within noise
octane-tsrx add 2.475 2.533 ±0.0% −3.8% … +4.3% ⚪ within noise
octane-tsrx update 0.139 0.142 +2.0% −5.8% … +5.4% ⚪ within noise
octane-tsrx select 0.006 0.006 +0.6% −0.8% … +3.6% ⚪ within noise
octane-tsrx swap 0.035 0.035 +1.0% −1.6% … +3.8% ⚪ within noise
octane-tsrx remove 0.018 0.018 +2.2% −0.7% … +4.5% ⚪ within noise
octane-tsrx runlots 26.525 26.883 −0.2% −2.8% … +3.7% ⚪ within noise
octane-tsrx select_lots 0.006 0.006 ±0.0% −1.4% … +1.1% ⚪ within noise
octane-tsrx clear 50.492 49.575 +1.3% −1.9% … +4.1% ⚪ within noise
octane-jsx run 3.417 3.417 +0.0% −3.0% … +3.2% ⚪ within noise
octane-jsx replace 7.883 7.908 +4.0% −7.8% … +21.4% ⚪ within noise
octane-jsx add 3.150 3.133 ±0.0% −0.0% … +3.3% ⚪ within noise
octane-jsx update 0.274 0.263 +0.3% −1.6% … +3.3% ⚪ within noise
octane-jsx select 0.150 0.152 +2.8% +0.5% … +3.9% ⚪ within noise
octane-jsx swap 0.223 0.228 −1.1% −2.2% … ±0.0% ⚪ within noise
octane-jsx remove 0.179 0.176 +0.7% −2.0% … +2.4% ⚪ within noise
octane-jsx runlots 28.392 28.325 +0.2% −1.7% … +2.9% ⚪ within noise
octane-jsx select_lots 1.576 1.796 +19.8% +16.2% … +21.9% 🟡 slower
octane-jsx clear 54.742 58.658 +1.3% −2.0% … +6.4% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

No changes across 60 measured values.

Public-import reachability bundles (bytes)

No changes across 108 measured values.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 7, 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 Preview URL Updated (UTC)
✅ Deployment successful!
View logs
octane-website-mcp 3433778 Commit Preview URL

Branch Preview URL
Oct 07 2026, 10:51 AM

@trueadm
trueadm merged commit 6c0bd4e into main Oct 7, 2026
53 checks passed
@trueadm
trueadm deleted the test/rspack-void-root-ratio branch October 7, 2026 11: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 ci PR: CI or build pipeline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant