-
-
Notifications
You must be signed in to change notification settings - Fork 759
perf: improve flag exports plugin and flag usage plugin #10712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
✅ 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
📝 Benchmark detail: Open
|
181c7af
to
56fa1c5
Compare
📝 Benchmark detail: Open
|
56fa1c5
to
7ebe03c
Compare
@@ -1479,6 +1479,7 @@ impl Compilation { | |||
#[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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
LGTM cc @ahabhgk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
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_exports
This 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_expr
function.Related links
Checklist