Skip to content

Commit

Permalink
refactor: incremental options name (#8175)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahabhgk authored Oct 21, 2024
1 parent fcd3bf3 commit d9551c5
Show file tree
Hide file tree
Showing 14 changed files with 130 additions and 135 deletions.
8 changes: 4 additions & 4 deletions crates/node_binding/binding.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1412,10 +1412,10 @@ export interface RawIncremental {
emitAssets: boolean
inferAsyncModules: boolean
providedExports: boolean
collectModulesDiagnostics: boolean
moduleHashes: boolean
moduleCodegen: boolean
moduleRuntimeRequirements: boolean
dependenciesDiagnostics: boolean
modulesHashes: boolean
modulesCodegen: boolean
modulesRuntimeRequirements: boolean
}

export interface RawInfo {
Expand Down
16 changes: 8 additions & 8 deletions crates/rspack_binding_options/src/options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,17 @@ impl TryFrom<RawOptions> for CompilerOptions {
if value.provided_exports {
passes.insert(IncrementalPasses::PROVIDED_EXPORTS);
}
if value.collect_modules_diagnostics {
passes.insert(IncrementalPasses::COLLECT_MODULES_DIAGNOSTICS);
if value.dependencies_diagnostics {
passes.insert(IncrementalPasses::DEPENDENCIES_DIAGNOSTICS);
}
if value.module_hashes {
passes.insert(IncrementalPasses::MODULE_HASHES);
if value.modules_hashes {
passes.insert(IncrementalPasses::MODULES_HASHES);
}
if value.module_codegen {
passes.insert(IncrementalPasses::MODULE_CODEGEN);
if value.modules_codegen {
passes.insert(IncrementalPasses::MODULES_CODEGEN);
}
if value.module_runtime_requirements {
passes.insert(IncrementalPasses::MODULE_RUNTIME_REQUIREMENTS);
if value.modules_runtime_requirements {
passes.insert(IncrementalPasses::MODULES_RUNTIME_REQUIREMENTS);
}
passes
}
Expand Down
8 changes: 4 additions & 4 deletions crates/rspack_binding_options/src/options/raw_experiments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ pub struct RawIncremental {
pub emit_assets: bool,
pub infer_async_modules: bool,
pub provided_exports: bool,
pub collect_modules_diagnostics: bool,
pub module_hashes: bool,
pub module_codegen: bool,
pub module_runtime_requirements: bool,
pub dependencies_diagnostics: bool,
pub modules_hashes: bool,
pub modules_codegen: bool,
pub modules_runtime_requirements: bool,
}

#[allow(clippy::empty_structs_with_brackets)]
Expand Down
26 changes: 14 additions & 12 deletions crates/rspack_core/src/compiler/compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ pub struct Compilation {
pub named_chunk_groups: HashMap<String, ChunkGroupUkey>,

pub async_modules: IdentifierSet,
pub modules_diagnostics: IdentifierMap<Vec<Diagnostic>>,
pub dependencies_diagnostics: IdentifierMap<Vec<Diagnostic>>,
pub code_generation_results: CodeGenerationResults,
pub cgm_hash_results: CgmHashResults,
pub cgm_runtime_requirements_results: CgmRuntimeRequirementsResults,
Expand Down Expand Up @@ -267,7 +267,7 @@ impl Compilation {
named_chunk_groups: Default::default(),

async_modules: Default::default(),
modules_diagnostics: Default::default(),
dependencies_diagnostics: Default::default(),
code_generation_results: Default::default(),
cgm_hash_results: Default::default(),
cgm_runtime_requirements_results: Default::default(),
Expand Down Expand Up @@ -1087,7 +1087,7 @@ impl Compilation {
.can_read_mutations(IncrementalPasses::PROVIDED_EXPORTS)
|| self
.incremental
.can_read_mutations(IncrementalPasses::COLLECT_MODULES_DIAGNOSTICS)
.can_read_mutations(IncrementalPasses::DEPENDENCIES_DIAGNOSTICS)
{
self
.unaffected_modules_cache
Expand Down Expand Up @@ -1128,14 +1128,14 @@ impl Compilation {
fn collect_dependencies_diagnostics(&mut self) {
let mutations = self
.incremental
.mutations_read(IncrementalPasses::COLLECT_MODULES_DIAGNOSTICS);
.mutations_read(IncrementalPasses::DEPENDENCIES_DIAGNOSTICS);
let modules = if let Some(mutations) = mutations {
let revoked_modules = mutations.iter().filter_map(|mutation| match mutation {
Mutation::ModuleRevoke { module } => Some(*module),
_ => None,
});
for revoked_module in revoked_modules {
self.modules_diagnostics.remove(&revoked_module);
self.dependencies_diagnostics.remove(&revoked_module);
}
self
.unaffected_modules_cache
Expand All @@ -1148,7 +1148,7 @@ impl Compilation {
module_graph.modules().keys().copied().collect()
};
let module_graph = self.get_module_graph();
let modules_diagnostics: IdentifierMap<Vec<Diagnostic>> = modules
let dependencies_diagnostics: IdentifierMap<Vec<Diagnostic>> = modules
.par_iter()
.map(|module_identifier| {
let mgm = module_graph
Expand All @@ -1165,10 +1165,12 @@ impl Compilation {
})
.collect();
let all_modules_diagnostics = if mutations.is_some() {
self.modules_diagnostics.extend(modules_diagnostics);
self.modules_diagnostics.clone()
self
.dependencies_diagnostics
.extend(dependencies_diagnostics);
self.dependencies_diagnostics.clone()
} else {
modules_diagnostics
dependencies_diagnostics
};
self.extend_diagnostics(all_modules_diagnostics.into_values().flatten());
}
Expand Down Expand Up @@ -1247,13 +1249,13 @@ impl Compilation {

let module_hashes_enabled = self
.incremental
.can_read_mutations(IncrementalPasses::MODULE_HASHES);
.can_read_mutations(IncrementalPasses::MODULES_HASHES);
let module_codegen_enabled = self
.incremental
.can_read_mutations(IncrementalPasses::MODULE_CODEGEN);
.can_read_mutations(IncrementalPasses::MODULES_CODEGEN);
let module_runtime_requirements_enabled = self
.incremental
.can_read_mutations(IncrementalPasses::MODULE_RUNTIME_REQUIREMENTS);
.can_read_mutations(IncrementalPasses::MODULES_RUNTIME_REQUIREMENTS);
let module_hashes_modules;
let module_codegen_modules;
let module_runtime_requirements_modules;
Expand Down
12 changes: 6 additions & 6 deletions crates/rspack_core/src/compiler/hmr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,27 +105,27 @@ impl Compiler {
}
if new_compilation
.incremental
.can_read_mutations(IncrementalPasses::COLLECT_MODULES_DIAGNOSTICS)
.can_read_mutations(IncrementalPasses::DEPENDENCIES_DIAGNOSTICS)
{
new_compilation.modules_diagnostics =
std::mem::take(&mut self.compilation.modules_diagnostics);
new_compilation.dependencies_diagnostics =
std::mem::take(&mut self.compilation.dependencies_diagnostics);
}
if new_compilation
.incremental
.can_read_mutations(IncrementalPasses::MODULE_HASHES)
.can_read_mutations(IncrementalPasses::MODULES_HASHES)
{
new_compilation.cgm_hash_results = std::mem::take(&mut self.compilation.cgm_hash_results);
}
if new_compilation
.incremental
.can_read_mutations(IncrementalPasses::MODULE_CODEGEN)
.can_read_mutations(IncrementalPasses::MODULES_CODEGEN)
{
new_compilation.code_generation_results =
std::mem::take(&mut self.compilation.code_generation_results);
}
if new_compilation
.incremental
.can_read_mutations(IncrementalPasses::MODULE_RUNTIME_REQUIREMENTS)
.can_read_mutations(IncrementalPasses::MODULES_RUNTIME_REQUIREMENTS)
{
new_compilation.cgm_runtime_requirements_results =
std::mem::take(&mut self.compilation.cgm_runtime_requirements_results);
Expand Down
8 changes: 4 additions & 4 deletions crates/rspack_core/src/unaffected_cache/incremental.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ bitflags! {
const MAKE = 1 << 0;
const INFER_ASYNC_MODULES = 1 << 1;
const PROVIDED_EXPORTS = 1 << 2;
const COLLECT_MODULES_DIAGNOSTICS = 1 << 3;
const MODULE_HASHES = 1 << 4;
const MODULE_CODEGEN = 1 << 5;
const MODULE_RUNTIME_REQUIREMENTS = 1 << 6;
const DEPENDENCIES_DIAGNOSTICS = 1 << 3;
const MODULES_HASHES = 1 << 4;
const MODULES_CODEGEN = 1 << 5;
const MODULES_RUNTIME_REQUIREMENTS = 1 << 6;
const EMIT_ASSETS = 1 << 7;
}
}
Expand Down
11 changes: 1 addition & 10 deletions packages/rspack-test-tools/src/case/new-incremental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,7 @@ const watchCreator = new BasicCaseCreator({
compilerType: ECompilerType.Rspack,
configFiles: ["rspack.config.js", "webpack.config.js"],
experiments: {
incremental: {
make: true,
emitAssets: true,
inferAsyncModules: true,
providedExports: true,
collectModulesDiagnostics: true,
moduleHashes: true,
moduleCodegen: true,
moduleRuntimeRequirements: true
}
incremental: true
}
})
: new WatchStepProcessor({
Expand Down
11 changes: 1 addition & 10 deletions packages/rspack-test-tools/src/processor/hot-new-incremental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,7 @@ export class HotNewIncrementalProcessor<
if (this._hotOptions.compilerType === ECompilerType.Rspack) {
const rspackOptions = options as TCompilerOptions<ECompilerType.Rspack>;
rspackOptions.experiments ??= {};
rspackOptions.experiments.incremental ??= {
make: true,
emitAssets: true,
inferAsyncModules: true,
providedExports: true,
collectModulesDiagnostics: true,
moduleHashes: true,
moduleCodegen: true,
moduleRuntimeRequirements: true
};
rspackOptions.experiments.incremental ??= true;
} else {
throw new Error(
"HotNewIncrementalProcessor should only used for Rspack."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ Object {
css: undefined,
futureDefaults: false,
incremental: Object {
collectModulesDiagnostics: false,
dependenciesDiagnostics: false,
emitAssets: true,
inferAsyncModules: false,
make: true,
moduleCodegen: false,
moduleHashes: false,
moduleRuntimeRequirements: false,
modulesCodegen: false,
modulesHashes: false,
modulesRuntimeRequirements: false,
providedExports: false,
},
layers: false,
Expand Down
Loading

2 comments on commit d9551c5

@rspack-bot
Copy link

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 (2024-10-21 e616982) Current Change
10000_development-mode + exec 2.1 s ± 34 ms 2.11 s ± 45 ms +0.22 %
10000_development-mode_hmr + exec 672 ms ± 18 ms 664 ms ± 8.9 ms -1.10 %
10000_production-mode + exec 2.66 s ± 35 ms 2.67 s ± 36 ms +0.44 %
arco-pro_development-mode + exec 1.8 s ± 42 ms 1.81 s ± 49 ms +0.34 %
arco-pro_development-mode_hmr + exec 427 ms ± 2.1 ms 427 ms ± 1.4 ms -0.02 %
arco-pro_production-mode + exec 3.21 s ± 79 ms 3.22 s ± 92 ms +0.28 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 3.24 s ± 76 ms 3.22 s ± 82 ms -0.81 %
threejs_development-mode_10x + exec 1.61 s ± 22 ms 1.62 s ± 19 ms +0.73 %
threejs_development-mode_10x_hmr + exec 756 ms ± 7.2 ms 760 ms ± 8.7 ms +0.58 %
threejs_production-mode_10x + exec 4.97 s ± 28 ms 5 s ± 22 ms +0.54 %

@rspack-bot
Copy link

Choose a reason for hiding this comment

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

📝 Ran ecosystem CI: Open

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

Please sign in to comment.