perf: skip dependency error/warning reporting for unchanged modules on rebuilds#21154
Conversation
🦋 Changeset detectedLatest commit: 723466f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
This PR is packaged and the instant preview is available (7bf5a72). Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@7bf5a72
yarn add -D webpack@https://pkg.pr.new/webpack@7bf5a72
pnpm add -D webpack@https://pkg.pr.new/webpack@7bf5a72 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #21154 +/- ##
=======================================
Coverage 92.35% 92.35%
=======================================
Files 581 581
Lines 63332 63372 +40
Branches 17507 17522 +15
=======================================
+ Hits 58488 58528 +40
Misses 4844 4844
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merging this PR will improve performance by 96.92%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Memory | benchmark "react", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
151.3 KB | 330.1 KB | -54.16% |
| ⚡ | Memory | benchmark "lodash", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
859.4 KB | 127.6 KB | ×6.7 |
| ⚡ | Memory | benchmark "asset-modules-bytes", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
859.2 KB | 248.1 KB | ×3.5 |
| ⚡ | Memory | benchmark "css-modules", scenario '{"name":"mode-development","mode":"development"}' |
1,708.8 KB | 845.2 KB | ×2 |
| ⚡ | Memory | benchmark "future-defaults", scenario '{"name":"mode-production","mode":"production"}' |
9.3 MB | 6.8 MB | +36.99% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing perf/dependency-report-cache-tokens (723466f) with main (0afe292)
|
The reported
So the measurable delta is ~5–25 KB (the expected token/WeakSet bookkeeping), not +728 KB. The report itself flags that the comparison crossed different runtime environments, and the unexplained ×2 "improvement" on the untouched css-modules initial build points the same way. Rebasing onto current main to re-run the benchmark on a clean comparison. Generated by Claude Code |
…n rebuilds Resolves the cacheToken TODO in Compilation.finish: each compilation renews a token for built modules and their (transitive) parents, and modules known to have no dependency errors/warnings under their current token are skipped. Active only without experiments.cacheUnaffected, which has its own more precise invalidation. https://claude.ai/code/session_015WjGhYn6DRDRoUWmWG32NL
840dfce to
723466f
Compare
Summary
Resolves the long-standing
cacheTokenTODO inCompilation.finish: the "report dependency errors and warnings" pass walked every module's dependency tree on every rebuild, even for unchanged modules, unlessexperiments.cacheUnaffectedwas enabled. Each compilation now renews a cache token for built modules and their (transitive) parents (using the samecouldAffectReferencingModule()rules as_computeAffectedModules), and modules known to be clean under their current token are skipped — on a 4100-module benchmark this cuts the phase from ~8.6 ms to ~1.1 ms per rebuild with default development cache, whileexperiments.cacheUnaffectedkeeps its existing, more precise invalidation untouched.What kind of change does this PR introduce?
perf
Did you add tests for your changes?
Yes —
test/watchCases/warnings/dependency-warnings-unchanged-modulescovers warning persistence for unchanged modules across rebuilds and a new export warning appearing on an unchanged importer when its dependency changes.Does this PR introduce a breaking change?
No.
If relevant, what needs to be documented once your changes are merged or what have you already documented?
n/a
Use of AI
This change was implemented with Claude (Claude Code) under my direction: it wrote the implementation, the watch test case, and ran before/after CPU/memory benchmarks; I reviewed the approach and results.
https://claude.ai/code/session_015WjGhYn6DRDRoUWmWG32NL
Generated by Claude Code