From 94b49a2d60d4612219d3509ea6fb47cf5bedc0eb Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Fri, 29 Apr 2022 10:11:02 -0700 Subject: [PATCH] Use `std::thread::available_parallelism` in place of num_cpus (#199) --- Cargo.toml | 1 - rust-toolchain | 2 +- src/lib.rs | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7907254..0ef6208 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,6 @@ raw-api = [] send_guard = ["parking_lot/send_guard"] [dependencies] -num_cpus = "1.13.1" parking_lot = "0.12.0" hashbrown = "0.11.2" serde = { version = "1.0.136", optional = true, features = ["derive"] } diff --git a/rust-toolchain b/rust-toolchain index e4528cb..62d03d5 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,4 +1,4 @@ [toolchain] -channel = "stable-2020-12-31" +channel = "1.59" components = [ "rustfmt", "clippy" ] profile = "minimal" diff --git a/src/lib.rs b/src/lib.rs index 836b70c..53a46d2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -46,7 +46,7 @@ cfg_if! { pub(crate) type HashMap = hashbrown::HashMap, S>; fn default_shard_amount() -> usize { - (num_cpus::get() * 4).next_power_of_two() + (std::thread::available_parallelism().map_or(1, usize::from) * 4).next_power_of_two() } fn ncb(shard_amount: usize) -> usize {