Skip to content

Commit bb1ef50

Browse files
committed
remove lock on outgoings module
1 parent e199cde commit bb1ef50

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

crates/rspack_core/src/build_chunk_graph/new_code_splitter.rs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,10 @@ impl CodeSplitter {
429429
fn analyze_module_graph(
430430
&mut self,
431431
compilation: &mut Compilation,
432-
prepared_outgoings: &IdentifierMap<IdentifierIndexMap<Vec<ModuleGraphConnection>>>,
432+
prepared_outgoings: &IdentifierMap<(
433+
IdentifierIndexMap<Vec<ModuleGraphConnection>>,
434+
Vec<AsyncDependenciesBlockIdentifier>,
435+
)>,
433436
) -> Result<Vec<CreateChunkRoot>> {
434437
// determine runtime and chunkLoading
435438
let mut entry_runtime: std::collections::HashMap<&str, RuntimeSpec, rustc_hash::FxBuildHasher> =
@@ -765,7 +768,10 @@ impl CodeSplitter {
765768
runtime: &RuntimeSpec,
766769
module_graph: &ModuleGraph,
767770
module_graph_cache: &ModuleGraphCacheArtifact,
768-
prepared_outgoings: &IdentifierMap<IdentifierIndexMap<Vec<ModuleGraphConnection>>>,
771+
prepared_outgoings: &IdentifierMap<(
772+
IdentifierIndexMap<Vec<ModuleGraphConnection>>,
773+
Vec<AsyncDependenciesBlockIdentifier>,
774+
)>,
769775
) -> (Vec<ModuleIdentifier>, Vec<AsyncDependenciesBlockIdentifier>) {
770776
if let Some(ref_value) = self
771777
.module_deps
@@ -776,15 +782,12 @@ impl CodeSplitter {
776782
return (ref_value.0.clone(), ref_value.1.clone());
777783
}
778784

779-
let outgoings = prepared_outgoings
785+
let (outgoings, blocks) = prepared_outgoings
780786
.get(module)
781787
.expect("should have outgoings");
782-
let m = module_graph
783-
.module_by_identifier(module)
784-
.expect("should have module");
785788

786789
let mut modules = IdentifierIndexSet::default();
787-
let mut blocks = m.get_blocks().to_vec();
790+
let mut blocks = blocks.clone();
788791

789792
'outer: for (m, conns) in outgoings.iter() {
790793
for conn in conns {
@@ -802,8 +805,8 @@ impl CodeSplitter {
802805
module_graph_cache,
803806
prepared_outgoings,
804807
);
805-
modules.extend(extra_modules.iter().copied());
806-
blocks.extend(extra_blocks.iter().copied());
808+
modules.extend(extra_modules);
809+
blocks.extend(extra_blocks);
807810
}
808811
crate::ConnectionState::Active(false) => {}
809812
crate::ConnectionState::CircularConnection => {}
@@ -1048,7 +1051,10 @@ impl CodeSplitter {
10481051
fn prepare_outgoings(
10491052
&self,
10501053
compilation: &Compilation,
1051-
) -> IdentifierMap<IdentifierIndexMap<Vec<ModuleGraphConnection>>> {
1054+
) -> IdentifierMap<(
1055+
IdentifierIndexMap<Vec<ModuleGraphConnection>>,
1056+
Vec<AsyncDependenciesBlockIdentifier>,
1057+
)> {
10521058
let module_graph = compilation.get_module_graph();
10531059
let modules = module_graph.modules().keys().copied().collect::<Vec<_>>();
10541060
modules
@@ -1058,7 +1064,7 @@ impl CodeSplitter {
10581064
let m = module_graph
10591065
.module_by_identifier(&mid)
10601066
.expect("should have module");
1061-
1067+
let blocks = m.get_blocks().to_vec();
10621068
m.get_dependencies()
10631069
.iter()
10641070
.filter(|dep_id| {
@@ -1072,7 +1078,7 @@ impl CodeSplitter {
10721078
.map(|conn| (conn.module_identifier(), conn))
10731079
.for_each(|(module, conn)| outgoings.entry(*module).or_default().push(conn.clone()));
10741080

1075-
(mid, outgoings)
1081+
(mid, (outgoings, blocks))
10761082
})
10771083
.collect::<IdentifierMap<_>>()
10781084
}

0 commit comments

Comments
 (0)