perf: cut dev-mode memory in the frontend and telemetry paths
Merged
FA
1mo ago+105+105+012345678901234567890123456789-31-31-01234567890123456789
Summary
Two dev-mode memory reductions, measured on a blank app.
- Frontend toolchain: set
MIMALLOC_ARENA_EAGER_COMMIT=0for the vite dev server and thereflex exportbuild (exec.frontend_env()). Rolldown allocates through mimalloc, and with eager commit the arena it touches during dependency pre-bundling stays resident for the life of the dev server. A value already present in the environment wins. - Telemetry:
_send_eventposts throughurllib.requestinstead ofhttpx, so backend workers never import httpx on their first error. Thepackagingimports intelemetry.pyare lazy.
Measurements
PSS over the whole reflex run tree, page loaded once in headless Chrome, 15 s settle, cold = no .web/node_modules/.vite.
| main | this PR | |
|---|---|---|
| node, cold | ~780 MB | ~460 MB |
| node, warm | ~415 MB | ~340 MB |
| total, cold | ~1118 MB | ~788 MB |
| total, warm | ~752 MB | ~668 MB |
| worker, first error | +9 MB, 0.07 s (httpx import) | +1 MB, 0.01 s |
Python-side worker layout is unchanged here; #7079 covers forking.
Test plan
-
uv run pytest tests/units(8482 passed, 76.6% coverage) - ruff, pyright, pre-commit clean
-
reflex export --frontend-onlybuilds with the new env - dev server starts and serves with the env var set