mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-18 19:21:46 +00:00
Consolidate concurrency limits (#3493)
## Summary This PR consolidates the concurrency limits used throughout `uv` and exposes two limits, `UV_CONCURRENT_DOWNLOADS` and `UV_CONCURRENT_BUILDS`, as environment variables. Currently, `uv` has a number of concurrent streams that it buffers using relatively arbitrary limits for backpressure. However, many of these limits are conflated. We run a relatively small number of tasks overall and should start most things as soon as possible. What we really want to limit are three separate operations: - File I/O. This is managed by tokio's blocking pool and we should not really have to worry about it. - Network I/O. - Python build processes. Because the current limits span a broad range of tasks, it's possible that a limit meant for network I/O is occupied by tasks performing builds, reading from the file system, or even waiting on a `OnceMap`. We also don't limit build processes that end up being required to perform a download. While this may not pose a performance problem because our limits are relatively high, it does mean that the limits do not do what we want, making it tricky to expose them to users (https://github.com/astral-sh/uv/issues/1205, https://github.com/astral-sh/uv/issues/3311). After this change, the limits on network I/O and build processes are centralized and managed by semaphores. All other tasks are unbuffered (note that these tasks are still bounded, so backpressure should not be a problem).
This commit is contained in:
parent
eab2b832a6
commit
783df8f657
35 changed files with 575 additions and 218 deletions
|
|
@ -91,6 +91,8 @@ impl Combine for PipOptions {
|
|||
link_mode: self.link_mode.or(other.link_mode),
|
||||
compile_bytecode: self.compile_bytecode.or(other.compile_bytecode),
|
||||
require_hashes: self.require_hashes.or(other.require_hashes),
|
||||
concurrent_downloads: self.concurrent_downloads.or(other.concurrent_downloads),
|
||||
concurrent_builds: self.concurrent_builds.or(other.concurrent_builds),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use std::path::PathBuf;
|
||||
use std::{num::NonZeroUsize, path::PathBuf};
|
||||
|
||||
use serde::Deserialize;
|
||||
|
||||
|
|
@ -85,4 +85,6 @@ pub struct PipOptions {
|
|||
pub link_mode: Option<LinkMode>,
|
||||
pub compile_bytecode: Option<bool>,
|
||||
pub require_hashes: Option<bool>,
|
||||
pub concurrent_downloads: Option<NonZeroUsize>,
|
||||
pub concurrent_builds: Option<NonZeroUsize>,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue