Skip to content

perf: cut dev-mode memory in the frontend and telemetry paths - #7112

Merged
masenf merged 1 commit into
reflex-dev:mainfrom
FarhanAliRaza:farhan/dev-mode-memory
Sep 11, 2026
Merged

perf: cut dev-mode memory in the frontend and telemetry paths#7112
masenf merged 1 commit into
reflex-dev:mainfrom
FarhanAliRaza:farhan/dev-mode-memory

Conversation

@FarhanAliRaza

@FarhanAliRaza FarhanAliRaza commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Two dev-mode memory reductions, measured on a blank app.

  • Frontend toolchain: set MIMALLOC_ARENA_EAGER_COMMIT=0 for the vite dev server and the reflex export build (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_event posts through urllib.request instead of httpx, so backend workers never import httpx on their first error. The packaging imports in telemetry.py are 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-only builds with the new env
  • dev server starts and serves with the env var set

https://claude.ai/code/session_015Gi5wTWZNBA61pVDdPLu8u

Review in cubic

Set MIMALLOC_ARENA_EAGER_COMMIT=0 for the vite dev server and the export
build so rolldown does not keep its dependency pre-bundling arena
resident. Send telemetry through urllib so backend workers never import
httpx on their first error, and import packaging lazily in telemetry.

Measured on a blank app (PSS over the whole `reflex run` tree, page
loaded once): node cold ~780 MB -> ~455 MB, warm ~415 MB -> ~335 MB.

Claude-Session: https://claude.ai/code/session_015Gi5wTWZNBA61pVDdPLu8u
@FarhanAliRaza
FarhanAliRaza requested a review from a team as a code owner September 11, 2026 14:33
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 11, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-11T14:37:13.721950Z 616ff22 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge, with no concrete correctness, security, or repository-rule violations identified.

Summary

  • Applies a user-overridable mimalloc setting to development servers and production frontend builds.
  • Replaces httpx telemetry delivery with the standard-library urllib client.
  • Defers package-metadata imports until telemetry defaults are collected.
  • Adds focused tests for environment precedence, request serialization, transport errors, and avoiding the httpx import.

Reviews (1) · Last reviewed commit: "perf: cut dev-mode memory in the fronten..."

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 6 files

Re-trigger cubic

@codspeed-hq

codspeed-hq Bot commented Sep 11, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 40 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing FarhanAliRaza:farhan/dev-mode-memory (616ff22) with main (8b393b5)

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@masenf
masenf merged commit 8d09bde into reflex-dev:main Sep 11, 2026
114 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants