Skip to content

Commit 744de43

Browse files
authored
chore: remove logic of parallelCodeSplitting (#12424)
chore: remove logic of parallel code splitting
1 parent 152ab9e commit 744de43

File tree

17 files changed

+8
-2263
lines changed

17 files changed

+8
-2263
lines changed

crates/node_binding/napi-binding.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2124,7 +2124,6 @@ export interface RawExperimentCacheOptionsPersistent {
21242124
export interface RawExperiments {
21252125
topLevelAwait: boolean
21262126
incremental?: false | { [key: string]: boolean }
2127-
parallelCodeSplitting: boolean
21282127
rspackFuture?: RawRspackFuture
21292128
cache: boolean | { type: "persistent" } & RawExperimentCacheOptionsPersistent | { type: "memory" }
21302129
useInputFileSystem?: false | Array<RegExp>

crates/rspack/src/builder/mod.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3693,8 +3693,6 @@ pub struct ExperimentsBuilder {
36933693
future_defaults: Option<bool>,
36943694
/// Whether to enable css.
36953695
css: Option<bool>,
3696-
/// Whether to enable parallel code splitting.
3697-
parallel_code_splitting: Option<bool>,
36983696
/// Whether to enable async web assembly.
36993697
async_web_assembly: Option<bool>,
37003698
// TODO: lazy compilation
@@ -3707,7 +3705,6 @@ impl From<Experiments> for ExperimentsBuilder {
37073705
top_level_await: Some(value.top_level_await),
37083706
rspack_future: Some(value.rspack_future),
37093707
cache: Some(value.cache),
3710-
parallel_code_splitting: Some(value.parallel_code_splitting),
37113708
output_module: None,
37123709
future_defaults: None,
37133710
css: Some(value.css),
@@ -3726,7 +3723,6 @@ impl From<&mut ExperimentsBuilder> for ExperimentsBuilder {
37263723
output_module: value.output_module.take(),
37273724
future_defaults: value.future_defaults.take(),
37283725
css: value.css.take(),
3729-
parallel_code_splitting: value.parallel_code_splitting.take(),
37303726
async_web_assembly: value.async_web_assembly.take(),
37313727
}
37323728
}
@@ -3769,12 +3765,6 @@ impl ExperimentsBuilder {
37693765
self
37703766
}
37713767

3772-
/// Set whether to enable parallel code splitting.
3773-
pub fn parallel_code_splitting(&mut self, parallel_code_splitting: bool) -> &mut Self {
3774-
self.parallel_code_splitting = Some(parallel_code_splitting);
3775-
self
3776-
}
3777-
37783768
/// Build [`Experiments`] from options.
37793769
///
37803770
/// [`Experiments`]: rspack_core::options::Experiments
@@ -3811,13 +3801,10 @@ impl ExperimentsBuilder {
38113801
w!(self.async_web_assembly, *future_defaults);
38123802
w!(self.output_module, false);
38133803

3814-
let parallel_code_splitting = d!(self.parallel_code_splitting, false);
3815-
38163804
Ok(Experiments {
38173805
incremental,
38183806
top_level_await,
38193807
rspack_future,
3820-
parallel_code_splitting,
38213808
cache,
38223809
css: d!(self.css, false),
38233810
lazy_barrel: true,

crates/rspack/tests/snapshots/defaults__default_options.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1512,7 +1512,6 @@ CompilerOptions {
15121512
MAKE | EMIT_ASSETS,
15131513
),
15141514
},
1515-
parallel_code_splitting: false,
15161515
top_level_await: true,
15171516
rspack_future: RspackFuture,
15181517
cache: Disabled,

crates/rspack_binding_api/src/raw_options/raw_experiments/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ pub struct RawExperiments {
1717
pub top_level_await: bool,
1818
#[napi(ts_type = "false | { [key: string]: boolean }")]
1919
pub incremental: Option<WithFalse<RawIncremental>>,
20-
pub parallel_code_splitting: bool,
2120
pub rspack_future: Option<RawRspackFuture>,
2221
#[napi(
2322
ts_type = r#"boolean | { type: "persistent" } & RawExperimentCacheOptionsPersistent | { type: "memory" }"#
@@ -40,7 +39,6 @@ impl From<RawExperiments> for Experiments {
4039
},
4140
None => IncrementalOptions::empty_passes(),
4241
},
43-
parallel_code_splitting: value.parallel_code_splitting,
4442
top_level_await: value.top_level_await,
4543
rspack_future: value.rspack_future.unwrap_or_default().into(),
4644
cache: normalize_raw_experiment_cache_options(value.cache),

crates/rspack_core/src/compilation/build_chunk_graph/artifact.rs

Lines changed: 4 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use futures::Future;
22
use indexmap::IndexMap;
3-
use rspack_collections::{IdentifierIndexMap, IdentifierIndexSet, IdentifierMap};
3+
use rspack_collections::{IdentifierIndexMap, IdentifierMap};
44
use rspack_error::Result;
55
use rspack_util::tracing_preset::TRACING_BENCH_TARGET;
66
use rustc_hash::FxHashMap as HashMap;
@@ -9,10 +9,7 @@ use tracing::instrument;
99
use crate::{
1010
ChunkByUkey, ChunkGraph, ChunkGroupByUkey, ChunkGroupUkey, ChunkUkey, Compilation, Logger,
1111
ModuleIdentifier,
12-
build_chunk_graph::{
13-
code_splitter::{CodeSplitter, DependenciesBlockIdentifier},
14-
new_code_splitter::CodeSplitter as NewCodeSplitter,
15-
},
12+
build_chunk_graph::code_splitter::{CodeSplitter, DependenciesBlockIdentifier},
1613
incremental::{IncrementalPasses, Mutation},
1714
};
1815

@@ -26,7 +23,6 @@ pub struct CodeSplittingCache {
2623
named_chunk_groups: HashMap<String, ChunkGroupUkey>,
2724
named_chunks: HashMap<String, ChunkUkey>,
2825
pub(crate) code_splitter: CodeSplitter,
29-
pub(crate) new_code_splitter: NewCodeSplitter,
3026
pub(crate) module_idx: IdentifierMap<(u32, u32)>,
3127
}
3228

@@ -36,11 +32,7 @@ impl CodeSplittingCache {
3632
// we don't need to check if module has changed its incomings
3733
// if it changes, the incoming module changes its outgoings as well
3834
fn can_skip_rebuilding(&self, this_compilation: &Compilation) -> bool {
39-
if this_compilation.options.experiments.parallel_code_splitting {
40-
self.can_skip_rebuilding_new(this_compilation)
41-
} else {
42-
self.can_skip_rebuilding_legacy(this_compilation)
43-
}
35+
self.can_skip_rebuilding_legacy(this_compilation)
4436
}
4537

4638
fn can_skip_rebuilding_legacy(&self, this_compilation: &Compilation) -> bool {
@@ -169,123 +161,6 @@ impl CodeSplittingCache {
169161

170162
true
171163
}
172-
173-
fn can_skip_rebuilding_new(&self, this_compilation: &Compilation) -> bool {
174-
let logger = this_compilation.get_logger("rspack.Compilation.codeSplittingCache");
175-
176-
if !this_compilation.entries.keys().eq(
177-
this_compilation
178-
.build_chunk_graph_artifact
179-
.code_splitting_cache
180-
.entrypoints
181-
.keys(),
182-
) {
183-
logger.log("entrypoints change detected, rebuilding chunk graph");
184-
return false;
185-
}
186-
187-
if this_compilation
188-
.options
189-
.optimization
190-
.used_exports
191-
.is_enable()
192-
{
193-
logger.log("used_exports enabled, rebuilding chunk graph for safety");
194-
return false;
195-
}
196-
197-
if self.new_code_splitter.module_deps.is_empty() {
198-
logger.log("no cache detected, rebuilding chunk graph");
199-
return false;
200-
}
201-
202-
let Some(mutations) = this_compilation
203-
.incremental
204-
.mutations_read(IncrementalPasses::MAKE)
205-
else {
206-
logger.log("incremental for make disabled, rebuilding chunk graph");
207-
// if disable incremental for make phase, we can't skip rebuilding
208-
return false;
209-
};
210-
211-
// if we have module removal, we can't skip rebuilding
212-
if mutations
213-
.iter()
214-
.any(|mutation| matches!(mutation, Mutation::ModuleRemove { .. }))
215-
{
216-
logger.log("module removal detected, rebuilding chunk graph");
217-
return false;
218-
}
219-
220-
let module_graph = this_compilation.get_module_graph();
221-
let module_graph_cache = &this_compilation.module_graph_cache_artifact;
222-
let affected_modules = mutations.get_affected_modules_with_module_graph(&module_graph);
223-
224-
for module in affected_modules.clone() {
225-
let mut current_outgoings_map = IdentifierIndexMap::<Vec<_>>::default();
226-
let curr_module = module_graph
227-
.module_graph_module_by_identifier(&module)
228-
.expect("module should exist");
229-
230-
curr_module
231-
.all_dependencies
232-
.iter()
233-
.filter(|dep_id| {
234-
module_graph
235-
.dependency_by_id(dep_id)
236-
.expect("should have dep")
237-
.as_module_dependency()
238-
.is_none_or(|module_dep| !module_dep.weak())
239-
})
240-
.filter_map(|dep| module_graph.connection_by_dependency_id(dep))
241-
.map(|conn| (conn.module_identifier(), conn))
242-
.for_each(|(module, conn)| current_outgoings_map.entry(*module).or_default().push(conn));
243-
let mut current_outgoings = IdentifierIndexSet::default();
244-
245-
'outer: for (m, conns) in current_outgoings_map.iter() {
246-
for conn in conns {
247-
let conn_state = conn.active_state(&module_graph, None, module_graph_cache);
248-
if conn_state.is_not_false() {
249-
current_outgoings.insert(*m);
250-
continue 'outer;
251-
}
252-
}
253-
}
254-
255-
let mut previous_outgoings = IdentifierIndexSet::default();
256-
let mut newly_added_module = true;
257-
for module_map in self.new_code_splitter.module_deps.values() {
258-
if let Some(outgoings) = module_map.get(&module) {
259-
newly_added_module = false;
260-
let (outgoings, _blocks) = outgoings.as_ref();
261-
for out in outgoings {
262-
previous_outgoings.insert(*out);
263-
}
264-
}
265-
}
266-
267-
if newly_added_module {
268-
logger.log(format!("new module: {module}"));
269-
return false;
270-
}
271-
272-
if previous_outgoings.len() != current_outgoings.len() {
273-
logger.log(format!(
274-
"module outgoings change detected (outgoings length change): {module}"
275-
));
276-
return false;
277-
}
278-
279-
for (prev, curr) in previous_outgoings.into_iter().zip(current_outgoings) {
280-
if prev != curr {
281-
logger.log(format!("module outgoings change detected {module}"));
282-
return false;
283-
}
284-
}
285-
}
286-
287-
true
288-
}
289164
}
290165

291166
#[instrument(name = "Compilation:code_splitting",target=TRACING_BENCH_TARGET, skip_all)]
@@ -305,13 +180,12 @@ where
305180
let incremental_code_splitting = compilation
306181
.incremental
307182
.passes_enabled(IncrementalPasses::BUILD_CHUNK_GRAPH);
308-
let new_code_splitting = compilation.options.experiments.parallel_code_splitting;
309183
let no_change = compilation
310184
.build_chunk_graph_artifact
311185
.code_splitting_cache
312186
.can_skip_rebuilding(compilation);
313187

314-
if (incremental_code_splitting && !new_code_splitting) || no_change {
188+
if incremental_code_splitting || no_change {
315189
let cache = &mut compilation.build_chunk_graph_artifact.code_splitting_cache;
316190
rayon::scope(|s| {
317191
s.spawn(|_| compilation.chunk_by_ukey = cache.chunk_by_ukey.clone());

0 commit comments

Comments
 (0)