perf(cli): mimalloc global allocator + build ariadne SourceCache once per diagnostic batch - #4049
perf(cli): mimalloc global allocator + build ariadne SourceCache once per diagnostic batch#4049hellovai wants to merge 1 commit into
Conversation
… per diagnostic batch Two independent wins for cold / wall time, re-derived from the compiler2 cold-compile audit (#4016): - baml_cli now sets mimalloc as its global allocator. The compiler workload is dominated by small short-lived allocations (Ty trees, Vecs, SmolStrs); system malloc measured ~35% of remaining single-threaded CPU in the original audit. - render_diagnostics builds the ariadne SourceCache (a line index over every project file) once per batch instead of once per diagnostic, threading it as &mut through render_ariadne / render_report_to_string. Rendered bytes are unchanged, so cached diagnostics from the #3924 disk cache replay identically (BAML_CACHE_VERIFY verified). Co-authored-by: Cursor <cursoragent@cursor.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
⏭️ Performance benchmarks were skippedPerf benchmarks (CodSpeed) are opt-in on pull requests — they no longer run on every push. They always run automatically after merge to To run them on this PR, do any of the following, then push a commit (or re-run CI):
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe CLI now uses mimalloc as its global allocator. Ariadne diagnostic rendering creates a source cache once and reuses it across single or batch rendering paths. ChangesPerformance updates
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Binary size checks passed✅ 7 passed
Generated by |
|
Folded into the combined re-landing PR #4054 (per maintainer preference for a single PR post-tool-merge). Branch kept for provenance; individual before/after measurements remain in this PR's description. |
Re-lands the
baml_clislice of the cold-compile performance audit (#4016, commit c1466f3), re-derived against current canary. Two independent changes:baml_cli's global allocator. The compiler workload is dominated by small short-lived allocations (Tytrees,Vecs,SmolStrs); system malloc measured ~35% of remaining single-threaded CPU in the original audit.SourceCacheonce per diagnostic batch inrender_diagnosticsinstead of once per diagnostic (eachSource::fromcomputes a line index over every project file), threading it as&mutthroughrender_ariadne/render_report_to_string. Rendered output bytes are unchanged.Measurements
CLI wall time on the warning-heavy corpus (
baml check crates/baml_tests/baml_src, ~100 warnings), disk cache disabled viaBAML_NO_BYTECODE_CACHE=1+ freshBAML_CACHE_DIR, release builds of clean canary (2660b8b) vs. this branch, alternated in one hyperfine invocation:The benchmark machine was under heavy background load, hence the wide σ; user CPU time (3.12 s → 1.18 s, ~2.6x) is load-independent and consistent across all runs.
Cache-verify gate (#3924 compatibility)
Cached diagnostics are replayed byte-for-byte on cache hits, so rendered output must not change. Verified with
BAML_CACHE_VERIFY=1and a freshBAML_CACHE_DIR(cache enabled), two runs each on before/after binaries so the second run replays cached diagnostics:Tests
cargo test --workspace: passes. (One caveat: three targets initially failed for environmental reasons on the shared bench machine —pack_e2ehit ENOSPC while the disk was full, the Python SDK cancellation tests need Python ≥ 3.11 (ExceptionGroup,asyncio.timeout) anduvhad picked 3.10, and the TS fixtures were missingnode_modulesafter the disk filled up. All three pass after freeing disk /UV_PYTHON=3.12/ re-runningsetup.sh, with no relation to this change.)baml_cli(385 tests),baml_compiler_diagnostics(18),baml_project— all pass.-D warnings) pass.Notes
mimalloc = { version = "0.1.52" }line to[workspace.dependencies].perf/compiler2-cold-compile).Summary by CodeRabbit
baml checkandbaml build.