Repository navigation
perf: share the TypeScript worker between compilers checking the same project - #390
alexander-akait wants to merge 4 commits into
Conversation
… starts A check that reportAs keeps off the compilation runs after a watch rebuild. When the next rebuild starts, its report is dropped, yet the TypeScript worker kept checking the whole program before it would start the run that matters. The plugin now tells a check to stop a run of an older compilation as soon as it takes over from it, through an optional cancel() on the check instance. The TypeScript check passes a CancellationToken backed by a SharedArrayBuffer to its worker, so the run stops between one file and the next and the builder keeps what it got through. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01App18sYbe6Vf6HDCjCXbvf
… project Each compiler of a MultiCompiler kept a worker and a program of its own for its TypeScript check. Runs that overlapped were already shared, but compilers building one after another built and held the program twice. Workers are now kept by what their program is built from, the same key concurrent runs are shared by, and ended once no compiler uses them. A shared worker numbers its runs, so a compiler stopping its own stale run no longer stops another compiler's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01App18sYbe6Vf6HDCjCXbvf
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 3 minutes. View limit details
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 |
One or more co-authors of this pull request were not found. You must specify co-authors in commit message trailer via: Supported
Alternatively, if the co-author should not be included, remove the Please update your commit message(s) by doing |
Two compilers linting the same files at once share one run. Stopping it for the compiler whose compilation is stale would have handed the other one an empty answer. A run another compiler joined is now left to finish, and a run that is stopped is taken out of the shared runs, so a compiler coming later starts its own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01App18sYbe6Vf6HDCjCXbvf
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01App18sYbe6Vf6HDCjCXbvf
|
EasyCLA fails because the commits carry a This PR now also carries #389's review fix (84b755e: never stop a run another compiler joined), merged in from that branch. Generated by Claude Code |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #390 +/- ##
========================================
Coverage 99.64% 99.65%
========================================
Files 19 19
Lines 5618 5750 +132
========================================
+ Hits 5598 5730 +132
Misses 20 20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Each compiler of a
MultiCompilerkept its own worker and its own program for its TypeScript check. Runs that overlap in time were already shared (sharedRunsincheck.js). Compilers that build one after another, though (parallelism: 1, ordependenciesbetween configs), each built and held the whole program.sharingKey("typescript", options), the same key concurrent runs are shared by. It is now exported fromcheck.js.shutdownorwatchClose, or incleanup()for a one-shot build.createSolonow writes a run's number into one of 64 slots of the sharedInt32Array.cancel(answer)stops exactly the run that promise belongs to.threads: false) still keeps a program per compiler, so it is garbage-collected with the compiler.Measurements
Setup: 600
.tsfiles, a two-compilerMultiCompilerwith the same TypeScript check, a watch with the first build plus one rebuild after an edit.parallelism: 1parallelism: 1One compiler alone takes 5.5 s, 10 CPU-s and about 450 MB, so two sequential compilers now cost about what one does.
One-shot sequential builds are unchanged by this PR. A one-shot compiler ends its worker when its build is done, or the thread would keep the process alive. #383's persisted builder state is what makes the second compiler cheap there.
Tests
test/typescript/share.test.js:parallelism: 1in watch mode must record["fresh", "reused"].fresh,fresh).test/typescript/cancel.test.jsfrom perf: stop a TypeScript run nothing will report once the next rebuild starts #389 still passes with per-run cancellation.tsc, schema lint, prettier, cspell and the full suite (332 tests) pass locally.Generated by Claude Code