perf(worker): lazy-load coverage provider to reduce worker startup overhead#1110
Merged
perf(worker): lazy-load coverage provider to reduce worker startup overhead#1110
Conversation
…erhead Defer import from static to dynamic , only loading when is true. This prevents every worker process from parsing ~100KB of picomatch/glob code (4411.js + 7704.js) at startup when coverage is disabled (the common case). Verified with module tracing: HEAD loads 4411.js in all 52+ worker PIDs, while this change loads it only once in the main process. Benchmark shows ~4.4% User CPU reduction across worker processes. Amp-Thread-ID: https://ampcode.com/threads/T-019d2927-404e-7449-b0c7-5798bdd49e6f Co-authored-by: Amp <amp@ampcode.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Rsdoctor Bundle Diff Analysis
Found 12 projects in monorepo, 1 project with changes. 📊 Quick Summary
📋 Detailed Reports (Click to expand)📁 core/mainPath:
📦 Download Diff Report: core/main Bundle Diff Generated by Rsdoctor GitHub Action |
9aoy
approved these changes
Mar 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Background
Every worker process statically imports the coverage module chain (
7704.js→4411.js), loading ~108KB of picomatch/glob code at startup — even when coverage is disabled (the common case).Implementation
createCoverageProviderfrom a top-level staticimportto a dynamicimport()guarded bycoverage.enabled.7704.js(1.6KB) and its transitive dependency4411.js(106KB) from every worker's static import chain. These chunks are now only loaded once in the main process when coverage is actually enabled.Worker static JS asset reduction:
Benchmark
Fixture: 50 test files × 20 tests (1000 tests), 14-core machine,
isolateWorkers: true,NODE_COMPILE_CACHEdisabled.Wall clock: ~2% (limited by 14-core parallelism). User CPU: -214ms (-6.1%), reflecting ~4ms less parse/compile per worker × 52 worker processes.
User Impact
Marginal wall-clock improvement for typical runs; more visible on lower-core machines or larger test suites.
Checklist