Repository navigation
feat(bench): show bundle-size as a range up to the whole client runtime - #1738
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Ceiling can invert bundle-size ranges
- A bundle-size bar now extends only when the whole-API ceiling clears the shipped size by at least 1 kB, so gzip noise no longer draws an inverted or one-kilobyte range, and the track scales to the solid bar.
Or push these changes by commenting:
@cursor push c8619174a1
Preview (c8619174a1)
diff --git a/website/src/components/BenchBars.tsrx b/website/src/components/BenchBars.tsrx
--- a/website/src/components/BenchBars.tsrx
+++ b/website/src/components/BenchBars.tsrx
@@ -76,14 +76,20 @@
ink: FillInk;
}
-// A ceiling that prints the same as its value would read "10 kB–10 kB", so the
-// bar stays a single value.
+// A ceiling draws a range only when it is a higher displayed value. The
+// whole-runtime build is separate from the fixture, so gzip can disagree by a
+// few hundred bytes in either direction and still round across a kilobyte.
+// That noise is not unused client API: a byte ceiling has to clear the bar by
+// at least 1 kB, and a ceiling below the bar must not invert the label.
function rangeEnd(
value: number,
ceiling: number | undefined,
format: (value: unknown) => string,
): number | undefined {
- return ceiling !== undefined && format(ceiling) !== format(value) ? ceiling : undefined;
+ if (ceiling === undefined || !(ceiling > value)) return undefined;
+ if (format(ceiling) === format(value)) return undefined;
+ if (format === fmtBytes && ceiling - value < 1024) return undefined;
+ return ceiling;
}
function geomeanRatio(pairs: Array<[number, number]>): number {
@@ -101,7 +107,9 @@
function barView(present: BarItem[], missing: BarView['missing']): BarView {
present.sort((a, b) => a.value - b.value);
let max = 0;
- for (const item of present) max = Math.max(max, item.ceiling ?? item.value);
+ // The track has to cover the solid bar. A ceiling below its value is noise,
+ // not a shorter scale.
+ for (const item of present) max = Math.max(max, item.value, item.ceiling ?? 0);
// 1.05 headroom keeps the longest bar off the card edge; an all-zero row
// (sub-timer-resolution scores) falls back to 1 so fractions stay finite.
return { present, missing, scaleMax: max > 0 ? max * 1.05 : 1 };
diff --git a/website/tests/bench-bars.test.ts b/website/tests/bench-bars.test.ts
--- a/website/tests/bench-bars.test.ts
+++ b/website/tests/bench-bars.test.ts
@@ -157,44 +157,61 @@
it('extends a bundle-size bar to its whole-API ceiling only where tree-shaking leaves a gap', async () => {
const bundleSize = FRAMEWORK_CARDS.find((c) => c.id === 'bundle-size')!;
- const row = bundleSize.rows[0];
- const ceilings = bundleSize.ceilings![row.op as string];
const { container, opButton } = await mountCard(bundleSize);
- fireEvent.click(opButton(row.op as string));
-
- await waitFor(() =>
- expect(opButton(row.op as string).getAttribute('aria-pressed')).toBe('true'),
- );
- const ranged: string[] = [];
- const single: string[] = [];
- for (const series of numericSeries(bundleSize, 0)) {
- const value = row[series.key] as number;
- const ceiling = ceilings[series.key];
- // Ranges whose ends round to the same kB stay single bars.
- (Math.round(ceiling / 1024) > Math.round(value / 1024) ? ranged : single).push(series.key);
- }
// The fixtures leave both kinds of framework on the card.
- expect(ranged.length).toBeGreaterThan(0);
- expect(single.length).toBeGreaterThan(0);
+ let sawRange = false;
+ let sawSingle = false;
+ for (const [index, row] of bundleSize.rows.entries()) {
+ const ceilings = bundleSize.ceilings![row.op as string];
+ fireEvent.click(opButton(row.op as string));
+ await waitFor(() =>
+ expect(opButton(row.op as string).getAttribute('aria-pressed')).toBe('true'),
+ );
+ const ranged: string[] = [];
+ const single: string[] = [];
+ for (const series of numericSeries(bundleSize, index)) {
+ const value = row[series.key] as number;
+ const ceiling = ceilings[series.key];
+ // A separately built whole runtime can sit a few hundred gzip bytes
+ // either side of the fixture and still round to another kilobyte.
+ // Only a gap of at least 1 kB is unused client API.
+ (ceiling - value >= 1024 && Math.round(ceiling / 1024) > Math.round(value / 1024)
+ ? ranged
+ : single
+ ).push(series.key);
+ }
+ if (ranged.length > 0) sawRange = true;
+ if (single.length > 0) sawSingle = true;
- const rows = Array.from(container.querySelectorAll('.bench-row:not(.bench-row-empty)'));
- const labelOf = (key: string) => rows.find((r) => r.getAttribute('data-series') === key)!;
- for (const key of ranged) {
- const bar = labelOf(key);
- expect(bar.querySelector('.bench-fill-range'), key).not.toBeNull();
- expect(bar.querySelector('.bench-val')!.textContent, key).toMatch(/kB–\d+ kB$/);
+ const rows = Array.from(container.querySelectorAll('.bench-row:not(.bench-row-empty)'));
+ const labelOf = (key: string) => rows.find((r) => r.getAttribute('data-series') === key)!;
+ for (const key of ranged) {
+ const bar = labelOf(key);
+ const hatch = bar.querySelector<HTMLElement>('.bench-fill-range');
+ const fill = bar.querySelector<HTMLElement>('.bench-fill')!;
+ expect(hatch, `${row.op}/${key}`).not.toBeNull();
+ expect(parseFloat(hatch!.style.width), `${row.op}/${key}`).toBeGreaterThan(0);
+ expect(parseFloat(fill.style.width), `${row.op}/${key}`).toBeLessThanOrEqual(100);
+ expect(bar.querySelector('.bench-val')!.textContent, `${row.op}/${key}`).toMatch(
+ /kB–\d+ kB$/,
+ );
+ }
+ for (const key of single) {
+ const bar = labelOf(key);
+ const fill = bar.querySelector<HTMLElement>('.bench-fill')!;
+ expect(bar.querySelector('.bench-fill-range'), `${row.op}/${key}`).toBeNull();
+ expect(bar.querySelector('.bench-val')!.textContent, `${row.op}/${key}`).not.toContain('–');
+ expect(parseFloat(fill.style.width), `${row.op}/${key}`).toBeLessThanOrEqual(100);
+ }
}
- for (const key of single) {
- const bar = labelOf(key);
- expect(bar.querySelector('.bench-fill-range'), key).toBeNull();
- expect(bar.querySelector('.bench-val')!.textContent, key).not.toContain('–');
- }
+ expect(sawRange).toBe(true);
+ expect(sawSingle).toBe(true);
// The exact ceilings stay readable without the hatching.
const tableRows = Array.from(container.querySelectorAll('tbody th'), (th) =>
th.textContent!.trim(),
);
- expect(tableRows).toContain(row.op + ', whole client API');
+ expect(tableRows).toContain(bundleSize.rows[0].op + ', whole client API');
});
it('charts a single-series card as one bar per operation, with no picker', async () => {You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 3f20bcc. Configure here.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Benchmark report🟢 No budget breaches, no added work, and no timing changes beyond ±3%. Compares js-framework: 1k/10k row operationsAll 20 timed operations (20 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)
50 other measured values are unchanged. Public-import reachability bundles (bytes)No changes across 105 measured values. |
Conflicts: - pnpm-lock.yaml: keep this branch's TSRX versions under main's @types/node 24.13.3 peer context. `pnpm install --lockfile-only` (pnpm 12.9.1) leaves the result unchanged. - 87 react-parity manifests: lockfileSha256 regenerated for the merged lockfile (react-parity:lockfiles:generate). - website BenchBars.tsrx and BenchmarkExplorer.tsrx: this branch only reformatted them, so take main's #1738 version and reformat it. - user-apps-v1 manifest.jsonl: regenerated by pnpm sync. - minimal-budgets.json: main re-baselined suspense-transition and binding-apollo-client-vite under the Oxc minifier (#1792), so this branch's earlier raises for the reformat are dropped. Reformat the 16 .tsrx files main added or changed in the old layout. Their client and server output is unchanged once position-derived ids are masked, and all 51 .tsrx files main touched compile in both modes. The reformat moves position-derived ids, which makes some bundles a few bytes smaller than main's budgets allow under the ratchet, so tighten them: context gzip -2, suspense-transition gzip -1, apollo esbuild brotli -99, bindings total raw -12. The bindings app and total gzip are set 27 bytes over the local measurement rather than 32, because CI has measured that app's gzip 5 bytes below local. Co-Authored-By: Claude Opus 5.5 <[email protected]>


Summary
bundle-sizenow also measures each framework's whole client runtime (every export of every framework entry point its fixtures import), and the website draws each bar as a range: solid for what the fixture ships, hatched up to the same application once it uses the whole client API.Why
Changes
benchmarks/bundle-size/run.mjs: while building each fixture, record the bare framework specifiers application modules import (resolved ids, so export conditions match the fixture build). After all sets, build one ceiling entry per framework that retainsimport * asof each, with the same normalized minify and framework chunk split, and reportfull_fw_raw/gzip/brotli. The Octane-only bindings set is excluded because its imports are bindings, not framework entry points. No budget or ratio guard is added; run-minimal.mjs keeps gating individual public imports.website/src/content/benchmarks.ts:BenchCard.ceilings(row → series → upper end). The bundle-size card sets it to each row'sapp_gzipplusfull_fw_gzip.BenchBars.tsrx/BenchmarkExplorer.tsrx: draw the extension hatched in the series color and label itlow–high; a range whose ends format identically stays a single bar. The overall view uses the geomean of ceilings over Octane's row values, so both ends share the 1× line. The data table gains "…, whole client API" rows.home-benchmark.ts:createHomeSummaryemits the same ceilings for cards that have them;HOME_SUMMARYregenerated (smoke test checks it againstcreateHomeSummary).benchmarks/baselines/local/bundle-size.json: re-recorded withnode benchmarks/bench.mjs --record bundle-size. Besides the newfull_fw_*ops, the existing Octane rows move by a few hundred bytes because main's runtime grew since the 0.8.0 recording; other frameworks' bytes are unchanged.Validation
pnpm format:check(ranpnpm format:files:checkover benchmarks/bundle-size, the baseline, website/src, website/tests: clean)pnpm typecheck(ranpnpm typecheck:fileson the 5 website files: clean;run.mjsis in no TS project,node --checkpasses)pnpm testvitest run website/tests, 31 files / 529 tests pass. The bench-bars range test walks every bundle-size row; it fails on 3f20bcc (weather total gzip/react: expected NaN to be greater than 0, the inverted range Bugbot reported) and with ranges disabled, and passes now.node benchmarks/bundle-size/run.mjs --budgets octane-tsrx octane-jsx: 6 application budgets hold.Risk / follow-ups
react-dom/server, Octane'soctane/hydration), so it is conservative for every framework.entry-delivery-clienthydration entries would give a measured mid-point between the two ends.Provenance
agent-authored)Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Low Risk
Benchmark reporting and marketing-site visualization only; no runtime or auth changes. Baseline JSON drift is expected when re-recording.
Overview
Bundle-size benchmarks and charts now show fixture bytes as a range up to “whole client API” size, so readers can see when small fixtures tree-shake the runtime vs shipping it all (e.g. React stays a single bar; Octane shows a large hatched extension).
The harness (
run.mjs) records bare framework specifiers during fixture builds, then runs a per-framework ceiling build that retainsimport *of those entry points and emitsfull_fw_*metrics plusmeta.ceilingspecifiers; the bindings fixture skips ceiling.bundle-size.jsonis re-recorded with the new ops and refreshed Octane byte counts.On the site,
BenchCard.ceilingsis derived for the bundle-size card (app_gzip + full_fw_gzip, only when runtime is ≥1.1× fixture framework bytes).BenchBarsandBenchmarkExplorerdraw a hatched segment,low–highlabels, tooltips, and table rows for “whole client API”; the home summary propagates ceiling geomeans for bundle-size. Tests cover which frameworks get ranges.Reviewed by Cursor Bugbot for commit 6aea57d. Bugbot is set up for automated code reviews on this repo. Configure here.