diff --git a/Cargo.lock b/Cargo.lock index b78927f45f..60e7dacc2c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -715,7 +715,6 @@ dependencies = [ "criterion 0.5.1", "crossterm 0.28.1", "futures", - "num_cpus", "parquet", "pepita", "pollster", diff --git a/crates/aprender-distribute/Cargo.toml b/crates/aprender-distribute/Cargo.toml index d7fee9105b..4d41b871d6 100644 --- a/crates/aprender-distribute/Cargo.toml +++ b/crates/aprender-distribute/Cargo.toml @@ -14,7 +14,7 @@ documentation = "https://docs.rs/repartir" [features] default = ["cpu"] -cpu = ["tokio", "num_cpus"] +cpu = ["tokio"] gpu = ["wgpu", "pollster"] remote = ["tokio", "bincode", "tracing-subscriber"] remote-tls = ["remote", "rustls", "tokio-rustls", "rustls-pemfile"] @@ -34,7 +34,6 @@ name = "repartir" tokio = { version = "1.35", features = ["rt-multi-thread", "sync", "time", "process", "io-util", "macros", "net"], optional = true } # CPU backend -num_cpus = { version = "1.16", optional = true } # GPU backend (pure Rust via gfx-rs) # wgpu provides cross-platform GPU compute (Vulkan/Metal/DX12/WebGPU) diff --git a/crates/aprender-distribute/src/executor/cpu.rs b/crates/aprender-distribute/src/executor/cpu.rs index 4ba21a3864..548880a6fc 100644 --- a/crates/aprender-distribute/src/executor/cpu.rs +++ b/crates/aprender-distribute/src/executor/cpu.rs @@ -36,9 +36,16 @@ impl CpuExecutor { /// Creates a new CPU executor. /// /// Detects the number of available CPU cores automatically. + /// + /// Uses `std::thread::available_parallelism`, stable since Rust 1.59 and far + /// below this workspace's 1.91 MSRV, rather than the `num_cpus` crate. That + /// dependency was optional and pulled by ONE feature (`cpu`) while this file + /// compiles under any feature enabling `tokio`, so six sibling selections + /// could not link it. Falling back to 1 when the count is undeterminable + /// matches what `num_cpus::get()` returned in the same situation. #[must_use] pub fn new() -> Self { - let num_cpus = num_cpus::get(); + let num_cpus = std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get); info!("CpuExecutor initialized with {num_cpus} cores"); Self { num_cpus } }