perf: parallel cold checks that actually scale + flat LSP latency#4100
perf: parallel cold checks that actually scale + flat LSP latency#4100hellovai wants to merge 1 commit into
Conversation
|
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):
|
Binary size checks passed✅ 7 passed
Generated by |
…roject load; parallel LSP sweep Three fixes for the "12 threads = 1.18x" cold-check scaling wall, diagnosed by comparing against ty/ruff's salsa usage (whose driver pattern ours already matches): - Prime wave: compute every file's PPIR semantic index across workers BEFORE fanning out per-file checks. Whole-package aggregate queries (package_items / namespace_items) fold over every file's index, and every file's check demands them - on a cold database the first worker to claim the aggregate memo computed parse+lowering+indexing for the entire project inline on one thread while all other workers parked on that memo's sync slot. With per-file indexes primed the aggregate fold is cheap and workers stay busy. Also replaces the old first-file serial warm-up, which warmed the builtin package (compiler2_all_files orders builtins first), not the user package. - Bulk project load: add_or_update_files registers all sources with ONE project-file-list write; the per-file path cloned and re-set the whole files Vec and bumped the salsa revision once per file (O(files^2) copies during initial load). Source reads now happen across worker threads, preserving discovery order so FileId assignment and diagnostic ordering are unchanged. - The LSP diagnostics candidate now checks files through the shared order-preserving parallel checker (under the held source guard - the same exclusion the serial loop relied on), so every per-edit path inherits the parallelism and the prime wave. check_files_parallel returns per-file results in input order so the LSP can zip them back to documents; the flat collector delegates. Measured (Apple Silicon, 12 cores): - cold pure check, 295k LOC: 7.4s -> 2.8s wall (1.2 -> 2.4+ cores) - cold check+seed, 295k LOC: 10.5s -> 4.4s; 59k LOC: ~0.9s - LSP edit->diagnostics: 250 files 464 -> 172ms; 500 files 1.7s -> 176ms; 1000 files 5.5s -> 209ms (now ~flat in project size) - LSP load test: burst storms + sustained churn at 250/1000 files, zero crashes, stable RSS, convergence after every storm Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V4oee6wrCHzXH6mM2h8eJo
c2da018 to
f214619
Compare
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 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 |
Stacked on #4098. Fixes the "12 threads = 1.18× speedup" wall, diagnosed by comparing our salsa usage against ty/ruff's (our driver pattern was already identical to theirs — the problem was one query shape).
What
package_items/namespace_items) fold over every file's index; on a cold db the first worker to claim that memo computed parse+lower+index for the entire project inline on one thread while all other workers parked on the memo's sync slot. Also retires the old first-file warm-up, which warmed the builtin package, not the user package.add_or_update_fileswrites the project file list once (the per-file path re-cloned the whole Vec and bumped the salsa revision per file — O(files²) during load); source reads are parallel with discovery order preserved (FileId assignment and diagnostic ordering unchanged).End-user impact (measured)
Editor latency is now ~flat in project size.
Verification
baml_project/bex_project/baml_cli.Not in this PR: ty-style snapshot+cancellation for the LSP (blocked on the
panic = "abort"release profile — cancellation requires unwinding; needs a product decision), and the warm-edit floor (throws-gate + unit loads; separate reviewed design).🤖 Generated with Claude Code
https://claude.ai/code/session_01V4oee6wrCHzXH6mM2h8eJo