perf: introduce ModuleGraphCache and cache the result of get_mode and determine_export_assignments#10584
Merged
LingyuCoder merged 18 commits intoweb-infra-dev:mainfrom Jun 12, 2025
Conversation
✅ Deploy Preview for rspack ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
This comment was marked as outdated.
This comment was marked as outdated.
5ac555b to
f075ac8
Compare
CodSpeed Performance ReportMerging #10584 will not alter performanceComparing Summary
|
ab3aab4 to
b879b9d
Compare
Contributor
|
📝 Benchmark detail: Open
|
91c0fc2 to
eadc307
Compare
Contributor
jerrykingxyz
approved these changes
Jun 12, 2025
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
Related: web-infra-dev/rslib#1011
In my M3Pro:
Most changed files are due to the trait method signature changes and passing
module_graph_cache, you may only need to focus on the following files:crates/rspack_core/src/compiler/compilation.rscrates/rspack_core/src/artifacts/module_graph_cache_artifact.rscrates/rspack_plugin_javascript/src/dependency/esm/esm_export_imported_specifier_dependency.rsfreeze()Compare with Webpack
getModewithdependencyCacheProvide(https://github.com/webpack/webpack/blob/19ca74127f7668aaf60d59f4af8fcaee7924541a/lib/ModuleGraph.js#L829). But it seems that rspack doesn't port themoduleMemCache. I'm not sure this is a further optimization or a fallback for correctness.DetermineExportAssginmentsare different, see the comments https://github.com/web-infra-dev/rspack/pull/10584/files#diff-24cb30e171ddb52a6fa8ee0070a832ad5164167b770ffd8c3b8def27cd3becd2R112To validate the cache effectiveness, I collect the cache stats:
Not sure why webpack execute
GetModefor 2000 times more than rspackFurther
There are still improvements to do, but I'd like to finish them in separated prs
ExportsMode. From my observationExportsModecan split to variants to reduce the struct size, thus making it cheaper to clone from the cache.Checklist