perf: improve flag exports plugin and flag usage plugin#10712
Merged
Conversation
2 tasks
Contributor
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
2 tasks
✅ Deploy Preview for rspack canceled.
|
c6a51c0 to
4057c0d
Compare
CodSpeed Performance ReportMerging #10712 will not alter performanceComparing Summary
|
af96732 to
7c5f196
Compare
e8a6cbc to
181c7af
Compare
Contributor
|
📝 Benchmark detail: Open
|
Contributor
181c7af to
56fa1c5
Compare
Contributor
|
📝 Benchmark detail: Open
|
Contributor
56fa1c5 to
7ebe03c
Compare
LingyuCoder
commented
Jun 27, 2025
| #[instrument("Compilation:seal", skip_all)] | ||
| pub async fn seal(&mut self, plugin_driver: SharedPluginDriver) -> Result<()> { | ||
| self.other_module_graph = Some(ModuleGraphPartial::default()); | ||
| self.get_module_graph_mut().prepare_export_info_map(); |
Contributor
Author
There was a problem hiding this comment.
Cause all exports info will get_mut during flag exports and usage, so we can just clone the whole map to module graph partial to prevent loop partials of each export info. This should be removed after refactoring of export info.
Contributor
|
LGTM cc @ahabhgk |
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
Impove FlagDependencyExportsPlugin
Parallel collecting exports of dependencies by
dep.get_exports.Since there is a backtracking mechanism in the processing of dependency exports, when re - exporting, if there is a relationship A -> B, after A is computed, when computing B, if B's exports change, then A's exports need to be recomputed.
If the computation queue is
[B, A]:If the computation queue is
[A, B]:Therefore, modules need to be sorted according to their dependency relationships to ensure that the backtracking computation will be triggered, and the results of the first parallel computation are discarded. Although this will result in some wasted computations, since the number of re - exported modules is not particularly large, parallel computation will still significantly improve performance.
Improve FlagDependencyUsagePlugin
parallel collecting referenced exports of dependencies by
dep.get_referenced_exportsThis plugin has the same issue with FlagDependencyExportsPlugin. But it has a queue internal and has handle the dependencies by recursive calling
collect_referenced_export_items. So it is safe to just parallel getting their referenced dependencies and no need to sort them.Improve SideEffectsFlagPlugin
Just prevent CallExpr being cloned by sending the parent expr node to
is_pure_call_exprfunction.Related links
Checklist