ENG-12614: reflex-bench size budgets (size.export, budgets.json, standard-runner CI gate)
PR-9 of the Holistic Framework Benchmarks project (ENG-12614, the footprint half; the memory half is PR-8). Adds a size.export benchmark that exports examples/playground for production and measures its bundle and footprint on disk, a committed budgets.json, a reflex-bench budgets check command, and a size-budgets workflow that gates every pull request on a standard GitHub runner. Bundle bytes need no statistics or macro runner, so this gate can run from day one (PLAN §2 rule 14, §8.8). The harness still never imports reflex: everything comes from reflex export in a subprocess and from files on disk.
Stack: main ← #7274 ← #7281 ← #7283 ← #7280 ← this PR. Nothing merges until the whole stack is done. reflex-bench is in never-publish-packages and nothing under reflex/ changes, so no news fragment is needed: reflex-release changelog-check --base-ref origin/farhan/beautiful-carson-ldmn0u prints "No packaged source changes; no changelog fragments required."
All Submissions:
- Have you followed the guidelines stated in CONTRIBUTING.md file?
- Have you checked to ensure there aren't any other open Pull Requests for the desired changed?
Type of change
- New feature (non-breaking change which adds functionality)
New Feature Submission:
- Does your submission pass the tests?
- Have you linted your code locally prior to submission?
Changes To Core Features:
Not applicable: nothing under reflex/ changes.
What landed
reflex_bench/suites/size.py: one benchmark,size.export[app=playground](kind="track", suitespranddaily, every metricassume="exact", so the scheduler takes one sample).setup_cachecopies the filesgit ls-files examples/playgroundlists intoctx.cache_dir / "app"(replacing the previous copy) and runsreflex export --frontend-only --no-zip --env prodthere throughrun_cli, withcache_env(reflex_dir=ctx.cache_dir / "reflex")so bun stays cached.samplemeasures the export on disk, with no subprocess. It fails clearly when the working directory is not in a checkout that tracksexamples/playground.reflex_bench/budgets.py:load(path),check(doc, budgets) -> list[BudgetRow],format_table(rows), and thebudgetsclick group withcheck RESULT.json [--budgets FILE]. The only change tocli.pyis registering the group (an import pluscli.add_command).packages/reflex-bench/budgets.json: budgets for five metrics, measured at HEAD plus headroom..github/workflows/size_budgets.yml: the standard-runner gate.- README: a "Size budgets" section and a
budgets checkrow in the command table. - Tests:
tests/units/reflex_bench/suites/test_size.py(a fake build directory, plus the realindex.htmlof both versions undertests/units/reflex_bench/fixtures/size/, with a README that says how they were captured),tests/units/reflex_bench/test_budgets.py, a registration test intest_cli.py, and an opt-in real testsuites/test_size_app.py(REFLEX_BENCH_APP_TESTS=1). The new modules have 100 % line and branch coverage. - Dependency:
brotli >=1.1.0forreflex-bench(see below). Theuv.lockdiff only adds brotli (+60 lines).
Metric definitions
One export gives every size, so the plan's five ids (size.bundle.initial, size.bundle.total, size.bundle.chunks, size.web_dir, size.node_modules) are metrics of one benchmark. Five benchmarks would run five exports (bun install plus vite build each).
| Metric | Unit | What |
|---|---|---|
initial_raw, initial_gzip, initial_brotli | B | The JS and CSS the first page loads: the files that the prerendered .web/build/client/index.html references with <link rel="modulepreload">, <link rel="stylesheet"> or <script src> |
total_raw, total_gzip, total_brotli | B | Every file under .web/build/client except compression sidecars |
chunks | 1 | *.js files in .web/build/client/assets |
web_dir | B | Regular files under .web outside .web/node_modules (build output with its sidecars, the SSR build, compiled pages, templates) |
node_modules | B | Regular files under .web/node_modules |
Initial-bytes rule. html.parser collects, in document order, the href of every <link> whose rel contains modulepreload or stylesheet, and the src of every <script>. Inline scripts have no src: the inline <script type="module"> only imports files that are also modulepreloaded. <link rel="preload" as="style"> (HEAD preloads its stylesheet too) and <link rel="preload" as="image"> are not JS or CSS module loads. A leading / resolves against the client directory. URLs with a scheme or host are skipped, because another server sends them. A reference to a file that is not in the build fails the sample and names the file. An app with a frontend_path is not supported (its pages sit under a prefix), which the README says.
Sidecar rule. HEAD pre-compresses the export (_compress_static_output, .gz by default) and 0.8.23 does not. So .gz, .br and .zst files are never measured: they are left out of total_*, chunks and the breakdown, and summed into extra["sidecar_bytes"] (329,167 B at HEAD, 0 at 0.8.23). The harness compresses each file on its own for both versions: gzip.compress(data, compresslevel=9, mtime=0) and brotli.compress(data, quality=11). *_gzip and *_brotli are sums of those per-file sizes, since files are served one by one.
Per-file breakdown (SampleResult.extra):
files:{path: {"raw", "gzip", "brotli", "initial"}}for every non-sidecar file of the client build. Keys are paths with the content hash replaced byHASH. The rule strips only the last-<8 of [A-Za-z0-9_-]>before the extension, and only for files directly inassets/:chunk-5KNZJZUH-q9CrfzJj.jsbecomeschunk-5KNZJZUH-HASH.jsand_item_.__item_id_._index-C-TMLTbt.jsbecomes_item_.__item_id_._index-HASH.js.__spa-fallback.htmlkeeps its name, although a naive pattern would readfallbackas a hash. If two names differ only in their hash, the second key gets#2.initial_files(keys in page order),html(index.html),sidecar_bytes,reflex_version,fixture_hash(the playground's.content-hash: the base does not fill the result'sfixtureblock, so it goes here), plus two keys the prompt did not ask for:bun_lockandcompressors(see deviations).
The brotli decision
brotli >=1.1.0 is a normal dependency of reflex-bench:
- The stdlib has no brotli, and brotli is what CDNs actually send. Measuring gzip only would hide brotli-specific regressions: large repetitive chunks compress differently.
reflex-benchis innever-publish-packages, so a compiled dependency costs users nothing.- PyPI
Brotli1.2.0 (the locked version) ships wheels for cp310 to cp314 on manylinux x86_64 and aarch64 (the CodSpeed macro runner is arm64), musllinux, macOS universal2 and Windows. I read that off the wheel list inuv.lock. - Node's
zlib.brotliCompresswas not an option: it would make the harness depend on a JS runtime path. scripts/check_min_deps.pycoversreflex-bench(apackages/*member that is not inSKIP_PACKAGES), anduv run python scripts/check_min_deps.py reflex-benchpasses at the minimum versions:PASS reflex-bench.- A plain
uv lock(uv 0.12.x) also rewrote unrelated resolution markers without changing any version. I kept only brotli's three hunks.uv lock --checkpasses with uv 0.12.5 (the version the release workflows pin) and 0.12.18, anduv sync --lockedworks.
budgets.json and budgets check
{
"schema": "reflex-bench-budgets/1",
"budgets": {
"size.export[app=playground]": {
"initial_gzip": 330000, "initial_brotli": 265000, "total_gzip": 350000,
"chunks": 16, "node_modules": 170000000
}
}
}
Budgets are whole numbers in the metric's unit: the largest allowed value. Each is the HEAD measurement plus about 5 %, rounded up to a readable number: 311,141 → 330,000, 248,763 → 265,000, 328,691 → 350,000, 15 → 16. node_modules gets about 20 % (140,122,308 → 170,000,000). A metric without an entry is tracked, not gated. To raise a budget, edit the file in the same PR, so the review diff shows the change. The value column prints the measured integer, ready to paste.
reflex-bench budgets check RESULT.json [--budgets FILE] prints one table (benchmark, metric, value, budget, delta in the unit and in percent of the budget, verdict) and a summary line, in plain text when CI=true. Exit codes reuse cli.py's constants:
EXIT_REGRESSION(2) when any metric exceeds its budget.EXIT_ERROR(1) when a budgeted benchmark is missing, is notokor lacks a budgeted metric, and for invalid files. Exit 1 wins over 2, because the gate did not see everything.EXIT_OK(0) otherwise.
The checked value is the largest timed sample of the metric (exact metrics have one).
CI workflow
.github/workflows/size_budgets.yml runs on pull_request with no branches filter, so this stacked PR runs it too. It also runs on push to main. Both triggers use the same paths (reflex/**, packages/**, examples/playground/**, pyproject.toml, uv.lock, the workflow itself). The rest:
permissions: contents: read, the concurrency group ofexamples.yml, telemetry and update checks off,timeout-minutes: 20,ubuntu-latest. There is no self-hosted runner, no secret and no comment, so fork PRs are safe.- Steps: checkout (
fetch-depth: 0, tags, no persisted credentials), thensetup_build_env(Python 3.14,uv sync, Node 22),reflex-bench run 'size.*' --json size-result.json --no-save --kind pr(cion pushes),reflex-bench budgets check size-result.json, and an upload ofsize-result.jsonwithif: always(). - With
CI=trueand no--baseline,runexits 0 unless the export fails. The budget gate is thebudgets checkstep.
Verification
The first page of both versions
index.html from a HEAD export (0.9.12.post18.dev0, Vite 8.2.2, react-router 8.4.0; the file is one line, split here, theme script elided):
<head>
<meta charSet="utf-8"/>
<meta content="width=device-width, initial-scale=1" name="viewport"/>
<link rel="preload" as="image" href="/logo.svg"/>
<link as="style" href="/assets/__reflex_global_styles-Bja7d8zq.css" rel="preload"/>
<title>Reflex playground</title>
<meta content="favicon.ico" property="og:image"/>
<link rel="modulepreload" href="/assets/manifest-24546cb6.js"/>
<link rel="modulepreload" href="/assets/entry.client-PAjQ1ewH.js"/>
<link rel="modulepreload" href="/assets/components-DzQT6F3y.js"/>
<link rel="modulepreload" href="/assets/react-dom-CM0sdMnz.js"/>
<link rel="modulepreload" href="/assets/errorBoundaries-m9jGFIQ4.js"/>
<link rel="modulepreload" href="/assets/root-ajGuFAV2.js"/>
<link rel="modulepreload" href="/assets/link-D_rz9Rcp.js"/>
<link rel="modulepreload" href="/assets/reflex-env-BVGF6eGS.js"/>
<link rel="modulepreload" href="/assets/emotion-react.browser.esm-BUuhssUM.js"/>
<link rel="modulepreload" href="/assets/button-Ca3xX7bl.js"/>
<link rel="modulepreload" href="/assets/code-D7agZnkH.js"/>
<link rel="modulepreload" href="/assets/_index-CaNbpnaO.js"/>
<script>/* theme */</script>
<link href="/assets/__reflex_global_styles-Bja7d8zq.css" rel="stylesheet" type="text/css"/>
</head>
From a 0.8.23 export (rolldown-vite 7.2.10, react-router 7.10.1):
<head>
<meta charSet="utf-8"/>
<meta content="width=device-width, initial-scale=1" name="viewport"/>
<link rel="preload" as="image" href="/logo.svg"/>
<title>Reflex playground</title>
<meta content="favicon.ico" property="og:image"/>
<link rel="modulepreload" href="/assets/manifest-23f351b0.js"/>
<link rel="modulepreload" href="/assets/entry.client-EnKPZijB.js"/>
<link rel="modulepreload" href="/assets/react-dom-BIr3m2O5.js"/>
<link rel="modulepreload" href="/assets/chunk-WWGJGFF6-CUwUJrNH.js"/>
<link rel="modulepreload" href="/assets/rolldown-runtime-ZTEY5dKY.js"/>
<link rel="modulepreload" href="/assets/root-BTlycLtU.js"/>
<link rel="modulepreload" href="/assets/reflex-env-B0awbqwU.js"/>
<link rel="modulepreload" href="/assets/emotion-react.browser.esm-3tEzYx87.js"/>
<link rel="modulepreload" href="/assets/esm-D1HOkqXd.js"/>
<link rel="modulepreload" href="/assets/_index-CvV2IH47.js"/>
<link rel="modulepreload" href="/assets/stateful_components-CPVWVdTg.js"/>
<script>/* theme */</script>
<link href="/assets/__reflex_global_styles-BOXGY6tA.css" rel="stylesheet" type="text/css"/>
</head>
The link shapes match: 12 and 11 modulepreloads plus one stylesheet. manifest-<8 hex>.js exists in both. Both bodies end in an inline <script type="module" async=""> with no src, which imports the manifest, root, _index and entry.client. Differences: HEAD also preloads its stylesheet (rel="preload" as="style", rightly not counted twice), and 0.8.23 has a rolldown-runtime-*.js chunk. The Vite 8 build at HEAD has none. Both heads are committed as test fixtures, and the tests parse them (13 and 12 files).
size.* on HEAD and on 0.8.23
uv run reflex-bench run 'size.*' --json final-head.json on 1e08ed1 (the final code; b29b42c only adds comments), then budgets check:
reflex-bench 0.0.0.post60.dev0+8e72b14be · reflex 0.9.12.post18.dev0+8e72b14be (workspace 1e08ed1) · py 3.14.7
[1/1] size.export[app=playground] ok · 1 sample · 14.2 s
size.export[app=playground] median ± 95 % CI range n
initial_raw 1.455 MB (exact) 1
initial_gzip 311.1 kB (exact) 1
initial_brotli 248.8 kB (exact) 1
total_raw 1.502 MB (exact) 1
total_gzip 328.7 kB (exact) 1
total_brotli 263.2 kB (exact) 1
chunks 15 (exact) 1
web_dir 2.143 MB (exact) 1
node_modules 140.1 MB (exact) 1
$ uv run reflex-bench budgets check final-head.json
benchmark metric value budget delta verdict
size.export[app=playground] initial_gzip 311141 330000 -18,859 B (-5.7 %) ok
size.export[app=playground] initial_brotli 248763 265000 -16,237 B (-6.1 %) ok
size.export[app=playground] total_gzip 328691 350000 -21,309 B (-6.1 %) ok
size.export[app=playground] chunks 15 16 -1 (-6.2 %) ok
size.export[app=playground] node_modules 140122308 170000000 -29,877,692 B (-18 %) ok
5 within budget · 0 over budget · 0 not checked
$ echo $?
0
uv run reflex-bench run 'size.*' --reflex 0.8.23 --python 3.12 --json final-0823.json (PR-2's subject venv):
reusing venv 3ffb620513131c23 for reflex 0.8.23 (py3.12)
reflex-bench 0.0.0.post60.dev0+8e72b14be · reflex 0.8.23 (0.8.23) · py 3.12.3
[1/1] size.export[app=playground] ok · 1 sample · 12.2 s
size.export[app=playground] median ± 95 % CI range n
initial_raw 1.650 MB (exact) 1
initial_gzip 332.4 kB (exact) 1
initial_brotli 262.1 kB (exact) 1
total_raw 1.694 MB (exact) 1
total_gzip 349.9 kB (exact) 1
total_brotli 276.5 kB (exact) 1
chunks 14 (exact) 1
web_dir 1.896 MB (exact) 1
node_modules 160.7 MB (exact) 1
$ uv run reflex-bench budgets check final-0823.json
benchmark metric value budget delta verdict
size.export[app=playground] initial_gzip 332386 330000 +2,386 B (+0.7 %) over budget
size.export[app=playground] initial_brotli 262132 265000 -2,868 B (-1.1 %) ok
size.export[app=playground] total_gzip 349924 350000 -76 B (-0.0 %) ok
size.export[app=playground] chunks 14 16 -2 (-12 %) ok
size.export[app=playground] node_modules 160661366 170000000 -9,338,634 B (-5.5 %) ok
4 within budget · 1 over budget · 0 not checked
to accept a new value, raise its budget in packages/reflex-bench/budgets.json in the same pull request
$ echo $?
2
(0.8.23 is over HEAD's initial_gzip budget: HEAD's first page is 21 kB smaller gzipped.)
The ten largest files, from extra["files"]:
HEAD (24 files, sidecar_bytes 329,167):
| file | raw | gzip | brotli | initial |
|---|---|---|---|---|
assets/__reflex_global_styles-HASH.css | 698,529 | 82,584 | 50,561 | yes |
assets/root-HASH.js | 302,323 | 84,279 | 70,562 | yes |
assets/entry.client-HASH.js | 182,427 | 56,950 | 49,507 | yes |
assets/link-HASH.js | 116,008 | 33,878 | 30,338 | yes |
assets/components-HASH.js | 86,488 | 28,312 | 25,159 | yes |
assets/errorBoundaries-HASH.js | 33,327 | 11,612 | 10,514 | yes |
assets/emotion-react.browser.esm-HASH.js | 20,715 | 8,018 | 7,330 | yes |
index.html | 9,369 | 3,444 | 2,814 | |
counter.html | 9,146 | 3,398 | 2,791 | |
counter/index.html | 9,146 | 3,398 | 2,791 |
0.8.23 (23 files, sidecar_bytes 0):
| file | raw | gzip | brotli | initial |
|---|---|---|---|---|
assets/__reflex_global_styles-HASH.css | 697,970 | 82,123 | 50,228 | yes |
assets/esm-HASH.js | 572,594 | 128,027 | 104,658 | yes |
assets/entry.client-HASH.js | 182,914 | 57,206 | 49,748 | yes |
assets/chunk-WWGJGFF6-HASH.js | 119,863 | 39,329 | 34,434 | yes |
assets/root-HASH.js | 45,053 | 13,598 | 12,119 | yes |
assets/emotion-react.browser.esm-HASH.js | 20,671 | 8,116 | 7,440 | yes |
index.html | 9,349 | 3,468 | 2,840 | |
counter.html | 9,126 | 3,427 | 2,809 | |
counter/index.html | 9,126 | 3,427 | 2,809 | |
404.html | 5,658 | 2,293 | 1,828 |
Differences between the versions:
- The Radix Themes CSS is the same size in both (698 kB raw, 82 kB gzip), bundled with
playground.css. At HEAD it comes fromRadixThemesPlugin, which the playground'srxconfig.pyadds when it exists. - 0.8.23's 573 kB
esm-*.jschunk goes away at HEAD, which splits the code differently (root,link,components, ...). - 0.8.23 has a
rolldown-runtime-*.jschunk and HEAD does not. - HEAD writes
.gzsidecars (329 kB) and abuild/serverSSR bundle, both part ofweb_dir. 0.8.23 writes neither. - HEAD installs 20 MB less into
node_modules.
Determinism
Two exports of one commit (clean 6845cc0; the later commits don't change what is measured). I ran size.* in two bench homes, REFLEX_BENCH_HOME=home-a and home-b, so each run had its own copy, .web and reflex dir, then took the sha256sum of every file under build/client, sidecars included:
files: 47 vs 47
21 identical, 10 differ (same path) # the other 16 files differ only in their hashed names
same set of hash-stripped names
metric home-a home-b diff
initial_raw 1,455,157 1,455,157 +0
initial_gzip 311,145 311,139 -6
initial_brotli 248,823 248,798 -25
total_raw 1,502,111 1,502,111 +0
total_gzip 328,699 328,683 -16
total_brotli 263,247 263,218 -29
chunks 15 15 +0
web_dir 2,142,835 2,142,814 -21
node_modules 140,122,308 140,122,308 +0
These are byte-identical, with their .gz files: entry.client, components, react-dom, errorBoundaries, emotion-react.browser.esm, reflex-env, _404_._index, the CSS, logo.svg, playground.css and sitemap.xml. So the sitemap has no lastmod, node's gzip header has no timestamp, and reflex-env-*.js embeds nothing variable. The builds are still not byte-identical, and there is no absolute path involved either. Reflex bundles .web/reflex.json into a shared chunk (assets/link-*.js at HEAD, assets/esm-*.js at 0.8.23). That file holds project_hash, a random 128-bit number chosen when .web is created, and last_reflex_run_datetime, the time of the export:
...var version=`0.9.12.post18.dev0+8e72b14be`,project_hash=15473762565479359e22,last_reflex_run_datetime=`2026-09-23 19:16:54.413348`,...
...var version=`0.9.12.post18.dev0+8e72b14be`,project_hash=11021243918841048e21,last_reflex_run_datetime=`2026-09-23 19:19:20.611310`,...
So link-*.js gets a new content hash. Every chunk that imports it names that hash (root, _index, _counter_._index, _item_…, button, code), so their hashes change too, and so do the manifest and the five HTML pages that list them, and their .gz files. Raw sizes stay equal except for the number of digits of the project hash: across the HEAD exports I made, link-*.js was 116,007, 116,008 or 116,009 B. Compressed sizes move by a few bytes, because the hashes differ, and web_dir moves by a few dozen (reflex.json, the packages cache file and the sidecars). This is far below the 5 % headroom and the 3 % threshold of exact comparisons, and every affected file is a real part of the bundle. So I excluded nothing from the breakdown and kept the metrics exact. The README section documents this.
Two samples of one export (--runs 2, same cache home): both samples are identical for every metric and in the extra data, and there is no "exact metric varied" warning:
[1/1] size.export[app=playground] ok · 2 samples · 10.9 s
2 samples per metric, identical: True | warnings: 0
extra identical: True
Deliberate regression
I added rx.code_block("print('size regression')", language="python") to the shared layout in playground/layout.py, so it renders on the first page, and ran hash_examples.py:
$ uv run reflex-bench run 'size.*' --json size-regressed.json
initial_gzip 328.8 kB (exact) 1
total_gzip 645.8 kB (exact) 1
chunks 314 (exact) 1
node_modules 147.6 MB (exact) 1
$ uv run reflex-bench budgets check size-regressed.json
benchmark metric value budget delta verdict
size.export[app=playground] initial_gzip 328831 330000 -1,169 B (-0.4 %) ok
size.export[app=playground] initial_brotli 263932 265000 -1,068 B (-0.4 %) ok
size.export[app=playground] total_gzip 645778 350000 +295,778 B (+85 %) over budget
size.export[app=playground] chunks 314 16 +298 (+1862 %) over budget
size.export[app=playground] node_modules 147625236 170000000 -22,374,764 B (-13 %) ok
3 within budget · 2 over budget · 0 not checked
to accept a new value, raise its budget in packages/reflex-bench/budgets.json in the same pull request
budgets exit=2
The breakdown against the clean build shows what grew:
initial files added: ['assets/one-dark-HASH.js']
initial files removed: []
file gzip before gzip after delta initial
counter.html 3,400 3,675 +275 False
counter/index.html 3,400 3,675 +275 False
index.html 3,446 3,709 +263 False
assets/_item_.__item_id_._index-HASH.js 1,060 1,198 +138 False
assets/_index-HASH.js 1,190 1,326 +136 True
assets/_counter_._index-HASH.js 1,182 1,312 +130 False
assets/one-dark-HASH.js - 17,530 +17,530 True (new)
assets/sqf-HASH.js - 11,113 +11,113 False (new)
assets/core-HASH.js - 11,045 +11,045 False (new)
assets/vim-HASH.js - 5,855 +5,855 False (new)
assets/gherkin-HASH.js - 5,221 +5,221 False (new)
assets/opencl-HASH.js - 4,226 +4,226 False (new)
... 299 new files, 315,838 B gzip in total; 0 removed: []
The highlighter adds one theme chunk to the first page (+17.5 kB gzip, just under the initial_gzip budget) and 298 lazily loaded language chunks.
I pushed the same edit as one temporary commit (6aca0bd). The workflow went red at the budget step and still uploaded the result:
Run uv run --no-sync reflex-bench budgets check size-result.json
benchmark metric value budget delta verdict
size.export[app=playground] initial_gzip 328829 330000 -1,171 B (-0.4 %) ok
size.export[app=playground] initial_brotli 263849 265000 -1,151 B (-0.4 %) ok
size.export[app=playground] total_gzip 645754 350000 +295,754 B (+85 %) over budget
size.export[app=playground] chunks 314 16 +298 (+1862 %) over budget
size.export[app=playground] node_modules 147625236 170000000 -22,374,764 B (-13 %) ok
3 within budget · 2 over budget · 0 not checked
to accept a new value, raise its budget in packages/reflex-bench/budgets.json in the same pull request
##[error]Process completed with exit code 2.
Artifact size-result has been successfully uploaded! Final size is 7845 bytes.
Then I dropped the commit (git reset --keep HEAD~1, force-pushed with a lease on 6aca0bd). The final diff does not touch examples/: git diff origin/farhan/beautiful-carson-ldmn0u -- examples/ is empty and hash_examples.py --check passes.
CI green on the final code
size-budgets run #4 on 1e08ed1 (the merge commit 539fe15, AMD EPYC runner) passed in 52 s, and its artifact size-result (2,600 B) is present. The last commit, b29b42c, only adds two comments (run #5). The numbers match the local ones: node_modules is byte-identical, and the compressed sizes differ by a few bytes, as explained above.
[1/1] size.export[app=playground] ok · 1 sample · 12.1 s
benchmark metric value budget delta verdict
size.export[app=playground] initial_gzip 311140 330000 -18,860 B (-5.7 %) ok
size.export[app=playground] initial_brotli 248726 265000 -16,274 B (-6.1 %) ok
size.export[app=playground] total_gzip 328675 350000 -21,325 B (-6.1 %) ok
size.export[app=playground] chunks 15 16 -1 (-6.2 %) ok
size.export[app=playground] node_modules 140122308 170000000 -29,877,692 B (-18 %) ok
5 within budget · 0 over budget · 0 not checked
The earlier green runs were #1 (6845cc0) and #3 (5114c06). examples.yml (playground-head, playground-0.8.23) also passes on the final commit.
Repo checks
uv run ruff check .: all checks passed.uv run ruff format --check .: already formatted.uv run pyright reflex tests packages/reflex-bench/src: 0 errors, 0 warnings.uv run pytest tests/units/reflex_bench -q: 541 passed, 3 skipped (the three opt-in app tests).REFLEX_BENCH_APP_TESTS=1 uv run pytest tests/units/reflex_bench/suites/test_size_app.py: 1 passed, in 11 s with a fresh bench home.uv run pytest tests/units --cov --no-cov-on-fail --cov-report=: 10,324 passed, 23 skipped, coverage 80.67 %.uv run pre-commit run --files <every file of this PR>: every hook passed, including biome (it leaves the.htmlfixtures alone) and codespell.uv lock --checkpasses with uv 0.12.5 and 0.12.18.check-jsonschema --builtin-schema vendor.github-workflows .github/workflows/size_budgets.ymlprints "ok".reflex-release changelog-checkandcheck-headings(both with--base-ref origin/farhan/beautiful-carson-ldmn0u) andsync --checkpass.- The import-isolation test (
test_the_harness_never_imports_reflex, which runsdiscover()and so importssize.py) passes.size.pyimports only the stdlib, brotli andreflex_bench.
Deviations from the prompt
- One benchmark instead of five ids, as the prompt anticipated. The ids are metrics of
size.export[app=playground]. - Exports are not byte-identical (see Determinism). Nothing is excluded from the breakdown: the changed files are real parts of the bundle, and their sizes move by bytes, not by real size changes.
<script src>counts whatever its type, not onlytype="module", since a classic external script is initial JS too. URLs of other hosts are skipped, not failed, because they are not files of the build.- Hash stripping only applies to files directly in
assets/. Otherwise__spa-fallback.htmlwould become__spa-HASH.html.#2,#3suffixes keep names that differ only in their hash apart, so no file is silently dropped from the breakdown. - Two more extra keys.
compressors(zlib.ZLIB_RUNTIME_VERSIONandbrotli.__version__) explains cross-machine differences in compressed sizes (zlib versus zlib-ng builds).bun_lock(sha256 of.web/bun.lock) tells a dependency release apart from a code change (see findings). setup_cachecopies and exports afresh on every run (it deletes the previous copy,.webincluded), and keeps only reflex's data directory (bun) in the cache directory. A reused.webcould otherwise leak files of a previous export intoweb_dirandnode_modules: two dirty states of one commit share a cache directory.--kindispron pull requests andcion pushes tomain, not alwayspr.- Budget values come from the measurement and differ from the prompt's example numbers:
initial_gzipis 311 kB, above the example's 260 kB. budgets checkdetails the prompt left open: the checked value is the largest timed sample, exit 1 wins over 2, and a summary line plus a hint follow the table.check_commandimportsEXIT_*,in_ciand_relativefromcli.pyinside the function:cli.pyimportsbudgets.pyto register the group, so a top-level import would be circular.--helpofbudgets checkshows the Args section of its docstring, like every PR-1 command.- Branch: the session environment pins
farhan/dreamy-turing-q0co01, notfarhan/reflex-bench-size.
Changes to lower PRs
packages/reflex-bench/src/reflex_bench/cli.py: registration of thebudgetsgroup only (an import andcli.add_command(budgets_command)).tests/units/reflex_bench/test_cli.py:test_list_hides_self_tests_by_defaultassumedlistshows nothing without--suite. It now expectssize.export[app=playground]and checks the empty-selection hint with a filter that matches nothing. There is also a newtest_budgets_check_is_registered.packages/reflex-bench/pyproject.tomlanduv.lock: the brotli dependency.packages/reflex-bench/README.md: the new section and command row.
Interfaces for later PRs
- PR-11 (PR comment):
budgets.load(path)andbudgets.check(doc, budgets) -> list[BudgetRow]. Each row hasbenchmark,metric,budget,value,unit,errorandexceeded, which is everything a markdown table needs.budgets.DEFAULT_PATHpoints at the committed file. The workflow'ssize-resultartifact is a completereflex-bench/1result. - Per-file diffs:
sample_extra[i]["files"], keyed by stable, hash-stripped paths, withraw/gzip/brotli/initial, plusinitial_filesin page order. Diff two results key by key. A diff should allow a few bytes of noise on the files that import thereflex.jsonchunk.bun_locktells whether the frontend packages changed between the two results. reflex_bench.suites.size.measure_export(app, reflex_version=...)measures any exported app directory.strip_hashandinitial_assetsare the naming and parsing rules on their own.
Findings
- Dependency drift. Reflex pins its direct frontend packages exactly (
vite 8.2.2,react-router 8.4.0, ...), but their dependencies resolve when bun installs them, and the playground commits no lockfile (by PR-4's design). A transitive release can therefore change the sizes of an unchanged commit and trip the gate on an unrelated PR. The headroom absorbs small changes. A differentbun_lockbetween themainresult and the PR result identifies the cause, and the fix is a budget bump in its own PR. - The export embeds the time and a random id (
reflex.jsonin a shared chunk, see Determinism). A reflex-side change, for example not bundlinglast_reflex_run_datetimeinto production builds, would make exports reproducible. That is out of scope here. rx.code_blockadds 299 files to a build (lazy language chunks).chunksis a sensitive signal for this kind of change.
Review bot findings
Greptile raised two P2 findings on 1e08ed1:
- Unexplained timeout durations: fixed in b29b42c. The comments now say what
EXPORT_TIMEOUT_S(10 minutes, a cold export also installs the frontend packages) andsetup_timeout(plus 1 minute to copy the app) cover. Thread resolved. - Missing news fragment: not applicable, so no change.
reflex-benchis innever-publish-packages, andreflex-release changelog-checkreports that no fragment is required. Thread left open for a human to close.
Adversarial self-review
- Sidecar exclusion is by extension (
.gz,.br,.zst) anywhere underbuild/client. A genuine.gzpublic asset would be left out oftotal_*. That is acceptable: reflex writes those extensions only as sidecars, and a real one would be summed intosidecar_bytes, not lost. Sidecars never reachchunks(x.js.gzhas the suffix.gz). Tested. - Hash stripping on names with extra dashes:
chunk-5KNZJZUH-q9CrfzJj.js,_item_.__item_id_._index-C-TMLTbt.js,_404_._index-DEKlLv-N.js,code-Dzr0iVq-.jsandindex-D1HOkqXd.js.mapare tested, and so are__spa-fallback.html,counter/index.html,react-dom.jsand a nestedassets/path, which must stay unchanged. One limitation: a Vite config that names files without hashes (not reflex's) could havename-<8 word chars>.jsread as a hash. The#2order follows the hashed names, so when two same-named chunks both change, a per-file diff can pair them the wrong way round; the totals stay right. web_dirandnode_modulesare disjoint: one walk excludes exactly.web/node_modules, the other walks only it, both count regular files only, and symlinks are neither followed nor counted. The test includes a.binsymlink. Both are apparent sizes. bun hardlinks packages from its global cache (all 12,464 files of the playground'snode_moduleshave more than one link), and those files count in full: that is the footprint the app directory shows, whatever the install backend.- Exit codes:
budgets checkreturns 0, 1 or 2 fromcli.py's constants. Invalid files becomeUsageErrorand exit 1 through_Group.main, and 1 wins over 2. All paths are tested through the CLI. In CI, an export failure fails therunstep: the only benchmark failed, soEXIT_ERROR. - No reflex import in
size.py: only the stdlib, brotli andreflex_bench. The PR-1 import-isolation test runsdiscover()and stays green. - Stale state:
copy_exampledeletes the previous copy withshutil.rmtreeand noignore_errors, so an undeletable leftover fails the benchmark instead of being measured. - Network: the export installs frontend packages from the npm registry, so a registry outage fails the job (exit 1, not 2).
examples.ymlhas the same exposure. - Private helper import:
check_commandimportscli._relative(see deviation 9) instead of duplicating it. This is package-internal.SLFandPLCare ignored by the repo's ruff config, and pyright does not flag it. - CLAUDE.md: Google-style docstrings everywhere, module-level test functions, no block comments, imports at the top except the one documented cycle, tests written first (they failed before the modules existed), and
uvfor every command.
Review fixes (527b7a865)
- Per-arm exports:
size.exportexports insetupinto the instance work directory (ctx.workdir/app, per instance and per arm, kept by--keep), not insetup_cache. Only bun/REFLEX_DIRstays in the cache directory. Before, both arms ofab --aashared one export and always matched byte for byte. Nowab --base workspace --head workspace 'size.*'shows the real export noise (total_gzip 328689 vs 328680, total_brotli 263286 vs 263106). exactdocumented: hereassume="exact"means deterministic up to about 150 B per export:project_hashand the export time are embedded inlink-*.js.node_modulesdrift documented: it grows with dependency releases (+25 kB in 18 h on one commit), so its budget can go red on unrelated PRs; raise it in that PR.- Budget report:
budgets checkprints a failed benchmark's error once, not on every row. The table usesreport.table.print_lines(renamed from_print_linesin #7274, no behavior change). Dead float branches and an unreachable branch are removed, andloadvalidation is one check. - Workflow: it also triggers on
.github/actions/setup_build_env/**changes. - Kept as is: the fixture hash is read from the committed
.content-hash, which the hash gate enforces in CI; a work-tree edit shows asdirtyon the subject.
Checks: 542 passed, 3 skipped; ruff, pyright and pre-commit pass. Real run: run 'size.*' --runs 2 → budgets check exit 0.