Skip to content

Commit

Permalink
fix: perf regression for get affected modules with chunk graph
Browse files Browse the repository at this point in the history
  • Loading branch information
ahabhgk committed Dec 2, 2024
1 parent 9335a8b commit bd04ca8
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions crates/rspack_core/src/incremental/mutations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use std::{
use once_cell::sync::OnceCell;
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
use rspack_collections::{IdentifierDashMap, IdentifierMap, IdentifierSet, UkeySet};
use rspack_util::fx_hash::FxIndexSet;
use rustc_hash::FxHasher;

use crate::{
Expand Down Expand Up @@ -300,22 +299,24 @@ fn compute_affected_modules_with_chunk_graph(
) -> u64 {
let module_identifier = module.identifier();
let mut hasher = FxHasher::default();
chunk_graph
compilation
.chunk_graph
.get_module_id(module_identifier)
.hash(&mut hasher);
ModuleGraph::is_async(compilation, &module_identifier).hash(&mut hasher);
let module_ids: FxIndexSet<_> = module_graph
for module_id in module_graph
.get_ordered_connections(&module_identifier)
.expect("should have module")
.into_iter()
.filter_map(|dep_id| {
let connection = module_graph
.connection_by_dependency_id(dep_id)
.expect("should have connection");
chunk_graph.get_module_id(*connection.module_identifier())
compilation
.chunk_graph
.get_module_id(*connection.module_identifier())
})
.collect();
for module_id in module_ids {
{
module_id.hash(&mut hasher);
}
for block_id in module.get_blocks() {
Expand All @@ -341,7 +342,7 @@ fn compute_affected_modules_with_chunk_graph(

let module_graph = compilation.get_module_graph();
let affected_modules: IdentifierMap<u64> = cache
.iter()
.par_iter()
.filter_map(|item| {
let (module_identifier, &old_invalidate_key) = item.pair();
let module = module_graph
Expand Down

0 comments on commit bd04ca8

Please sign in to comment.