Skip to content

Commit 6fe23ef

Browse files
committed
Don't depend on num_cpus for parallelism
We almost never use it anyway and it's an extra dependency that complicates the build process of rust-lang/rust. Let's just stick to a smaller default in the case that we're running entirely outside of a Cargo context, which should be pretty rare anyway.
1 parent 150cdfc commit 6fe23ef

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ exclude = ["/.travis.yml", "/appveyor.yml"]
1818
edition = "2018"
1919

2020
[dependencies]
21-
num_cpus = { version = "1.10", optional = true }
2221
jobserver = { version = "0.1.16", optional = true }
2322

2423
[features]
25-
parallel = ["num_cpus", "jobserver"]
24+
parallel = ["jobserver"]
2625

2726
[dev-dependencies]
2827
tempfile = "3"

src/lib.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,9 +1101,13 @@ impl Build {
11011101
return client;
11021102
}
11031103

1104-
// ... but if that fails for whatever reason fall back to the number
1105-
// of cpus on the system or the `NUM_JOBS` env var.
1106-
let mut parallelism = num_cpus::get();
1104+
// ... but if that fails for whatever reason select something
1105+
// reasonable and crate a new jobserver. Use `NUM_JOBS` if set (it's
1106+
// configured by Cargo) and otherwise just fall back to a
1107+
// semi-reasonable number. Note that we could use `num_cpus` here
1108+
// but it's an extra dependency that will almost never be used, so
1109+
// it's generally not too worth it.
1110+
let mut parallelism = 4;
11071111
if let Ok(amt) = env::var("NUM_JOBS") {
11081112
if let Ok(amt) = amt.parse() {
11091113
parallelism = amt;

0 commit comments

Comments
 (0)