Skip to content

Commit

Permalink
chore: move modern module library finish_modules to finish_make (#9426)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahabhgk authored Feb 21, 2025
1 parent 5577719 commit b69ccff
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
4 changes: 4 additions & 0 deletions crates/rspack_core/src/compiler/compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,10 @@ impl Compilation {
}

let start = logger.time("finish modules");
// finish_modules means the module graph (modules, connections, dependencies) are
// frozen and start to optimize (provided exports, infer async, etc.) based on the
// module graph, so any kind of change that affect these should be done before the
// finish_modules
plugin_driver
.compilation_hooks
.finish_modules
Expand Down
18 changes: 9 additions & 9 deletions crates/rspack_plugin_library/src/modern_module_library_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use rspack_collections::IdentifierMap;
use rspack_core::rspack_sources::{ConcatSource, RawStringSource, SourceExt};
use rspack_core::{
merge_runtime, to_identifier, ApplyContext, BoxDependency, ChunkUkey,
CodeGenerationExportsFinalNames, Compilation, CompilationFinishModules,
CompilationOptimizeChunkModules, CompilationParams, CompilerCompilation, CompilerOptions,
ConcatenatedModule, ConcatenatedModuleExportsDefinitions, DependenciesBlock, Dependency,
DependencyId, LibraryOptions, ModuleGraph, ModuleIdentifier, Plugin, PluginContext,
CodeGenerationExportsFinalNames, Compilation, CompilationOptimizeChunkModules, CompilationParams,
CompilerCompilation, CompilerFinishMake, CompilerOptions, ConcatenatedModule,
ConcatenatedModuleExportsDefinitions, DependenciesBlock, Dependency, DependencyId,
LibraryOptions, ModuleGraph, ModuleIdentifier, Plugin, PluginContext,
};
use rspack_error::{error_bail, Result};
use rspack_hash::RspackHash;
Expand Down Expand Up @@ -212,8 +212,8 @@ fn render_startup(
Ok(())
}

#[plugin_hook(CompilationFinishModules for ModernModuleLibraryPlugin, stage = Compilation::PROCESS_ASSETS_STAGE_ADDITIONS)]
async fn finish_modules(&self, compilation: &mut Compilation) -> Result<()> {
#[plugin_hook(CompilerFinishMake for ModernModuleLibraryPlugin)]
async fn finish_make(&self, compilation: &mut Compilation) -> Result<()> {
let mut mg = compilation.get_module_graph_mut();
let modules = mg.modules();
let module_ids = modules.keys().cloned().collect::<Vec<_>>();
Expand Down Expand Up @@ -457,9 +457,9 @@ impl Plugin for ModernModuleLibraryPlugin {
.tap(optimize_chunk_modules::new(self));
ctx
.context
.compilation_hooks
.finish_modules
.tap(finish_modules::new(self));
.compiler_hooks
.finish_make
.tap(finish_make::new(self));

Ok(())
}
Expand Down

2 comments on commit b69ccff

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented on b69ccff Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Benchmark detail: Open

Name Base (2025-02-21 18420bb) Current Change
10000_big_production-mode_disable-minimize + exec 36.6 s ± 380 ms 37.4 s ± 1.06 s +2.18 %
10000_development-mode + exec 1.71 s ± 14 ms 1.69 s ± 20 ms -0.91 %
10000_development-mode_hmr + exec 671 ms ± 13 ms 669 ms ± 31 ms -0.29 %
10000_production-mode + exec 2.19 s ± 56 ms 2.16 s ± 49 ms -1.30 %
10000_production-mode_persistent-cold + exec 2.35 s ± 128 ms 2.29 s ± 22 ms -2.49 %
10000_production-mode_persistent-hot + exec 1.62 s ± 28 ms 1.62 s ± 47 ms +0.40 %
arco-pro_development-mode + exec 1.72 s ± 92 ms 1.75 s ± 168 ms +1.62 %
arco-pro_development-mode_hmr + exec 374 ms ± 1.2 ms 376 ms ± 1.8 ms +0.30 %
arco-pro_production-mode + exec 3.58 s ± 82 ms 3.5 s ± 187 ms -2.26 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 3.57 s ± 41 ms 3.55 s ± 150 ms -0.64 %
arco-pro_production-mode_persistent-cold + exec 3.67 s ± 287 ms 3.58 s ± 244 ms -2.19 %
arco-pro_production-mode_persistent-hot + exec 2.24 s ± 106 ms 2.27 s ± 39 ms +1.34 %
arco-pro_production-mode_traverse-chunk-modules + exec 3.54 s ± 225 ms 3.48 s ± 154 ms -1.69 %
large-dyn-imports_development-mode + exec 1.97 s ± 37 ms 1.95 s ± 37 ms -1.04 %
large-dyn-imports_production-mode + exec 2.02 s ± 37 ms 2.04 s ± 47 ms +1.08 %
threejs_development-mode_10x + exec 1.48 s ± 140 ms 1.44 s ± 65 ms -2.97 %
threejs_development-mode_10x_hmr + exec 817 ms ± 22 ms 782 ms ± 14 ms -4.32 %
threejs_production-mode_10x + exec 5.14 s ± 161 ms 5.01 s ± 145 ms -2.39 %
threejs_production-mode_10x_persistent-cold + exec 5.15 s ± 352 ms 5.13 s ± 332 ms -0.53 %
threejs_production-mode_10x_persistent-hot + exec 4.49 s ± 273 ms 4.41 s ± 84 ms -1.70 %
10000_big_production-mode_disable-minimize + rss memory 8682 MiB ± 73.1 MiB 8684 MiB ± 38.4 MiB +0.03 %
10000_development-mode + rss memory 651 MiB ± 9.54 MiB 671 MiB ± 17.1 MiB +3.00 %
10000_development-mode_hmr + rss memory 1191 MiB ± 187 MiB 1300 MiB ± 127 MiB +9.20 %
10000_production-mode + rss memory 620 MiB ± 27.7 MiB 658 MiB ± 56.6 MiB +6.13 %
10000_production-mode_persistent-cold + rss memory 729 MiB ± 21.8 MiB 748 MiB ± 17.5 MiB +2.62 %
10000_production-mode_persistent-hot + rss memory 703 MiB ± 22.6 MiB 738 MiB ± 29.2 MiB +5.02 %
arco-pro_development-mode + rss memory 574 MiB ± 19.3 MiB 601 MiB ± 25.7 MiB +4.67 %
arco-pro_development-mode_hmr + rss memory 660 MiB ± 46.9 MiB 695 MiB ± 50.3 MiB +5.27 %
arco-pro_production-mode + rss memory 711 MiB ± 22.3 MiB 732 MiB ± 13.8 MiB +3.00 %
arco-pro_production-mode_generate-package-json-webpack-plugin + rss memory 729 MiB ± 38.7 MiB 751 MiB ± 25.5 MiB +3.11 %
arco-pro_production-mode_persistent-cold + rss memory 789 MiB ± 47.8 MiB 798 MiB ± 36.2 MiB +1.14 %
arco-pro_production-mode_persistent-hot + rss memory 636 MiB ± 24.6 MiB 704 MiB ± 16.3 MiB +10.72 %
arco-pro_production-mode_traverse-chunk-modules + rss memory 725 MiB ± 22.4 MiB 747 MiB ± 19.6 MiB +3.08 %
large-dyn-imports_development-mode + rss memory 644 MiB ± 5.16 MiB 672 MiB ± 11.1 MiB +4.50 %
large-dyn-imports_production-mode + rss memory 521 MiB ± 5.02 MiB 554 MiB ± 10.9 MiB +6.40 %
threejs_development-mode_10x + rss memory 572 MiB ± 30 MiB 584 MiB ± 5.25 MiB +1.99 %
threejs_development-mode_10x_hmr + rss memory 1128 MiB ± 228 MiB 1165 MiB ± 155 MiB +3.27 %
threejs_production-mode_10x + rss memory 851 MiB ± 78.3 MiB 865 MiB ± 17.5 MiB +1.63 %
threejs_production-mode_10x_persistent-cold + rss memory 957 MiB ± 45.2 MiB 952 MiB ± 61.9 MiB -0.47 %
threejs_production-mode_10x_persistent-hot + rss memory 811 MiB ± 63.4 MiB 829 MiB ± 64.5 MiB +2.18 %

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented on b69ccff Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Ecosystem CI detail: Open

suite result
modernjs ❌ failure
rspress ✅ success
rslib ✅ success
rsbuild ❌ failure
rsdoctor ❌ failure
examples ✅ success
devserver ✅ success
nuxt ✅ success

Please sign in to comment.