ENG-12610: reflex-bench lifecycle benchmarks (init, compile, export, run, import) and the synthetic app generator
Linear: ENG-12610, project P-ENG-487, PR-5 "Lifecycle suite", plus the synthetic app generator (moved here from PR-4). Stacked on #7280: base farhan/beautiful-carson-ldmn0u (main ← #7274 ← #7281 ← #7283 ← #7280 ← this PR). Nothing merges until the whole stack is complete.
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)
Description
The first real numbers of the harness: how long a user waits for reflex init, reflex compile (cold, warm, after one edit), reflex export, reflex run in each mode until it serves HTTP, and import reflex, on HEAD and back to 0.8.23. lifecycle.compile.warm and lifecycle.compile.incremental form the pr suite. A synthetic app generator adds the scaling curve (1 → 1000 pages) the playground cannot give.
New in packages/reflex-bench/src/reflex_bench/:
fixtures/__init__.py:playground_root(),describe_playground(),materialize_playground(dest),ensure_fixture(cache_dir, describe, make),bump_marker(path, target).fixtures/generate.py:GenParams,describe(params),generate(dest, params),main()(uv run python -m reflex_bench.fixtures.generate --pages 10 DEST). Writes text; never imports reflex.suites/lifecycle.py: the benchmarks below.
Benchmarks
| Id | Suites | Kind | One sample |
|---|---|---|---|
lifecycle.init.cold | daily | time | reflex init --template blank in a fresh empty app directory with a fresh REFLEX_DIR under ctx.workdir (both deleted in prepare): bun is downloaded, the templates copied. Network-bound |
lifecycle.init.warm | daily | time | the same with REFLEX_DIR in ctx.cache_dir, primed by one init in setup_cache |
lifecycle.compile.cold[app=playground] | daily | time | reflex compile of a fresh copy of the playground (made in prepare) with a fresh BUN_INSTALL_CACHE_DIR under ctx.workdir; REFLEX_DIR warm |
lifecycle.compile.warm[app=playground] | pr, daily | time | reflex compile of the app in ctx.cache_dir/app (setup_cache: ensure_fixture + one priming compile) |
lifecycle.compile.incremental[app=playground] | pr, daily | time | prepare rewrites the leaf pragma line (playground/components/marker.py) to m-<n>-leaf; sample compiles |
lifecycle.export.dev[app=playground], .prod | daily | time | reflex export --env dev|prod --zip-dest-dir <ctx.workdir>/export of the primed app; prepare replaces the old zips with an empty directory (reflex needs it to exist) |
lifecycle.run.dev.ready[app=playground] | daily | startup | AppProcess(mode="dev") of the primed app: process_ready, http_ready |
lifecycle.run.prod.ready[app=playground] | daily | startup | mode="prod": compile + frontend build + start (two ports on 0.8.23) |
lifecycle.run.preview.ready[app=playground] | daily | startup | mode="preview", min_version="0.9.8": unsupported on 0.8.23 |
lifecycle.run.backend_only.ready[app=playground] | daily | startup | mode="dev", backend_only=True: /ping |
lifecycle.import | daily | time | python -c "import reflex" in a fresh interpreter; wall only |
lifecycle.scale.compile.warm[pages=1|10|100|1000] | all | time | as compile.warm on a generated app; the other GenParams fields are hidden_params |
lifecycle.scale.compile.incremental[pages=…] | all | time | as compile.incremental, editing the first leaf target of bench-manifest.json |
Cache state per id (the harness owns it; host and CI caches never reach a measured phase):
| State | REFLEX_DIR (bun, templates) | BUN_INSTALL_CACHE_DIR | app + .web (node_modules) |
|---|---|---|---|
init.cold | fresh per sample | untouched (init installs no packages) | fresh empty dir |
init.warm | ctx.cache_dir/reflex, primed | untouched | fresh empty dir |
compile.cold | ctx.cache_dir/reflex, primed | fresh per sample | fresh copy per sample |
compile.warm, .incremental, export.*, run.*, scale.* | ctx.cache_dir/reflex, primed | host default | ctx.cache_dir/app, primed by one compile |
- A host bun is hidden. reflex (both versions) runs
REFLEX_DIR/bun/bin/bun, but when that is missing it takes abunfromPATHif it is new enough:MIN_VERSIONis 1.3.0 in 0.8.23 and 1.4.0 at HEAD. This sandbox has bun 1.3.11 in/root/.bun/binand/usr/local/bin(next tonode), so 0.8.23 skipped its bun download (a "cold" init that was warm) and ran a different bun than HEAD. The lifecycle commands run with eachPATHdirectory holding a bun replaced by a view (symlinks to everything else in it, inctx.workdir), so a freshREFLEX_DIRalways downloads the subject's own bun: below, everyinit.coldprepare after the first deletes an 80.8 MB (HEAD, bun 1.4.0) or 104.3 MB (0.8.23, bun 1.3.4)REFLEX_DIR. - Metrics of
timebenchmarks:wall(CliResult.wall_s, returned explicitly),cpu,peak_mem(whole process tree).extra:phases(attribution()),timing,cpu_method,memory_method,peak_reset,returncode, for cold samplesdeleted_bytes(whatpreparedeleted:.weband bun cache, or.webandREFLEX_DIR; 0 before the first sample), and for incremental samples the newmarker.startupbenchmarks returnprocess_ready,http_readywithreadinessinextra.lifecycle.importreturnswallonly. - Collectors:
CgroupScope()whenCgroupScope.available()isNone, else PSS sampling;phases=True. Whole-run peaks (peak_resetrecorded). - Timeouts: each command gets 30 s less than its hook, so the driver kills a stuck command and reports it before the scheduler abandons the hook: hooks 120 s (commands 90 s), 600 s (570 s) for
compile.cold, prod/preview start and every scale tier (the 1000-page tier uses 570 s, the others 90 s),setup_timeout900 s (priming 870 s; priming a 1000-page app took ~70 s here).AppProcessgets the command timeout forstart()plus 20 s forwait_http_ready(). warmup=1for warm, incremental, export, run and import; 0 for cold and init.estimates come from the runs below.
The fixture record (dims)
Context gains fixture: FixtureDoc | None = None (last field). Every benchmark that drives an app (the playground or a generated one) sets ctx.fixture in setup (which always runs; setup_cache does not when a scheduler already primed the directory), and Session._setup copies it into the entry after setup succeeds:
"dims": {"fixture": "playground", "fixture_hash": "sha256:5c66b0dc30717af353d0f8b0765ac1a73207debf1fbb3a59e6d2c0b39e9226f9"}
dims are part of the pairing key (store.entry_key) and of the series key (store.series_key), so a playground edit or a generator change starts a new series. init.* and import drive no fixture and keep dims empty. The document-level fixture stays null: one invocation can drive several fixtures (--suite all runs the playground and four generated tiers), which one slot cannot describe.
ensure_fixture keeps the app in cache_dir/app with a fixture.json stamp next to it and reuses it only while the stamp equals describe(), else deletes and remakes it; the stamp is written after make returns, so a half-made app is never reused. setup_cache directories are keyed by subject identity and params, and a dirty workspace shares one with a dirty path: subject on the same commit, so the stamp is what makes a fixture change invalidate a primed app. materialize_playground copies with an ignore list mirroring examples/playground/.gitignore (.web, .states, __pycache__, *.db, *.py[cod], reflex.lock, uv.lock, .venv, uploaded_files, assets/external anchored to the app root) plus .content-hash; the hash is the committed line, never recomputed.
The generator contract
-
GenParams(pages, components_per_page=20, state_vars=20, substate_depth=2, computed_vars=5, seed=42); counts below 1 (0 for depth and computed vars) raise. -
describe(params)→{"name": "gen", "content_hash": "sha256:" + sha256(generate.py bytes + canonical params JSON), "params": asdict(params)}. Equal params give byte-identical trees (no timestamps, no set iteration); any change ofgenerate.pychanges every generated hash. -
Tree (app
genapp):rxconfig.pywith the playground'sRadixThemesPluginguard and no other plugin;genapp/genapp.py(rx.App(), page 0 at/, pageiat/page-<i>);genapp/state.py(GenState(rx.State)withstate_varstyped fields cyclingint,str,float,bool,list[str],computed_vars@rx.varproperties and anincrementhandler, thenSub1(GenState)…Sub<depth>each with three vars and one@rx.eventhandler);genapp/components/shared.py(the layout every page imports:rx.cond(GenState.is_hydrated, rx.el.span(id="bench-hydrated"))and theroottarget);genapp/pages/page_<i>.py(a heading andcomponents_per_pagecomponents fromrx.vstack,rx.hstack,rx.heading,rx.text,rx.button,rx.link,rx.foreach,rx.condover the fields, computed vars, substates and handlers; consecutive pages start at consecutive fields, so the pages use them all). -
Only
import reflex as rxand APIs the playground proved on 0.8.23; the tests scan every generated module withastand allow nothing butreflexandgenapp.*. -
Pragmas, as in the playground:
NAME = "m-initial-<name>" # bench:hmr-target <name>on its own line, rendered in#bench-marker-<name>. Oneroottarget in the shared layout;leaf-<i>targets inmin(pages, 10)pages drawn withrandom.Random(seed).sample(uniform, without replacement). -
bench-manifest.json:{"targets": [ {"name": "root", "path": "genapp/components/shared.py", "route": "/", "depth": 2}, {"name": "leaf-3", "path": "genapp/pages/page_3.py", "route": "/page-3", "depth": 1}, ... ]}depthis the import distance from the app module;routeis a page showing the target, so PR-6 can navigate to it without parsing code.
Debug logging (phases=True) costs 0.04 %
reflex compile of the primed playground on HEAD, 10 × --loglevel info and 10 × --loglevel debug, interleaved ABBA after one untimed warmup, through run_cli without collectors (throwaway script, not committed):
| arm | n | median wall | samples (s) |
|---|---|---|---|
--loglevel info | 10 | 1.1009 s | 1.033 1.003 1.209 1.103 1.015 1.060 1.099 1.111 1.163 1.203 |
--loglevel debug | 10 | 1.1013 s | 1.111 1.058 1.187 1.094 1.031 1.108 1.095 1.067 1.175 1.190 |
Median ratio debug/info 1.0004, below the 2 % of PLAN §8.2, so the samples are timed with phases=True (no separate untimed compile). For reference, the full local instrumentation (phases=True with its process-tree sampler, plus PSS sampling) against plain info: medians 1.1609 s vs 1.1238 s, ratio 1.033, n = 10 each, ABBA. That 3 % is the samplers, not the logging, and applies to both arms of a comparison; on a cgroup host PSS sampling is off.
Export: what a second export reuses
After priming (one compile), two exports in a row on the same app (install and frontend from the process tree):
| version | env | sample | wall | install | frontend |
|---|---|---|---|---|---|
| HEAD | dev | 1 | 5.06 s | 0.00 s | 3.74 s |
| HEAD | dev | 2 | 4.79 s | 0.00 s | 3.51 s |
| HEAD | prod | 1 | 4.82 s | 0.00 s | 3.39 s |
| HEAD | prod | 2 | 4.71 s | 0.00 s | 3.32 s |
| 0.8.23 | dev | 1 | 9.55 s | 0.00 s | 8.13 s |
| 0.8.23 | dev | 2 | 8.82 s | 0.00 s | 7.43 s |
| 0.8.23 | prod | 1 | 8.26 s | 0.00 s | 6.74 s |
| 0.8.23 | prod | 2 | 8.76 s | 0.00 s | 7.31 s |
The second export reuses only node_modules (no install, as after priming); the frontend is rebuilt and both zips rewritten every time, within 2–8 % of the first. The docstring states it: a sample measures a primed app whose previous export is replaced (warmup 1).
Verification
All on this sandbox: a 4-core Firecracker VM (Intel Xeon, 16.9 GB), Python 3.14.7, no systemd and a hybrid cgroup v1 layout. So no cgroup scopes here: every sample records cpu_method: "rusage", memory_method: "pss_sampling", peak_reset: null; I have no cgroup host to show cgroup for both. The sandbox's environment carries BUN_OPTIONS=--smol and NODE_OPTIONS=--max-old-space-size=8192, which reach reflex through ctx.env like any host setting. HEAD is this branch at 5c2f4d6 (clean); 0.8.23 is --reflex 0.8.23 (a PyPI venv on Python 3.14).
Daily suite, --runs 5
uv run reflex-bench run --suite daily 'lifecycle.*' --runs 5 on HEAD, then with --reflex 0.8.23:
HEAD: 12 ok
lifecycle.compile.cold[app=playground] median ± 95 % CI range n
wall 9.88 s (need ≥ 6 samples) 8.81 s … 13.21 s 5
⚠ high variance: CV 17 % (warns at 10 %)
cpu 7.445 s (need ≥ 6 samples) 4.641 s … 9.596 s 5
⚠ high variance: CV 27 % (warns at 10 %)
peak_mem 165.1 MB (need ≥ 6 samples) 162.1 MB … 180.3 MB 5
lifecycle.compile.incremental[app=playground]
wall 1.126 s (need ≥ 6 samples) 1.084 s … 1.160 s 5
cpu 1.112 s (need ≥ 6 samples) 1.083 s … 1.136 s 5
peak_mem 83.71 MB (need ≥ 6 samples) 83.50 MB … 96.40 MB 5
⚠ first sample much slower: raise --warmup (modified z-score 36.9)
lifecycle.compile.warm[app=playground]
wall 1.067 s (need ≥ 6 samples) 1.026 s … 1.197 s 5
cpu 1.063 s (need ≥ 6 samples) 1.019 s … 1.194 s 5
peak_mem 83.62 MB (need ≥ 6 samples) 83.58 MB … 97.25 MB 5
lifecycle.export.dev[app=playground]
wall 4.768 s (need ≥ 6 samples) 4.527 s … 4.933 s 5
cpu 6.841 s (need ≥ 6 samples) 6.655 s … 7.029 s 5
peak_mem 505.9 MB (need ≥ 6 samples) 494.0 MB … 511.8 MB 5
lifecycle.export.prod[app=playground]
wall 4.504 s (need ≥ 6 samples) 4.397 s … 4.763 s 5
cpu 6.551 s (need ≥ 6 samples) 6.378 s … 6.761 s 5
peak_mem 511.6 MB (need ≥ 6 samples) 501.2 MB … 512.1 MB 5
⚠ 1 severe outlier (sample 2: -2 %). Kept.
lifecycle.import
wall 27.15 ms (need ≥ 6 samples) 25.83 ms … 34.57 ms 5
⚠ high variance: CV 13 % (warns at 10 %)
lifecycle.init.cold
wall 3.429 s (need ≥ 6 samples) 3.178 s … 3.499 s 5
cpu 1.459 s (need ≥ 6 samples) 1.425 s … 1.563 s 5
peak_mem 69.68 MB (need ≥ 6 samples) 69.62 MB … 69.77 MB 5
⚠ 1 severe outlier (sample 2: +0 %). Kept.
lifecycle.init.warm
wall 1.017 s (need ≥ 6 samples) 0.795 s … 1.038 s 5
⚠ high variance: CV 10 % (warns at 10 %)
⚠ 1 severe outlier (sample 4: -22 %). Kept.
cpu 612.5 ms (need ≥ 6 samples) 581.9 ms … 633.0 ms 5
peak_mem 56.97 MB (need ≥ 6 samples) 56.92 MB … 57.00 MB 5
lifecycle.run.backend_only.ready[app=playground]
process_ready 1.024 s (need ≥ 6 samples) 0.985 s … 1.063 s 5
http_ready 1.030 s (need ≥ 6 samples) 0.990 s … 1.070 s 5
lifecycle.run.dev.ready[app=playground]
process_ready 2.166 s (need ≥ 6 samples) 2.059 s … 2.224 s 5
http_ready 2.679 s (need ≥ 6 samples) 2.607 s … 2.756 s 5
lifecycle.run.preview.ready[app=playground]
process_ready 4.583 s (need ≥ 6 samples) 4.490 s … 4.771 s 5
http_ready 4.593 s (need ≥ 6 samples) 4.501 s … 4.781 s 5
lifecycle.run.prod.ready[app=playground]
process_ready 4.907 s (need ≥ 6 samples) 4.597 s … 4.948 s 5
http_ready 4.918 s (need ≥ 6 samples) 4.608 s … 4.961 s 5
0.8.23: 11 ok, preview unsupported
lifecycle.compile.cold[app=playground] median ± 95 % CI range n
wall 9.88 s (need ≥ 6 samples) 9.40 s … 14.52 s 5
⚠ high variance: CV 20 % (warns at 10 %)
⚠ 1 severe outlier (sample 1: +47 %). Kept.
cpu 10.08 s (need ≥ 6 samples) 9.60 s … 10.29 s 5
peak_mem 286.4 MB (need ≥ 6 samples) 275.7 MB … 303.4 MB 5
lifecycle.compile.incremental[app=playground]
wall 1.270 s (need ≥ 6 samples) 1.230 s … 1.349 s 5
cpu 1.257 s (need ≥ 6 samples) 1.219 s … 1.327 s 5
peak_mem 97.79 MB (need ≥ 6 samples) 97.71 MB … 97.82 MB 5
lifecycle.compile.warm[app=playground]
wall 1.320 s (need ≥ 6 samples) 1.230 s … 1.368 s 5
cpu 1.308 s (need ≥ 6 samples) 1.224 s … 1.349 s 5
peak_mem 97.77 MB (need ≥ 6 samples) 97.71 MB … 97.88 MB 5
⚠ first sample much slower: raise --warmup (modified z-score 19.4)
⚠ 2 severe outliers (samples 1: +0 %, 2: -0 %). Kept.
lifecycle.export.dev[app=playground]
wall 8.462 s (need ≥ 6 samples) 8.341 s … 9.053 s 5
cpu 12.62 s (need ≥ 6 samples) 12.44 s … 13.30 s 5
peak_mem 760.6 MB (need ≥ 6 samples) 751.8 MB … 762.9 MB 5
⚠ 1 severe outlier (sample 1: -1 %). Kept.
lifecycle.export.prod[app=playground]
wall 8.365 s (need ≥ 6 samples) 8.302 s … 8.634 s 5
cpu 12.57 s (need ≥ 6 samples) 12.40 s … 12.95 s 5
peak_mem 743.4 MB (need ≥ 6 samples) 726.4 MB … 760.8 MB 5
lifecycle.import
wall 22.17 ms (need ≥ 6 samples) 21.30 ms … 29.58 ms 5
⚠ high variance: CV 15 % (warns at 10 %)
⚠ first sample much slower: raise --warmup (modified z-score 167.1)
⚠ 2 severe outliers (samples 1: +33 %, 4: -4 %). Kept.
lifecycle.init.cold
wall 3.990 s (need ≥ 6 samples) 3.428 s … 4.614 s 5
⚠ high variance: CV 12 % (warns at 10 %)
cpu 2.018 s (need ≥ 6 samples) 1.934 s … 2.086 s 5
⚠ 2 severe outliers (samples 2: +3 %, 3: -4 %). Kept.
peak_mem 101.6 MB (need ≥ 6 samples) 101.5 MB … 101.7 MB 5
lifecycle.init.warm
wall 896.4 ms (need ≥ 6 samples) 844.6 ms … 932.7 ms 5
cpu 880.0 ms (need ≥ 6 samples) 820.7 ms … 925.4 ms 5
peak_mem 79.98 MB (need ≥ 6 samples) 79.97 MB … 80.03 MB 5
⚠ 1 severe outlier (sample 2: +0 %). Kept.
lifecycle.run.backend_only.ready[app=playground]
process_ready 2.356 s (need ≥ 6 samples) 2.300 s … 2.379 s 5
http_ready 2.378 s (need ≥ 6 samples) 2.321 s … 2.402 s 5
lifecycle.run.dev.ready[app=playground]
process_ready 2.475 s (need ≥ 6 samples) 2.403 s … 2.556 s 5
http_ready 3.112 s (need ≥ 6 samples) 3.052 s … 3.199 s 5
lifecycle.run.preview.ready[app=playground]
– unsupported: requires reflex >= 0.9.8 (subject has 0.8.23)
lifecycle.run.prod.ready[app=playground]
process_ready 9.188 s (need ≥ 6 samples) 9.076 s … 9.330 s 5
http_ready 9.198 s (need ≥ 6 samples) 9.086 s … 9.340 s 5
12 benchmarks: 11 ok · 1 unsupported
Both as one table (medians of the timed samples):
| id | metric | HEAD median | 0.8.23 median | n (HEAD / 0.8.23) |
|---|---|---|---|---|
lifecycle.compile.cold[app=playground] | cpu | 7.445 s | 10.08 s | 5 / 5 |
lifecycle.compile.cold[app=playground] | peak_mem | 165.1 MB | 286.4 MB | 5 / 5 |
lifecycle.compile.cold[app=playground] | wall | 9.884 s | 9.883 s | 5 / 5 |
lifecycle.compile.incremental[app=playground] | cpu | 1.112 s | 1.257 s | 5 / 5 |
lifecycle.compile.incremental[app=playground] | peak_mem | 83.71 MB | 97.79 MB | 5 / 5 |
lifecycle.compile.incremental[app=playground] | wall | 1.126 s | 1.270 s | 5 / 5 |
lifecycle.compile.warm[app=playground] | cpu | 1.063 s | 1.308 s | 5 / 5 |
lifecycle.compile.warm[app=playground] | peak_mem | 83.62 MB | 97.77 MB | 5 / 5 |
lifecycle.compile.warm[app=playground] | wall | 1.067 s | 1.320 s | 5 / 5 |
lifecycle.export.dev[app=playground] | cpu | 6.841 s | 12.62 s | 5 / 5 |
lifecycle.export.dev[app=playground] | peak_mem | 505.9 MB | 760.6 MB | 5 / 5 |
lifecycle.export.dev[app=playground] | wall | 4.768 s | 8.462 s | 5 / 5 |
lifecycle.export.prod[app=playground] | cpu | 6.551 s | 12.57 s | 5 / 5 |
lifecycle.export.prod[app=playground] | peak_mem | 511.6 MB | 743.4 MB | 5 / 5 |
lifecycle.export.prod[app=playground] | wall | 4.504 s | 8.365 s | 5 / 5 |
lifecycle.import | wall | 27.15 ms | 22.17 ms | 5 / 5 |
lifecycle.init.cold | cpu | 1.459 s | 2.018 s | 5 / 5 |
lifecycle.init.cold | peak_mem | 69.68 MB | 101.6 MB | 5 / 5 |
lifecycle.init.cold | wall | 3.429 s | 3.990 s | 5 / 5 |
lifecycle.init.warm | cpu | 612.5 ms | 880.0 ms | 5 / 5 |
lifecycle.init.warm | peak_mem | 56.97 MB | 79.98 MB | 5 / 5 |
lifecycle.init.warm | wall | 1.017 s | 896.4 ms | 5 / 5 |
lifecycle.run.backend_only.ready[app=playground] | http_ready | 1.030 s | 2.378 s | 5 / 5 |
lifecycle.run.backend_only.ready[app=playground] | process_ready | 1.024 s | 2.356 s | 5 / 5 |
lifecycle.run.dev.ready[app=playground] | http_ready | 2.679 s | 3.112 s | 5 / 5 |
lifecycle.run.dev.ready[app=playground] | process_ready | 2.166 s | 2.475 s | 5 / 5 |
lifecycle.run.preview.ready[app=playground] | http_ready | 4.593 s | unsupported | 5 / 0 |
lifecycle.run.preview.ready[app=playground] | process_ready | 4.583 s | unsupported | 5 / 0 |
lifecycle.run.prod.ready[app=playground] | http_ready | 4.918 s | 9.198 s | 5 / 5 |
lifecycle.run.prod.ready[app=playground] | process_ready | 4.907 s | 9.188 s | 5 / 5 |
- Cold vs warm (wall medians):
init3.429 / 1.017 s = 3.37× on HEAD, 3.990 / 0.896 s = 4.45× on 0.8.23 (the bun download: everyinit.coldprepare after the first deleted an 80.8 MBREFLEX_DIRon HEAD, 104.3 MB on 0.8.23).compile9.884 / 1.067 s = 9.26× on HEAD, 9.883 / 1.320 s = 7.49× on 0.8.23; everycompile.coldprepare after the first deleted 140 MB of.weband 166 MB of bun cache (HEAD; 161 MB and 192 MB on 0.8.23), so each sample installed every package from the registry. compile.incrementallands oncompile.warm, 8–9× below cold: 1.126 s vs 1.067 s on HEAD (+5.5 %), 1.270 s vs 1.320 s on 0.8.23 (−3.8 %), both within the run-to-run spread. The phases say why: in both,installandfrontendare 0, the Python compile phases sum to 0.06 s, andother(interpreter start-up,import reflex, importing and evaluating the app,.webbookkeeping) is ~1.0–1.3 s of the total.reflex compilerecompiles every page whether one module changed or none, so the edit of one leaf module costs nothing measurable; cold is dominated by the package install (7.6–13.0 s of 8.8–14.5 s).
Scaling tiers, --runs 3
uv run reflex-bench run 'lifecycle.scale.*' --runs 3 on HEAD:
| tier | compile.warm wall | compile.incremental wall | peak_mem | python phase / other (warm) |
|---|---|---|---|---|
| pages=1 | 1.131 s | 1.156 s | 83.4 MB | 0.05 s / 1.08 s |
| pages=10 | 1.467 s | 1.459 s | 89.1 MB | 0.29 s / 1.18 s |
| pages=100 | 5.872 s | 6.018 s | 144.0 MB | 3.09 s / 2.75 s |
| pages=1000 | 63.33 s | 63.45 s | 691.6 MB | 42.32 s / 21.18 s |
Ratios: warm 100/10 = 4.00×, 1000/100 = 10.79×; incremental 100/10 = 4.12×, 1000/100 = 10.54×. Below ~100 pages the fixed start-up dominates; from 100 to 1000 pages compile time grows linearly (~64 ms per page, ~44 ms of it in the Python compile phases). Priming the 1000-page tier (generate + first compile with package install) took ~70 s, well inside setup_timeout=900.
Printed table
lifecycle.scale.compile.incremental[pages=1] median ± 95 % CI range n
wall 1.156 s (need ≥ 6 samples) 1.084 s … 1.206 s 3
cpu 1.134 s (need ≥ 6 samples) 1.084 s … 1.190 s 3
peak_mem 95.70 MB (need ≥ 6 samples) 83.53 MB … 97.55 MB 3
lifecycle.scale.compile.incremental[pages=10]
wall 1.459 s (need ≥ 6 samples) 1.438 s … 1.553 s 3
cpu 1.433 s (need ≥ 6 samples) 1.428 s … 1.540 s 3
peak_mem 100.9 MB (need ≥ 6 samples) 89.1 MB … 103.0 MB 3
lifecycle.scale.compile.incremental[pages=100]
wall 6.018 s (need ≥ 6 samples) 5.692 s … 6.039 s 3
cpu 5.956 s (need ≥ 6 samples) 5.666 s … 5.975 s 3
peak_mem 144.2 MB (need ≥ 6 samples) 144.1 MB … 157.6 MB 3
lifecycle.scale.compile.incremental[pages=1000]
wall 63.45 s (need ≥ 6 samples) 63.10 s … 63.53 s 3
cpu 62.46 s (need ≥ 6 samples) 62.16 s … 62.50 s 3
peak_mem 691.8 MB (need ≥ 6 samples) 691.7 MB … 700.1 MB 3
lifecycle.scale.compile.warm[pages=1]
wall 1.131 s (need ≥ 6 samples) 1.082 s … 1.169 s 3
cpu 1.099 s (need ≥ 6 samples) 1.078 s … 1.147 s 3
peak_mem 83.43 MB (need ≥ 6 samples) 83.41 MB … 97.32 MB 3
⚠ first sample much slower: raise --warmup (modified z-score 508.2)
lifecycle.scale.compile.warm[pages=10]
wall 1.467 s (need ≥ 6 samples) 1.387 s … 1.518 s 3
cpu 1.454 s (need ≥ 6 samples) 1.378 s … 1.503 s 3
peak_mem 89.1 MB (need ≥ 6 samples) 89.0 MB … 102.8 MB 3
⚠ first sample much slower: raise --warmup (modified z-score 94.3)
lifecycle.scale.compile.warm[pages=100]
wall 5.872 s (need ≥ 6 samples) 5.676 s … 5.885 s 3
cpu 5.779 s (need ≥ 6 samples) 5.632 s … 5.788 s 3
peak_mem 144.0 MB (need ≥ 6 samples) 144.0 MB … 156.6 MB 3
lifecycle.scale.compile.warm[pages=1000]
wall 63.33 s (need ≥ 6 samples) 63.12 s … 63.50 s 3
cpu 62.37 s (need ≥ 6 samples) 62.21 s … 62.66 s 3
peak_mem 691.6 MB (need ≥ 6 samples) 691.6 MB … 691.6 MB 3
Phase attribution
For every time sample, parts/total = (python + install + frontend + max(other, 0)) / total. All 39 samples with phases on HEAD and all 39 on 0.8.23 are at 1.000 with mismatch: false (no phases: warning in any entry); so are the 32 scale samples and the 18 of the ab and offline runs. Per sample for compile.cold and compile.warm:
HEAD:
lifecycle.compile.cold[app=playground]
| sample | warmup | total s | python s | install s | frontend s | other s | parts/total | mismatch |
|---|---|---|---|---|---|---|---|---|
| 0 | False | 13.206 | 0.060 | 11.976 | 0.000 | 1.170 | 1.000 | False |
| 1 | False | 9.414 | 0.060 | 8.211 | 0.000 | 1.143 | 1.000 | False |
| 2 | False | 9.884 | 0.110 | 8.624 | 0.000 | 1.150 | 1.000 | False |
| 3 | False | 11.803 | 0.070 | 10.606 | 0.000 | 1.126 | 1.000 | False |
| 4 | False | 8.813 | 0.070 | 7.558 | 0.000 | 1.185 | 1.000 | False |
lifecycle.compile.warm[app=playground]
| sample | warmup | total s | python s | install s | frontend s | other s | parts/total | mismatch |
|---|---|---|---|---|---|---|---|---|
| 0 | True | 1.204 | 0.070 | 0.000 | 0.000 | 1.134 | 1.000 | False |
| 1 | False | 1.061 | 0.060 | 0.000 | 0.000 | 1.001 | 1.000 | False |
| 2 | False | 1.026 | 0.060 | 0.000 | 0.000 | 0.966 | 1.000 | False |
| 3 | False | 1.121 | 0.060 | 0.000 | 0.000 | 1.061 | 1.000 | False |
| 4 | False | 1.197 | 0.060 | 0.000 | 0.000 | 1.137 | 1.000 | False |
| 5 | False | 1.067 | 0.060 | 0.000 | 0.000 | 1.007 | 1.000 | False |
0.8.23:
lifecycle.compile.cold[app=playground]
| sample | warmup | total s | python s | install s | frontend s | other s | parts/total | mismatch |
|---|---|---|---|---|---|---|---|---|
| 0 | False | 10.189 | 0.060 | 8.730 | 0.000 | 1.398 | 1.000 | False |
| 1 | False | 14.524 | 0.080 | 13.039 | 0.000 | 1.405 | 1.000 | False |
| 2 | False | 9.883 | 0.060 | 8.563 | 0.000 | 1.260 | 1.000 | False |
| 3 | False | 9.485 | 0.060 | 8.118 | 0.000 | 1.307 | 1.000 | False |
| 4 | False | 9.400 | 0.080 | 7.966 | 0.000 | 1.354 | 1.000 | False |
lifecycle.compile.warm[app=playground]
| sample | warmup | total s | python s | install s | frontend s | other s | parts/total | mismatch |
|---|---|---|---|---|---|---|---|---|
| 0 | True | 1.209 | 0.070 | 0.000 | 0.000 | 1.139 | 1.000 | False |
| 1 | False | 1.320 | 0.060 | 0.000 | 0.000 | 1.260 | 1.000 | False |
| 2 | False | 1.270 | 0.070 | 0.000 | 0.000 | 1.200 | 1.000 | False |
| 3 | False | 1.354 | 0.070 | 0.000 | 0.000 | 1.284 | 1.000 | False |
| 4 | False | 1.230 | 0.050 | 0.000 | 0.000 | 1.180 | 1.000 | False |
| 5 | False | 1.368 | 0.070 | 0.000 | 0.000 | 1.298 | 1.000 | False |
No orphans
After every run above (HEAD, 0.8.23, scale, ab, the offline run) a psutil scan for -m reflex, reflex run, granian, vite, node, bun in the command line or REFLEX_BENCH_OWNER in the environment, excluding the scanning process and its ancestors, printed no leftover processes.
Ctrl-C during lifecycle.run.prod.ready: a script starts uv run reflex-bench run lifecycle.run.prod.ready --runs 5 --no-save in its own process group, waits until the app (or one of its processes) exists, and sends SIGINT to the harness's group, as a terminal does:
=== Ctrl-C 0.3 s after `reflex run --env prod` started (workspace)
app tree at Ctrl-C: 19132 python
harness exit code: 130
app tree processes still alive: []
interrupted
no leftover processes
=== Ctrl-C 3.0 s after `reflex run --env prod` started (workspace)
app tree at Ctrl-C: 19178 python, 19194 bun, 19197 node
harness exit code: 130
app tree processes still alive: []
interrupted
no leftover processes
=== Ctrl-C 8.5 s after `reflex run --env prod` started (0.8.23)
app tree at Ctrl-C: 19260 python, 19262 python, 19263 python, 19275 bun, 19277 node
harness exit code: 130
app tree processes still alive: []
interrupted
no leftover processes
=== Ctrl-C 0.2 s after granian started (0.8.23)
app tree at Ctrl-C: 19475 python, 19477 python, 19478 python, 19587 bun, 19588 node, 19595 python, 19598 python, 19599 python
harness exit code: 130
app tree processes still alive: []
interrupted
no leftover processes
A/A
uv run reflex-bench ab --aa --head workspace lifecycle.compile.warm --rounds 4, with a poller recording every 50 ms which processes carry REFLEX_BENCH_OWNER:
[1/1] lifecycle.compile.warm[app=playground] ok · 8 samples · 13.4 s
lifecycle.compile.warm[app=playground] median ± 95 % CI range n
wall [A] 1.098 s (need ≥ 6 samples) 1.051 s … 1.216 s 4
wall [B] 1.136 s (need ≥ 6 samples) 1.053 s … 1.200 s 4
cpu [A] 1.094 s (need ≥ 6 samples) 1.047 s … 1.187 s 4
cpu [B] 1.121 s (need ≥ 6 samples) 1.045 s … 1.181 s 4
peak_mem [A] 95.01 MB (need ≥ 6 samples) 82.28 MB … 95.87 MB 4
peak_mem [B] 82.29 MB (need ≥ 6 samples) 82.20 MB … 94.71 MB 4
reflex-bench compare A=workspace B=workspace α=0.01 (Holm, 3 metrics) threshold=3 %
lifecycle.compile.warm[app=playground] wall 1.098 s 1.136 s +3.5 % p=1.00 n=4/4 ? inconclusive (~6 runs/side needed)
cpu 1.094 s 1.121 s +2.5 % p=1.00 n=4/4 ? inconclusive (~6 runs/side needed)
peak_mem 95.01 MB 82.29 MB -13 % p=0.60 n=4/4 ? inconclusive (~6 runs/side needed)
0 regressed · 0 improved · 3 inconclusive · 0 unchanged
Both arms ok (A/A, inconclusive at n = 4 as expected). The poller saw owned processes in 234 of 280 polls: 198 inside a sample window (±50 ms), 36 before the first sample (the untimed priming of both arms' setup_cache) and none between samples; the orphan scan after the run found nothing. The gaps between samples are 0–2.3 ms: run_cli reaps the tree before sample() returns, and every AppProcess starts in sample and stops in conclude.
The pr suite needs no network
unshare -n -- env UV_OFFLINE=1 uv run --offline reflex-bench run --suite pr --runs 3 (a network namespace with no interface up) on the primed caches: both ok, compile.warm 1.096 s, compile.incremental 1.122 s, the same as online. Only the first priming of a new commit's cache downloads bun and packages, in setup_cache, never in a sample.
list --suite pr
$ uv run reflex-bench list --suite pr
id kind metrics suites estimate
lifecycle.compile.incremental[app=playground] time wall (s), cpu (s), peak_mem (B) pr,daily ~32 s
lifecycle.compile.warm[app=playground] time wall (s), cpu (s), peak_mem (B) pr,daily ~32 s
2 benchmarks · ~65 s estimated with default settings
Opt-in slow tests
REFLEX_BENCH_APP_TESTS=1 REFLEX_BENCH_NETWORK_TESTS=1 uv run pytest tests/units/reflex_bench/suites/test_lifecycle_app.py (fresh bench home; 0.8.23 through subjects.resolve("0.8.23", python="3.12", ...)):
test_the_generated_app_compiles[1-workspace] PASSED
test_the_generated_app_compiles[1-0.8.23] PASSED
test_the_generated_app_compiles[10-workspace] PASSED
test_the_generated_app_compiles[10-0.8.23] PASSED
test_smoke_runs[daily-workspace] PASSED (86 s: every entry ok)
test_smoke_runs[daily-0.8.23] PASSED (95 s: every entry ok, preview unsupported)
test_smoke_runs[scale-workspace] FAILED see below; passed on rerun (13 s)
test_smoke_runs[scale-0.8.23] PASSED
The one failure was the network, recorded as data the way it should be: priming lifecycle.scale.compile.warm[pages=10] in the fresh home got curl: (22) The requested URL returned error: 502 from github.com/oven-sh/bun/releases/download/bun-v1.4.0/bun-linux-x64.zip, so the entry is failed with that error and the run went on. The rerun passed.
New Feature Submission:
- Does your submission pass the tests?
- Have you linted your code locally prior to submission?
Changes To Core Features:
- Have you added an explanation of what your changes do and why you'd like us to include them?
- Have you written new tests for your core changes, as applicable?
- Have you successfully ran tests with your changes locally?
Tests
Written before the code they cover; the tests of new behaviour failed first (the store test and the empty-dims tests pin behaviour that already held):
tests/units/reflex_bench/fixtures/test_generate.py(31): byte-identical trees for equal params; a different hash for every param and for a changed generator source (patching the bytesdescribereads); page files and routes (astoveradd_page); components per page; targets for 1, 7, 10 and 1000 pages (root first, 1–10 distinct leaves, each at its path with exactly one pragma line and its#bench-marker-<name>); the seed picks them; every pragma line matches^\w+ = "m-initial-[\w-]+" # bench:hmr-target [\w-]+$; the output imports onlyreflexandgenapp.*; the rxconfig guard; the state tree shape; every module compiles for extreme params; invalid params; a non-empty destination;main().tests/units/reflex_bench/fixtures/test_fixtures.py(13): the root is found from inside the checkout; a missing.content-hashraises a clear error; the hash is the committed line; the tracked files are copied without.content-hash; the ignore list (includingassets/externalanchored to the root whileplayground/external/andassets/externals.cssare kept);ensure_fixturereuses on an equal stamp (keeping what priming added), rebuilds on a changed stamp, after an interruptedmakeand when the app is missing;bump_markerrewrites exactly the pragma line, continues from the number in the file and needs exactly one target.tests/units/reflex_bench/suites/test_lifecycle.py(23), withrun_cliandAppProcessreplaced by recorders returningCliResult/Readinessbuilt from the dataclasses: the suites and instance names; the argv, cwd and env of every id (REFLEX_DIR/BUN_INSTALL_CACHE_DIRunderctx.workdirfor cold, underctx.cache_dirfor warm, host bun cache untouched otherwise); what eachpreparedeletes and measures; the untimed priming;compile.incrementalchanges exactly the pragma line, with a new value each call; the export destination is recreated empty; eachrunmode andbackend_only;concludestops the app whensampleraised, once; the import's prefix; the scale tiers' fixture, timeouts and hidden params;ctx.fixture; theextrakeys; the host bun is hidden while every otherPATHtool stays reachable.test_scheduler.py: the fixture lands indimsfromsetup_cacheorsetup;dimsstay empty without a fixture and whensetupfails; thephases:warning counts only timed samples, survivesfinalize(), is absent within tolerance and is per arm.test_store.py: series and entry keys differ byfixture_hash.drivers/test_app_process.py: therun_cliprefix.test_cli.py: see "Changes to lower PRs".tests/units/reflex_bench/suites/test_lifecycle_app.py: the opt-in real runs above.- The harness-import test (
test_context.py::test_the_harness_never_imports_reflex) stays green:discover()importslifecycle, which imports the generator, and nothing loadsreflex.
Check results
| Check | Result |
|---|---|
uv run ruff check . | All checks passed! |
uv run ruff format --check . | 1631 files already formatted |
uv run pyright reflex tests packages/reflex-bench/src | 0 errors, 0 warnings, 0 informations |
uv run pytest tests/units/reflex_bench -q | 567 passed, 10 skipped (the opt-in modules) in 25 s. Coverage: fixtures/__init__.py 100 %, fixtures/generate.py 98.6 %, suites/lifecycle.py 98.2 %, scheduler.py 98.6 %; package 94.9 % |
opt-in test_lifecycle_app.py (app + network) | 7 passed, 1 failed on a GitHub 502, passed on rerun |
uv run pre-commit run --files <changed files> | ruff-format, ruff-check, codespell, update-pyi-files, pyright, ty: Passed |
No news fragment: reflex-bench is in never-publish-packages, and nothing under reflex/ or a published package changed. The last commit (98bff2a) only corrects two numbers in the lifecycle.py module docstring; the runs above are on 5c2f4d6, with the same code.
Deviations from the spec
- Branch: this session is pinned to
farhan/gallant-gauss-fs7wl5, so the PR comes from that branch instead offarhan/reflex-bench-lifecycle. - Scale ids:
lifecycle.scale.compile.{warm,incremental}[pages=N]instead of PLAN §8.2'slifecycle.compile.*[app=gen,pages=N]: suites are chosen per benchmark (registry.select), and the tiers belong inallbut not inpr/daily. bump_marker(path, target) -> str(infixtures, not in the spec's list): the incremental benchmarks need a value that differs from what the cached app was last compiled with. A counter that restarts at 1 per instance does not guarantee it: an earlier invocation that took one sample leavesm-1-leafin the reused app, and the two arms ofab --aashare one cache directory, so arm B would write the value arm A just compiled, and a warm compile would be recorded as incremental.bump_markerwritesm-<n+1>-<target>wherenis the number in the file. Values keep the spec'sm-<n>-leafform.- The host bun is hidden from the lifecycle commands (not in the spec; found by measurement, see "Benchmarks").
- Manifest: targets carry
routebesidesname,pathanddepth, androotis listed first;depthis the import distance from the app module (pages 1, layout 2). - Cold
extra:deleted_bytesofinit.coldcounts.webandREFLEX_DIR(init installs no packages, so there is no bun cache to delete; the bun binary is inREFLEX_DIR);compile.coldcounts.weband the bun cache as specified. - Timeouts: the decorator values are the spec's (120 / 600 / 900 s); commands get 30 s less so the driver, not the scheduler, stops a stuck command. The 1000-page tier cannot have its own decorator timeout (timeouts are per benchmark), so both scale benchmarks declare 600 s and pick the command timeout per tier.
generate()refuses a non-empty destination (stale pages from a larger app would stay behind), andGenParamsrejects counts that make no app.lifecycle.importhas no fixture and runs inctx.workdirwithctx.env; it runsrun_cli(python, [], prefix=("-c", "import reflex")).
Changes to lower PRs
context.py(PR-1):Context.fixture: FixtureDoc | None = None, last field.scheduler.py(PR-1):Session._setupcopiesctx.fixtureintoentry["dims"]oncesetupsucceeded;finalize()appendsphases: <k> of <n> samples exceed the total by more than 5 %to thewallmetric (per arm, timed samples only; the 5 % iscollectors.phases.MISMATCH_TOLERANCE). It readsextra["phases"].get("mismatch"), so a malformedextracannot crashfinalize(), which runs outside any try.drivers/app_process.py(PR-3):run_cli(..., prefix=("-m", "reflex")).README.md: a "Fixtures" section (thedimsrecord, the playground, the generator,ensure_fixture,bump_marker) and theprefixnote.test_cli.py::test_list_hides_self_tests_by_defaultassumed the registry holds only self-tests (listprinted "no benchmarks selected"). It now checks thatlistshowslifecycle.*and no self-test, and that an empty selection still prints the hint.
Interfaces for later PRs
- Fixtures:
app, doc = ensure_fixture(ctx.cache_dir, describe, make), withdescribe_playground/materialize_playground(dest)orlambda: generate.describe(params)/lambda dest: generate.generate(dest, params). Setctx.fixtureinsetup(it always runs;setup_cachedoes not when a scheduler already primed the directory). - Generator:
GenParams(pages, components_per_page=20, state_vars=20, substate_depth=2, computed_vars=5, seed=42),generate(dest, params) -> FixtureDoc,describe(params).genapp/bench-manifest.json(generate.MANIFEST):{"targets": [{"name", "path", "route", "depth"}, ...]},rootfirst, then the leaves in draw order. Every page renders#bench-hydratedonce hydrated. - Hot reload edits (PR-6):
new = bump_marker(app / target["path"], target["name"]), then wait for#bench-marker-<name>ontarget["route"]to shownew. - Result index (PR-10):
dims = {"fixture": <name>, "fixture_hash": "sha256:…"}on every entry that drives an app; empty otherwise. The document-levelfixturestaysnull. - Driver:
run_cli(..., prefix=("-c", "…"))runs other interpreter arguments through the same process tree code. - Host bun:
_hide_bun(PATH, views)lives inlifecycle.py; the hot reload suite needs it as soon as it starts apps with a freshREFLEX_DIR, and should move it next tocache_env.
Self-review
An adversarial pass over the diff against CLAUDE.md and the spec, with the four questions it asks first:
- Cache-state leaks between samples. Found two and fixed both: the host bun (a cold
initon 0.8.23 did not download bun; now everyinit.coldprepare after the first deletes an 80–104 MBREFLEX_DIR), and the incremental counter (see deviation 3). The data shows the rest holds: everycompile.coldprepare deletes 140–161 MB of.weband 166–192 MB of bun cache, so no sample installs from a warm cache; every warm, incremental and export sample hasinstall= 0 (nothing reinstalled, no hidden cold step); the registry-latency probe reflex runs on a freshREFLEX_DIRis cached in the primed one (reflex_best_registry.cached), so it only lands ininit.cold, where the spec wants it. - Processes left after a timeout. Commands time out 30 s before their hooks, so
run_clikills and reaps its tree before the scheduler could abandon the hook;AppProcess.start()gets the command timeout andwait_http_ready()20 s within the margin, andconcludestops the app from any thread. Ctrl-C at four points left nothing. Limitation: with a--timeoutlower than a command's own timeout, an abandonedrun_clikeeps its tree until that timeout (then kills it) or until exit (atexit), and the scheduler keeps the work directory. - Fixtures reused across a hash change. The stamp rebuilds on any change of the committed playground hash or of
generate.py, and a half-made app has no stamp. Limitation by design: an edit of the playground that is not yet re-hashed (pre-commitorscripts/hash_examples.py) is not seen, since the hash is never recomputed. - A
pr-suite benchmark that depends on the network. Verified offline (above). The first priming of a new commit's cache needs the network (bun download, package install into bun's cache), insetup_cacheonly.
Other findings, left as they are:
tests/units/reflex_bench/test_scheduler.py::test_interrupt_runs_conclude_on_a_fresh_thread(PR-1) failed once while a compile loaded all 4 cores: the abandoned worker picked up the queuedsamplejob afterconcludeandcleanuphad run, socalls[-2:]ended withsample. The test races with its own worker; it passed 5/5 on an idle machine and in every later run. Not touched here.CliResult.check()names the commandreflex <args>, so a failed import would read "reflex exited with code 1" above the traceback.- Host environment variables reach reflex through
ctx.env(PR-1's policy); on this sandbox that includesBUN_OPTIONS=--smolandNODE_OPTIONS=--max-old-space-size=8192. - Network-bound benchmarks:
init.colddownloads bun (a 37 MB zip for 1.4.0, 39 MB for 1.3.4) and probes two npm registries,compile.coldfills a fresh bun cache with 166–192 MB of packages per sample (CV 17–20 % here). A transient 502 fails the priming of an instance (seen once, above); no retry. - Disk: every benchmark instance keeps its own
REFLEX_DIR(78–104 MB of bun) and primed app per subject commit (node_modulesare hard links into bun's cache); nothing prunes old commits' cache directories yet (subjects prunehandles venvs), which PR-11 will want in CI. - The benchmark
versionhashes the class source only, so a change in the shared base classes or helpers oflifecycle.pykeeps the version (as for any shared helper since PR-1). estimateis per benchmark, so the scale tiers share one (18 s, the mean of 1.1–63 s).- The generated
rxconfig.pyhas noSitemapPlugin, as specified, so both versions print their "enabled by default" warning on every compile. - Two concurrent invocations sharing a cache directory could race in
ensure_fixture(no cross-process lock; the same holds for everysetup_cachesince PR-1).
Review fixes (61b6e058e)
These supersede the matching parts above.
- An edited fixture is reported, not silently dropped.
dimsnow hold only the fixture name ({"fixture": "playground", "collector": …}).fixture_hashis an entry-level field that is part of the series key but not the pairing key. So after a playground or generator edit,comparereportsnot compared: …: fixture content hash differs: sha256:… vs sha256:…instead of listing both ids as unpaired and skipping the gate;--forcecompares them. (Lower-PR changes:schemaoptionalfixture_hash,store.series_key,scheduler.Session._setup.) lifecycle.importmeasures the framework: it runsimport reflex as rx; rx.App; rx.Statein a fresh interpreter.import reflexalone is lazy (~10 modules), so the old 22–27 ms numbers were mostly interpreter start-up. Measured now: ~0.49 s, 58 → 1032 modules.- Collector in
dims: time benchmarks decide the collector once insetupand recorddims["collector"] = "cgroup" | "fallback", so cgroup and fallback numbers never share a series. NewContext.dims, copied into the entry by the scheduler. - One
REFLEX_DIRper subject: warm benchmarks share<home>/cache/<subject>/reflex, so a commit downloads bun once instead of once per instance.init.coldstill uses its own fresh one. - Incremental edits are restored:
concluderestores the edited module. Markers stay unique acrossabarms (bump_marker(path, target, n)with a shared counter). The cached app matches its recorded.content-hashafter runs. - No late start after a timeout:
_Readybuilds theAppProcessinprepareand stops it inconclude, so a timed-out sample cannot start an app after teardown. - Trimmed (~95 lines net):
functools.partialfor the repeated@benchmarkkwargs;_Primed.fixture(ctx); over-defensiveGenParams/generate()checks removed;ensure_fixturereturns the path.
Checks: 566 passed, 10 skipped; ruff, pyright and pre-commit pass. Real runs (cgroup): compile.warm 711 ms, incremental 670 ms, import 491 ms (n=3); compile.cold 48.6 s with .web and the bun cache really deleted.
Phase attribution rework (43f2342cb)
This supersedes the "Phase attribution" section above: the other bucket, parts/total and the 5 % rule. On warm compiles python was 0.04 s and other 0.6 s, because only the [timing] log labels counted as Python, and the 5 % check could never fire.
Now collectors/phases.attribute(total_s, cpu_s, timing, tree) works per process class. TreePhases records the root too, and every process gets one class:
install: bun/npm/pnpm/yarn install|add|i|ci, and what they start;frontend: node, vite, react-router, esbuild, and what they start;python: everything else.
Reported per sample in extra["phases"]:
- wall per class: a tool class is the union of its process lifetimes, clipped to the total.
python = total − |install ∪ frontend|, since the interpreter only waits while those run. cpuper class from sampledcpu_times, andcpu_totalfrom the cgroupcpu.stat(or rusage).mismatch: true when the per-class CPU sum is offcpu_totalby more than 10 % (MISMATCH_TOLERANCE). This is a real cross-check that can fail.idle: the sum over classes of max(wall − cpu, 0), for example network waits during a cold install.python_breakdown: the[timing]labels (minus install), nested under Python.
Small changes to lower-PR files: collectors/phases.py and drivers/app_process.py (#7283: attribution() passes cpu_s), and scheduler.py (#7274: the phase warning text).
Checks: 571 passed, 10 skipped; ruff, pyright and pre-commit pass. Real verification follows after the running benchmark comparison.
Cold samples without the network (7716d127f)
lifecycle.compile.cold and lifecycle.init.cold measured the network and the npm registry, not Reflex. init.cold downloaded bun (~80 MB) in every sample (31–35 s). compile.cold emptied bun's package cache and downloaded every package (51–77 s, depending on registry speed).
compile.cold: each sample still gets a fresh app copy with no.weband nonode_modules, and the subject's primed bun package cache is shared. The fix is the lockfile. A fresh copy without one madebun addfetch every package manifest from the registry even with a full cache (bun's--prefer-offlineandBUN_MANIFEST_CACHEdon't help a lockfile-lessbun add).preparenow copies the priming compile's lockfile into the copy (reflex.lock/on 0.9,.web/bun.lockon 0.8), so the install links everything from the cache.init.cold: each sample still gets a fresh project and a freshREFLEX_DIR, but bun is copied in from the subject's primedREFLEX_DIR(untimed), so nothing is downloaded.
Verified:
straceon the timed install: 0 bytes to any outside socket.- With the registry pointed at
127.0.0.1:9, HEAD passes (with the lockfile), and 0.8.23 passes with or without it.
Real runs, --runs 3:
| HEAD | 0.8.23 | |
|---|---|---|
compile.cold | 941 ms | 985 ms |
init.cold | 4.08 s | ~4 s |
Before: 51–77 s and 31–35 s.
New test: test_compile_cold_prepare_copies_the_primed_lockfiles; 572 passed; pre-commit passes.