Add UV_CONCURRENT_INSTALLS variable in favor of RAYON_NUM_THREADS (#3646)

## Summary

Continuation of https://github.com/astral-sh/uv/pull/3493. This gives us
more flexibility in case we decide to move away from `rayon` in the
future.
This commit is contained in:
Ibraheem Ahmed 2024-05-17 23:12:37 -04:00 committed by GitHub
parent fe2bc079bc
commit 53633392c3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 50 additions and 7 deletions

View file

@ -11,13 +11,18 @@ pub struct Concurrency {
///
/// Note this value must be non-zero.
pub builds: usize,
/// The maximum number of concurrent installs.
///
/// Note this value must be non-zero.
pub installs: usize,
}
impl Default for Concurrency {
fn default() -> Self {
Concurrency {
downloads: Concurrency::DEFAULT_DOWNLOADS,
builds: Concurrency::default_builds(),
builds: Concurrency::threads(),
installs: Concurrency::threads(),
}
}
}
@ -26,8 +31,8 @@ impl Concurrency {
// The default concurrent downloads limit.
pub const DEFAULT_DOWNLOADS: usize = 50;
// The default concurrent builds limit.
pub fn default_builds() -> usize {
// The default concurrent builds and install limit.
pub fn threads() -> usize {
std::thread::available_parallelism()
.map(NonZeroUsize::get)
.unwrap_or(1)