Holistic Framework Benchmarks: reflex-bench harness, suites and playground
Linear project: P-ENG-487 "Holistic Framework Benchmarks".
Tickets: ENG-12603, ENG-12604, ENG-12605, ENG-12608, ENG-12609, ENG-12610, ENG-12611, ENG-12612, ENG-12614, ENG-12735.
This PR combines the stacked PRs #7274, #7281, #7283, #7280, #7287, #7292, #7310, #7285, #7289 and #7284 into one branch, plus the SharedState benchmark work, all review fixes, and a new wire.navigate benchmark. The individual PR descriptions hold the detailed design notes and measurements; this description summarizes them.
What this adds
packages/reflex-bench: a macro benchmark harness. It is never published and needs no news fragment.
- It drives real Reflex apps through the
reflexCLI, HTTP, the websocket and a real browser, and never imports the reflex under test. - One CLI for local runs and CI:
list,run,show,compare,ab,doctor,export,subjects,budgets check. - Subjects:
--reflex workspace|<version>|git:<ref>|path:<dir>, each in a cached venv. Backfill to 0.8.23 works. ab: interleaved ABBA A/B runs on one machine;--aafor noise floors.- Statistics: median with an exact CI, Mann-Whitney U, bootstrap CI of the change, Holm correction. Verdicts need both significance and the whole CI past the threshold; too few samples gives "inconclusive", never "no change".
- Results: schema
reflex-bench/1, with every raw sample, the machine profile and a series key. Local storage in.reflex-bench/. - App driver: runs
reflex run/compile/exportas subprocesses, with readiness levels per mode and version, and safe teardown of the whole process tree. - Collectors: a cgroup scope for tree-wide
memory.peakand CPU, withOOMPolicy=continueso OOM evidence stays readable; PSS sampling; phase attribution per process class (python / install / frontend).
Suites (168 benchmark IDs):
| Suite | Measures |
|---|---|
lifecycle | init, compile (cold/warm/incremental), export, run → ready (dev/preview/prod/backend-only), import, scale tiers from a synthetic app generator. Cold samples download nothing (primed bun and lockfile). |
browser / hmr | interactive-ready in a real browser, prod page load (LCP/TBT, 4× CPU throttle), hot reload latency (leaf, root, handler, css, asset, reconnect, preview), full-reload detection |
events | an open-loop websocket generator (0.8.23 and HEAD protocol): capacity, per-run p50/p90/p99, the knee, CPU per event; simple, complex, cross, background, SharedState fan-out and contention |
memory | compile and export peaks, idle (prod and dev, with backend and frontend split), memory per session, a leak gate, a 512 MiB boot test naming the failing phase |
wire | exact websocket bytes: hydration, per event, frontend-triggered navigation, and one-item changes to large collections |
size | bundle bytes (gzip and brotli), chunks, node_modules; budgets.json plus a standard-runner CI gate |
examples/playground: the fixture app. It runs standalone on HEAD and on 0.8.23, has a content-hash gate, a lint rule for rx.-only imports, a CI compile on 0.8.23, benchmark hooks, and a SharedState /board page.
Findings the benchmarks surfaced
-
The dev stylesheet hot update has been broken since v0.9.12. The preload link breaks Vite's
css-update. Fixed separately in #7317; until thenhmr.cssfails fast withDroppedUpdateError. -
Expired states are not freed promptly, because of reference cycles, and the disk manager's lock map grows without bound. Fixed separately in #7318. Most of the remaining post-expiry memory is allocator retention: granian's jemalloc and pymalloc arenas.
-
A one-item change to a collection resends the whole collection: 4.0 kB for a 1000-int list, 13.9 kB for a 1000-key dict, against 136 B for a scalar.
-
0.8.23 →
main(subset run):Metric Change compile time −34 % compile peak memory −35 % export (Vite) peak memory −41 % import −47 % prod start −52 % 512 MiB boot peak −53 % 0.9.12 →
mainis about the same.
Review fixes included
All Greptile threads on the stacked PRs were triaged: valid findings are fixed test-first, the rest are declined with reasons (the replies are drafted separately). Masen's two comments are addressed:
- the playground uses the real Reflex favicon, and the hot-reload asset target is a neutral
mark.svg; wire.navigate[route=counter|item]measures a frontend-triggered navigation, with reply bytes cross-checked against a real browser.
Three timing-sensitive tests were made deterministic. For one of them, the fix corrects the CPU attribution of short-lived children.
Checks
| Check | Result |
|---|---|
uv run pytest tests/units/reflex_bench tests/units/test_examples.py tests/units/test_hash_examples.py | 948 passed, 22 skipped |
uv run ruff check ., ruff format --check . | clean |
uv run pyright packages/reflex-bench/src tests/units/reflex_bench | 0 errors |
scripts/hash_examples.py --check, uv lock --check | pass |
Follow-ups (not in this PR)
- CI wiring for the macro runner (ENG-12613). Budget: 500 min/month; use the budget-safe workflow pattern recorded on ENG-12603.
- History store, backfill to 0.8.23 (ENG-12615), the published scorecard (ENG-12617), and the regression gate (ENG-12618).
- Unify the playground copy/env helpers across suites.
- Send per-version request frames from the events driver (
wirerequest bytes are 71 B above HEAD's frontend).