Skip to content

Commit 59a0c65

Browse files
authored
perf: IndexSet for ArcPath (#11727)
1 parent e5d43b8 commit 59a0c65

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/rspack_core/src/cache/persistent/snapshot/strategy.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ use std::{
55
time::{SystemTime, UNIX_EPOCH},
66
};
77

8-
use dashmap::DashMap;
98
use rspack_cacheable::cacheable;
109
use rspack_fs::ReadableFileSystem;
11-
use rspack_paths::{ArcPath, AssertUtf8};
10+
use rspack_paths::{ArcPath, ArcPathDashMap, AssertUtf8};
1211
use rustc_hash::FxHasher;
1312

1413
/// Snapshot check strategy
@@ -46,7 +45,7 @@ pub enum ValidateResult {
4645

4746
pub struct StrategyHelper {
4847
fs: Arc<dyn ReadableFileSystem>,
49-
package_version_cache: DashMap<ArcPath, Option<String>>,
48+
package_version_cache: ArcPathDashMap<Option<String>>,
5049
compile_time: u64,
5150
}
5251

crates/rspack_core/src/compiler/compilation.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::{
1010

1111
use dashmap::DashSet;
1212
use futures::future::BoxFuture;
13-
use indexmap::{IndexMap, IndexSet};
13+
use indexmap::IndexMap;
1414
use itertools::Itertools;
1515
use rayon::prelude::*;
1616
use rspack_cacheable::{
@@ -24,7 +24,7 @@ use rspack_error::{Diagnostic, Result, ToStringResultToRspackResultExt};
2424
use rspack_fs::{IntermediateFileSystem, ReadableFileSystem, WritableFileSystem};
2525
use rspack_hash::{RspackHash, RspackHashDigest};
2626
use rspack_hook::define_hook;
27-
use rspack_paths::{ArcPath, ArcPathSet};
27+
use rspack_paths::{ArcPath, ArcPathIndexSet, ArcPathSet};
2828
use rspack_sources::{BoxSource, CachedSource, SourceExt};
2929
use rspack_tasks::CompilerContext;
3030
use rspack_util::{itoa, tracing_preset::TRACING_BENCH_TARGET};
@@ -268,10 +268,10 @@ pub struct Compilation {
268268

269269
pub hash: Option<RspackHashDigest>,
270270

271-
pub file_dependencies: IndexSet<ArcPath, BuildHasherDefault<FxHasher>>,
272-
pub context_dependencies: IndexSet<ArcPath, BuildHasherDefault<FxHasher>>,
273-
pub missing_dependencies: IndexSet<ArcPath, BuildHasherDefault<FxHasher>>,
274-
pub build_dependencies: IndexSet<ArcPath, BuildHasherDefault<FxHasher>>,
271+
pub file_dependencies: ArcPathIndexSet,
272+
pub context_dependencies: ArcPathIndexSet,
273+
pub missing_dependencies: ArcPathIndexSet,
274+
pub build_dependencies: ArcPathIndexSet,
275275

276276
pub value_cache_versions: ValueCacheVersions,
277277

crates/rspack_paths/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ version.workspace = true
1111
[dependencies]
1212
camino = { workspace = true }
1313
dashmap = { workspace = true }
14+
indexmap = { workspace = true }
1415
rspack_cacheable = { workspace = true }
1516
rustc-hash = { workspace = true }
1617
ustr = { workspace = true }

crates/rspack_paths/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use std::{
88

99
pub use camino::{Utf8Component, Utf8Components, Utf8Path, Utf8PathBuf, Utf8Prefix};
1010
use dashmap::{DashMap, DashSet};
11+
use indexmap::IndexSet;
1112
use rspack_cacheable::{
1213
cacheable,
1314
with::{AsRefStr, AsRefStrConverter},
@@ -143,3 +144,7 @@ pub type ArcPathDashMap<V> = DashMap<ArcPath, V, BuildHasherDefault<IdentityHash
143144
/// A standard `DashSet` using `ArcPath` as the key type with a custom `Hasher`
144145
/// that just uses the precomputed hash for speed instead of calculating it.
145146
pub type ArcPathDashSet = DashSet<ArcPath, BuildHasherDefault<IdentityHasher>>;
147+
148+
/// A standard `IndexSet` using `ArcPath` as the key type with a custom `Hasher`
149+
/// that just uses the precomputed hash for speed instead of calculating it.
150+
pub type ArcPathIndexSet = IndexSet<ArcPath, BuildHasherDefault<IdentityHasher>>;

0 commit comments

Comments
 (0)