diff --git a/Cargo.lock b/Cargo.lock index a9f5c1b..2db5c70 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -300,12 +300,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "hermit-abi" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" - [[package]] name = "ignore" version = "0.4.23" @@ -384,16 +378,6 @@ dependencies = [ "adler2", ] -[[package]] -name = "num_cpus" -version = "1.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91df4bbde75afed763b708b7eee1e8e7651e02d97f6d5dd763e89367e957b23b" -dependencies = [ - "hermit-abi", - "libc", -] - [[package]] name = "once_cell_polyfill" version = "1.70.1" @@ -460,7 +444,6 @@ dependencies = [ "flate2", "ignore", "mimalloc", - "num_cpus", "phf", "strum", "strum_macros", diff --git a/Cargo.toml b/Cargo.toml index cb8be98..f30b7c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,6 @@ crossbeam = { version = "0.8.4" } flate2 = { version = "1.1.2" } ignore = { version = "0.4.23" } mimalloc = { version = "0.1.48" } -num_cpus = { version = "1.17.0" } phf = { version = "0.13.1", features = ["macros"] } strum = { version = "0.27.2" } strum_macros = { version = "0.27.2" } diff --git a/src/main.rs b/src/main.rs index 1e827e2..f6fc4a1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,7 @@ use std::path::PathBuf; use std::process::exit; +use std::thread::available_parallelism; use std::time::{Duration, Instant}; use clap::Parser; @@ -19,10 +20,10 @@ static GLOBAL: MiMalloc = MiMalloc; fn main() { let args = Args::parse(); - let threads = match args.threads { - 0 => num_cpus::get(), - t => t, - }; + let mut threads = args.threads; + if threads == 0 { + threads = available_parallelism().map(|v| v.get()).unwrap_or(1); + } let (algs, quality) = parse_compression(args.compression);