mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 21:35:00 +00:00
Remove unnecessary uses of DashMap
and Arc
(#3413)
## Summary All of the resolver code is run on the main thread, so a lot of the `Send` bounds and uses of `DashMap` and `Arc` are unnecessary. We could also switch to using single-threaded versions of `Mutex` and `Notify` in some places, but there isn't really a crate that provides those I would be comfortable with using. The `Arc` in `OnceMap` can't easily be removed because of the uv-auth code which uses the [reqwest-middleware](https://docs.rs/reqwest-middleware/latest/reqwest_middleware/trait.Middleware.html) crate, that seems to adds unnecessary `Send` bounds because of `async-trait`. We could duplicate the code and create a `OnceMapLocal` variant, but I don't feel that's worth it.
This commit is contained in:
parent
2c84af15b8
commit
94cf604574
18 changed files with 165 additions and 145 deletions
|
@ -1,5 +1,6 @@
|
|||
use std::io;
|
||||
use std::path::Path;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
|
||||
use futures::{FutureExt, TryStreamExt};
|
||||
|
@ -41,20 +42,20 @@ use crate::{ArchiveMetadata, Error, LocalWheel, Reporter, SourceDistributionBuil
|
|||
///
|
||||
/// This struct also has the task of acquiring locks around source dist builds in general and git
|
||||
/// operation especially.
|
||||
pub struct DistributionDatabase<'a, Context: BuildContext + Send + Sync> {
|
||||
pub struct DistributionDatabase<'a, Context: BuildContext> {
|
||||
client: &'a RegistryClient,
|
||||
build_context: &'a Context,
|
||||
builder: SourceDistributionBuilder<'a, Context>,
|
||||
locks: Arc<Locks>,
|
||||
locks: Rc<Locks>,
|
||||
}
|
||||
|
||||
impl<'a, Context: BuildContext + Send + Sync> DistributionDatabase<'a, Context> {
|
||||
impl<'a, Context: BuildContext> DistributionDatabase<'a, Context> {
|
||||
pub fn new(client: &'a RegistryClient, build_context: &'a Context) -> Self {
|
||||
Self {
|
||||
client,
|
||||
build_context,
|
||||
builder: SourceDistributionBuilder::new(client, build_context),
|
||||
locks: Arc::new(Locks::default()),
|
||||
locks: Rc::new(Locks::default()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -307,7 +308,7 @@ impl<'a, Context: BuildContext + Send + Sync> DistributionDatabase<'a, Context>
|
|||
let built_wheel = self
|
||||
.builder
|
||||
.download_and_build(&BuildableSource::Dist(dist), tags, hashes)
|
||||
.boxed()
|
||||
.boxed_local()
|
||||
.await?;
|
||||
|
||||
// If the wheel was unzipped previously, respect it. Source distributions are
|
||||
|
@ -360,7 +361,7 @@ impl<'a, Context: BuildContext + Send + Sync> DistributionDatabase<'a, Context>
|
|||
return Ok(ArchiveMetadata { metadata, hashes });
|
||||
}
|
||||
|
||||
match self.client.wheel_metadata(dist).boxed().await {
|
||||
match self.client.wheel_metadata(dist).boxed_local().await {
|
||||
Ok(metadata) => Ok(ArchiveMetadata::from(metadata)),
|
||||
Err(err) if err.is_http_streaming_unsupported() => {
|
||||
warn!("Streaming unsupported when fetching metadata for {dist}; downloading wheel directly ({err})");
|
||||
|
@ -404,7 +405,7 @@ impl<'a, Context: BuildContext + Send + Sync> DistributionDatabase<'a, Context>
|
|||
let metadata = self
|
||||
.builder
|
||||
.download_and_build_metadata(source, hashes)
|
||||
.boxed()
|
||||
.boxed_local()
|
||||
.await?;
|
||||
Ok(metadata)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue