Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 12 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ tag-prefix = ""
lto = true

[workspace.dependencies]
ahash = "0.8.12"
anyhow = "1.0.98"
archspec = "0.1.3"
assert_matches = "1.5.0"
Expand Down Expand Up @@ -67,7 +68,6 @@ fs-err = { version = "3.1.0" }
fslock = "0.2.1"
futures = "0.3.31"
futures-util = "0.3.31"
fxhash = "0.2.1"
# lots of other crates are still stuck on older version which breaks `deserialize`
# pinning to 0.14.7 because 0.14.8 introduces deprecation notices.
generic-array = "=0.14.7"
Expand Down
2 changes: 1 addition & 1 deletion crates/path_resolver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ readme.workspace = true
description = "Provides a trie-based data structure to track and resolve relative path ownership across multiple packages"

[dependencies]
ahash.workspace = true
fs-err.workspace = true
fxhash.workspace = true
indexmap.workspace = true
itertools.workspace = true
proptest.workspace = true
Expand Down
39 changes: 22 additions & 17 deletions crates/path_resolver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use std::{
};

use fs_err as fs;
use fxhash::{FxHashMap as HashMap, FxHashSet as HashSet};
use indexmap::IndexSet;
use itertools::Itertools;

Expand Down Expand Up @@ -99,11 +98,11 @@ pub struct ClobberedPath {
#[derive(Default, Debug, Clone, PartialEq, Eq)]
struct PathTrieNode {
/// All tags that touch this prefix *or* any descendant.
prefixes: HashSet<PackageName>,
prefixes: ahash::HashSet<PackageName>,
/// Tags that have a file exactly at this node.
terminals: HashSet<PackageName>,
terminals: ahash::HashSet<PackageName>,
/// Child components.
children: HashMap<OsString, PathTrieNode>,
children: ahash::HashMap<OsString, PathTrieNode>,
}

/// A trie of relative file-paths, tagged by package name (in insertion order).
Expand Down Expand Up @@ -364,14 +363,14 @@ impl PathResolver {
pub fn reprioritize_packages(&mut self, new_order: Vec<PackageName>) -> Changes {
fn rank<'a>(
order: impl IntoIterator<Item = &'a PackageName>,
) -> HashMap<&'a PackageName, usize> {
) -> ahash::HashMap<&'a PackageName, usize> {
order.into_iter().enumerate().map(|(i, v)| (v, i)).collect()
}

fn collect_removed_subtree(
n: &PathTrieNode,
cur: &mut PathBuf,
old_rank: &HashMap<&PackageName, usize>,
old_rank: &ahash::HashMap<&PackageName, usize>,
to_clobbers: &mut ToClobbers,
) {
let old_winner = n
Expand All @@ -393,7 +392,7 @@ impl PathResolver {
fn collect_new_winners(
n: &PathTrieNode,
cur: &mut PathBuf,
new_rank: &HashMap<&PackageName, usize>,
new_rank: &ahash::HashMap<&PackageName, usize>,
from_clobbers: &mut FromClobbers,
) {
let new_winner = n
Expand All @@ -416,8 +415,8 @@ impl PathResolver {
fn dfs(
n: &PathTrieNode,
cur: &mut PathBuf,
old_rank: &HashMap<&PackageName, usize>,
new_rank: &HashMap<&PackageName, usize>,
old_rank: &ahash::HashMap<&PackageName, usize>,
new_rank: &ahash::HashMap<&PackageName, usize>,
to_clobbers: &mut ToClobbers,
from_clobbers: &mut FromClobbers,
) {
Expand Down Expand Up @@ -471,8 +470,8 @@ impl PathResolver {
if self.packages.len() != new_order.len() {
break 'reorder false;
}
let self_pkg_set: HashSet<&PackageName> = self.packages.iter().collect();
let new_pkg_set: HashSet<&PackageName> = new_order.iter().collect();
let self_pkg_set: ahash::HashSet<&PackageName> = self.packages.iter().collect();
let new_pkg_set: ahash::HashSet<&PackageName> = new_order.iter().collect();
self_pkg_set == new_pkg_set
};

Expand Down Expand Up @@ -562,7 +561,10 @@ New:
}

/// Which packages own this prefix?
pub fn packages_for_prefix<P: AsRef<Path>>(&self, path: P) -> Option<&HashSet<PackageName>> {
pub fn packages_for_prefix<P: AsRef<Path>>(
&self,
path: P,
) -> Option<&ahash::HashSet<PackageName>> {
let mut cur = &self.root;

for comp in path.as_ref().components().map(Component::as_os_str) {
Expand All @@ -573,7 +575,10 @@ New:
}

/// Who owns exactly this file?
pub fn packages_for_exact<P: AsRef<Path>>(&self, path: P) -> Option<&HashSet<PackageName>> {
pub fn packages_for_exact<P: AsRef<Path>>(
&self,
path: P,
) -> Option<&ahash::HashSet<PackageName>> {
Self::get_node(&self.root, path.as_ref()).map(|n| &n.terminals)
}

Expand Down Expand Up @@ -607,12 +612,12 @@ New:

/// Collect all paths where multiple packages wrote the same file,
/// returning a map from each path to its final owner and overridden packages.
pub fn collect_clobbered_paths(&self) -> HashMap<PathBuf, ClobberedPath> {
pub fn collect_clobbered_paths(&self) -> ahash::HashMap<PathBuf, ClobberedPath> {
fn dfs(
node: &PathTrieNode,
path: &mut PathBuf,
packages: &IndexSet<PackageName>,
results: &mut HashMap<PathBuf, ClobberedPath>,
results: &mut ahash::HashMap<PathBuf, ClobberedPath>,
) {
if !node.terminals.is_empty() {
// Determine the winning package by insertion priority
Expand Down Expand Up @@ -642,7 +647,7 @@ New:
}
}

let mut results = HashMap::default();
let mut results = ahash::HashMap::default();
dfs(
&self.root,
&mut PathBuf::new(),
Expand Down Expand Up @@ -726,7 +731,7 @@ mod tests {
resolver.unregister_package("pkg");
assert!(resolver
.packages_for_exact("foo.txt")
.is_none_or(HashSet::is_empty));
.is_none_or(ahash::HashSet::is_empty));
assert!(resolver.packages_for_prefix("foo").is_none());
}

Expand Down
2 changes: 1 addition & 1 deletion crates/rattler_cache/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ native-tls = ["reqwest/native-tls", "rattler_networking/native-tls", "rattler_pa
[dependencies]

[target.'cfg(not( target_arch = "wasm32" ))'.dependencies]
ahash = { workspace = true }
anyhow = { workspace = true }
dashmap = { workspace = true }
dirs = { workspace = true }
futures = { workspace = true }
fs-err = { workspace = true }
fs4 = { workspace = true, features = ["fs-err3-tokio", "tokio"] }
fxhash = { workspace = true }
itertools = { workspace = true }
parking_lot = { workspace = true }
rattler_conda_types = { workspace = true, default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion crates/rattler_conda_types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ default = ["rayon"]
experimental_extras = []

[dependencies]
ahash = { workspace = true }
chrono = { workspace = true }
file_url = { workspace = true }
fxhash = { workspace = true }
glob = { workspace = true }
hex = { workspace = true }
itertools = { workspace = true }
Expand Down
Loading
Loading