Skip to content

Commit 4d4e793

Browse files
committed
Use available_parallelism replace the num_cpuscrate
Signed-off-by: hi-rustin <[email protected]>
1 parent 849adb7 commit 4d4e793

File tree

3 files changed

+2
-3
lines changed

3 files changed

+2
-3
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ git-testament = "0.2"
6262
home = "0.5.4"
6363
lazy_static.workspace = true
6464
libc = "0.2"
65-
num_cpus = "1.15"
6665
once_cell = { workspace = true, optional = true }
6766
opener = "0.6.0"
6867
opentelemetry = { workspace = true, optional = true }

src/diskio/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ use std::io::{self, Write};
6060
use std::ops::{Deref, DerefMut};
6161
use std::path::{Path, PathBuf};
6262
use std::sync::mpsc::Receiver;
63+
use std::thread::available_parallelism;
6364
use std::time::{Duration, Instant};
6465
use std::{fmt::Debug, fs::OpenOptions};
6566

@@ -452,7 +453,7 @@ pub(crate) fn get_executor<'a>(
452453
) -> Result<Box<dyn Executor + 'a>> {
453454
// If this gets lots of use, consider exposing via the config file.
454455
let thread_count = match process().var("RUSTUP_IO_THREADS") {
455-
Err(_) => num_cpus::get(),
456+
Err(_) => available_parallelism().map(|p| p.get()).unwrap_or(1),
456457
Ok(n) => n
457458
.parse::<usize>()
458459
.context("invalid value in RUSTUP_IO_THREADS. Must be a natural number")?,

0 commit comments

Comments
 (0)