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
42 changes: 24 additions & 18 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 @@ -137,7 +137,6 @@ console = { version = "0.16.0", default-features = false, features = ["std"] }
csv = { version = "1.3.0" }
ctrlc = { version = "3.4.5" }
cyclonedx-bom = { version = "0.8.1" }
dashmap = { version = "6.1.0" }
data-encoding = { version = "2.6.0" }
diskus = { version = "0.9.0", default-features = false }
dotenvy = { version = "0.15.7" }
Expand Down Expand Up @@ -183,6 +182,7 @@ miette = { version = "7.2.0", features = ["fancy-no-backtrace"] }
nix = { version = "0.31.2", features = ["resource", "signal"] }
open = { version = "5.3.2" }
owo-colors = { version = "4.1.0" }
papaya = { version = "0.2.4" }
path-slash = { version = "0.2.1" }
pathdiff = { version = "0.2.1" }
percent-encoding = { version = "2.3.1" }
Expand Down
4 changes: 2 additions & 2 deletions crates/uv-distribution/src/source/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3025,15 +3025,15 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
};

if let Some(builder) = self.build_context.build_arena().remove(&build_key) {
debug!("Creating build environment for: {source}");
debug!("Reusing existing build environment for: {source}");
let wheel = builder.wheel(temp_dir.path()).await.map_err(Error::Build)?;

// Store the build context.
self.build_context.build_arena().insert(build_key, builder);

wheel
} else {
debug!("Reusing existing build environment for: {source}");
debug!("Creating build environment for: {source}");

let builder = self
.build_context
Expand Down
2 changes: 1 addition & 1 deletion crates/uv-git/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ uv-warnings = { workspace = true }

anyhow = { workspace = true }
cargo-util = { workspace = true }
dashmap = { workspace = true }
papaya = { workspace = true }
fs-err = { workspace = true, features = ["tokio"] }
owo-colors = { workspace = true }
reqwest = { workspace = true }
Expand Down
31 changes: 19 additions & 12 deletions crates/uv-git/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ use std::path::PathBuf;
use std::str::FromStr;
use std::sync::Arc;

use dashmap::DashMap;
use dashmap::mapref::one::Ref;
use fs_err::tokio as fs;
use papaya::{HashMap, ResizeMode};
use reqwest_middleware::ClientWithMiddleware;
use tracing::debug;

Expand Down Expand Up @@ -60,18 +59,26 @@ impl GitHttpSettings {
}

/// A resolver for Git repositories.
#[derive(Default, Clone)]
pub struct GitResolver(Arc<DashMap<RepositoryReference, GitOid>>);
#[derive(Clone)]
pub struct GitResolver(Arc<HashMap<RepositoryReference, GitOid>>);

impl Default for GitResolver {
fn default() -> Self {
Self(Arc::new(
HashMap::builder().resize_mode(ResizeMode::Blocking).build(),
))
}
}

impl GitResolver {
/// Inserts a new [`GitOid`] for the given [`RepositoryReference`].
pub fn insert(&self, reference: RepositoryReference, sha: GitOid) {
self.0.insert(reference, sha);
self.0.pin().insert(reference, sha);
}

/// Returns the [`GitOid`] for the given [`RepositoryReference`], if it exists.
fn get(&self, reference: &RepositoryReference) -> Option<Ref<'_, RepositoryReference, GitOid>> {
self.0.get(reference)
fn get(&self, reference: &RepositoryReference) -> Option<GitOid> {
self.0.pin().get(reference).copied()
}

/// Return the [`GitOid`] for the given [`GitUrl`], if it is already known.
Expand All @@ -84,7 +91,7 @@ impl GitResolver {
// If we know the precise commit already, return it.
let reference = RepositoryReference::from(url);
if let Some(precise) = self.get(&reference) {
return Some(*precise);
return Some(precise);
}

None
Expand Down Expand Up @@ -181,7 +188,7 @@ impl GitResolver {
// single process are consistent.
let url = {
if let Some(precise) = self.get(&reference) {
Cow::Owned(url.clone().with_precise(*precise))
Cow::Owned(url.clone().with_precise(precise))
} else {
Cow::Borrowed(url)
}
Expand Down Expand Up @@ -241,7 +248,7 @@ impl GitResolver {
pub fn precise(&self, url: GitUrl) -> Option<GitUrl> {
let reference = RepositoryReference::from(&url);
let precise = self.get(&reference)?;
Some(url.with_precise(*precise))
Some(url.with_precise(precise))
}

/// Returns `true` if the two Git URLs refer to the same precise commit.
Expand All @@ -263,11 +270,11 @@ impl GitResolver {
}

// Otherwise, the URLs must resolve to the same precise commit.
let Some(a_precise) = a.precise().or_else(|| self.get(&a_ref).map(|sha| *sha)) else {
let Some(a_precise) = a.precise().or_else(|| self.get(&a_ref)) else {
return false;
};

let Some(b_precise) = b.precise().or_else(|| self.get(&b_ref).map(|sha| *sha)) else {
let Some(b_precise) = b.precise().or_else(|| self.get(&b_ref)) else {
return false;
};

Expand Down
2 changes: 1 addition & 1 deletion crates/uv-once-map/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ test = false
workspace = true

[dependencies]
dashmap = { workspace = true }
futures = { workspace = true }
papaya = { workspace = true }
tokio = { workspace = true }
Loading
Loading