diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-08-15 20:11:41 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-15 20:11:41 +0200 |
| commit | e65de39763cc516a92c768c5644d7f86e973fb24 (patch) | |
| tree | c4a707523bfd7a0b4c4cc5f9da41862e2a885975 /src | |
| parent | fba30041f6d892cdd93d650d96d8f42ab0602d19 (diff) | |
| parent | 84531229bb923cdad698f271bdc1311f67f174e8 (diff) | |
Rollup merge of #100586 - the8472:available_parallelism_2, r=jyn514
Reland changes replacing num_cpus with available_parallelism Since #97925 added cgroupv1 support the problem in #97549 which lead to the previous revert should be addressed now. Cargo has reapplied the replacement too https://github.com/rust-lang/cargo/pull/10969 Reverts 1ae4b258267462da0b1aae1badcf83578153c799 (part of #97911) Relands #94524
Diffstat (limited to 'src')
| -rw-r--r-- | src/bootstrap/Cargo.lock | 1 | ||||
| -rw-r--r-- | src/bootstrap/Cargo.toml | 1 | ||||
| -rw-r--r-- | src/bootstrap/config.rs | 2 | ||||
| -rw-r--r-- | src/bootstrap/flags.rs | 2 | ||||
| -rw-r--r-- | src/bootstrap/lib.rs | 4 | ||||
| -rw-r--r-- | src/tools/build-manifest/Cargo.toml | 1 | ||||
| -rw-r--r-- | src/tools/build-manifest/src/main.rs | 2 |
7 files changed, 6 insertions, 7 deletions
diff --git a/src/bootstrap/Cargo.lock b/src/bootstrap/Cargo.lock index 664ffa1ddd2..84c06fdce70 100644 --- a/src/bootstrap/Cargo.lock +++ b/src/bootstrap/Cargo.lock @@ -53,7 +53,6 @@ dependencies = [ "hex", "ignore", "libc", - "num_cpus", "once_cell", "opener", "pretty_assertions", diff --git a/src/bootstrap/Cargo.toml b/src/bootstrap/Cargo.toml index 84f6aaf99c1..2dad41bb18f 100644 --- a/src/bootstrap/Cargo.toml +++ b/src/bootstrap/Cargo.toml @@ -38,7 +38,6 @@ test = false cmake = "0.1.38" fd-lock = "3.0.6" filetime = "0.2" -num_cpus = "1.0" getopts = "0.2.19" cc = "1.0.69" libc = "0.2" diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index c4983accc68..203db2d3876 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -1465,7 +1465,7 @@ fn set<T>(field: &mut T, val: Option<T>) { fn threads_from_config(v: u32) -> u32 { match v { - 0 => num_cpus::get() as u32, + 0 => std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get) as u32, n => n, } } diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index 1edb513f0b6..789da748100 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -220,7 +220,7 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`", let j_msg = format!( "number of jobs to run in parallel; \ defaults to {} (this host's logical CPU count)", - num_cpus::get() + std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get) ); opts.optopt("j", "jobs", &j_msg, "JOBS"); opts.optflag("h", "help", "print this help message"); diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index a242243aaaf..dcfa92d1004 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -1008,7 +1008,9 @@ impl Build { /// Returns the number of parallel jobs that have been configured for this /// build. fn jobs(&self) -> u32 { - self.config.jobs.unwrap_or_else(|| num_cpus::get() as u32) + self.config.jobs.unwrap_or_else(|| { + std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get) as u32 + }) } fn debuginfo_map_to(&self, which: GitRepo) -> Option<String> { diff --git a/src/tools/build-manifest/Cargo.toml b/src/tools/build-manifest/Cargo.toml index c022d3aa0ac..c437bde5ae6 100644 --- a/src/tools/build-manifest/Cargo.toml +++ b/src/tools/build-manifest/Cargo.toml @@ -13,4 +13,3 @@ tar = "0.4.29" sha2 = "0.10.1" rayon = "1.5.1" hex = "0.4.2" -num_cpus = "1.13.0" diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index efe3f2b618b..1a6760d8c68 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -210,7 +210,7 @@ fn main() { let num_threads = if let Some(num) = env::var_os("BUILD_MANIFEST_NUM_THREADS") { num.to_str().unwrap().parse().expect("invalid number for BUILD_MANIFEST_NUM_THREADS") } else { - num_cpus::get() + std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get) }; rayon::ThreadPoolBuilder::new() .num_threads(num_threads) |
