Skip to content

Commit 0cfdbc0

Browse files
committed
[beta] Revert rust-lang#10427: switch from num_cpus
This reverts commit 6d11f9e, reversing changes made to c5cdd25.
1 parent 4751950 commit 0cfdbc0

File tree

3 files changed

+4
-13
lines changed

3 files changed

+4
-13
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ libc = "0.2"
4444
log = "0.4.6"
4545
libgit2-sys = "0.13.2"
4646
memchr = "2.1.3"
47+
num_cpus = "1.0"
4748
opener = "0.5"
4849
os_info = "3.0.7"
4950
pathdiff = "0.2"

src/cargo/core/compiler/build_config.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
use crate::core::compiler::CompileKind;
22
use crate::util::interning::InternedString;
33
use crate::util::{CargoResult, Config, RustfixDiagnosticServer};
4-
use anyhow::{bail, Context as _};
4+
use anyhow::bail;
55
use cargo_util::ProcessBuilder;
66
use serde::ser;
77
use std::cell::RefCell;
88
use std::path::PathBuf;
9-
use std::thread::available_parallelism;
109

1110
/// Configuration information for a rustc build.
1211
#[derive(Debug)]
@@ -74,12 +73,7 @@ impl BuildConfig {
7473
its environment, ignoring the `-j` parameter",
7574
)?;
7675
}
77-
let jobs = match jobs.or(cfg.jobs) {
78-
Some(j) => j,
79-
None => available_parallelism()
80-
.context("failed to determine the amount of parallelism available")?
81-
.get() as u32,
82-
};
76+
let jobs = jobs.or(cfg.jobs).unwrap_or(::num_cpus::get() as u32);
8377
if jobs == 0 {
8478
anyhow::bail!("jobs may not be 0");
8579
}

src/cargo/core/compiler/timings.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use anyhow::Context as _;
1313
use cargo_util::paths;
1414
use std::collections::HashMap;
1515
use std::io::{BufWriter, Write};
16-
use std::thread::available_parallelism;
1716
use std::time::{Duration, Instant, SystemTime};
1817

1918
pub struct Timings<'cfg> {
@@ -381,9 +380,6 @@ impl<'cfg> Timings<'cfg> {
381380
};
382381
let total_time = format!("{:.1}s{}", duration, time_human);
383382
let max_concurrency = self.concurrency.iter().map(|c| c.active).max().unwrap();
384-
let num_cpus = available_parallelism()
385-
.map(|x| x.get().to_string())
386-
.unwrap_or_else(|_| "n/a".into());
387383
let max_rustc_concurrency = self
388384
.concurrency
389385
.iter()
@@ -446,7 +442,7 @@ impl<'cfg> Timings<'cfg> {
446442
self.total_fresh + self.total_dirty,
447443
max_concurrency,
448444
bcx.build_config.jobs,
449-
num_cpus,
445+
num_cpus::get(),
450446
self.start_str,
451447
total_time,
452448
rustc_info,

0 commit comments

Comments
 (0)