File tree Expand file tree Collapse file tree 3 files changed +13
-4
lines changed
Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,6 @@ libc = "0.2"
4343log = " 0.4.6"
4444libgit2-sys = " 0.13.1"
4545memchr = " 2.1.3"
46- num_cpus = " 1.0"
4746opener = " 0.5"
4847os_info = " 3.0.7"
4948percent-encoding = " 2.0"
Original file line number Diff line number Diff line change 11use crate :: core:: compiler:: CompileKind ;
22use crate :: util:: interning:: InternedString ;
33use crate :: util:: { CargoResult , Config , RustfixDiagnosticServer } ;
4- use anyhow:: bail;
4+ use anyhow:: { bail, Context as _ } ;
55use cargo_util:: ProcessBuilder ;
66use serde:: ser;
77use std:: cell:: RefCell ;
88use std:: path:: PathBuf ;
9+ use std:: thread:: available_parallelism;
910
1011/// Configuration information for a rustc build.
1112#[ derive( Debug ) ]
@@ -70,7 +71,12 @@ impl BuildConfig {
7071 its environment, ignoring the `-j` parameter",
7172 ) ?;
7273 }
73- let jobs = jobs. or ( cfg. jobs ) . unwrap_or ( :: num_cpus:: get ( ) as u32 ) ;
74+ let jobs = match jobs. or ( cfg. jobs ) {
75+ Some ( j) => j,
76+ None => available_parallelism ( )
77+ . context ( "failed to determine the amount of parallelism available" ) ?
78+ . get ( ) as u32 ,
79+ } ;
7480 if jobs == 0 {
7581 anyhow:: bail!( "jobs may not be 0" ) ;
7682 }
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ use anyhow::Context as _;
1313use cargo_util:: paths;
1414use std:: collections:: HashMap ;
1515use std:: io:: { BufWriter , Write } ;
16+ use std:: thread:: available_parallelism;
1617use std:: time:: { Duration , Instant , SystemTime } ;
1718
1819pub struct Timings < ' cfg > {
@@ -380,6 +381,9 @@ impl<'cfg> Timings<'cfg> {
380381 } ;
381382 let total_time = format ! ( "{:.1}s{}" , duration, time_human) ;
382383 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 ( ) ) ;
383387 let max_rustc_concurrency = self
384388 . concurrency
385389 . iter ( )
@@ -442,7 +446,7 @@ impl<'cfg> Timings<'cfg> {
442446 self . total_fresh + self . total_dirty,
443447 max_concurrency,
444448 bcx. build_config. jobs,
445- num_cpus:: get ( ) ,
449+ num_cpus,
446450 self . start_str,
447451 total_time,
448452 rustc_info,
You can’t perform that action at this time.
0 commit comments