File tree 3 files changed +13
-4
lines changed
3 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,6 @@ libc = "0.2"
43
43
log = " 0.4.6"
44
44
libgit2-sys = " 0.13.1"
45
45
memchr = " 2.1.3"
46
- num_cpus = " 1.0"
47
46
opener = " 0.5"
48
47
os_info = " 3.0.7"
49
48
percent-encoding = " 2.0"
Original file line number Diff line number Diff line change 1
1
use crate :: core:: compiler:: CompileKind ;
2
2
use crate :: util:: interning:: InternedString ;
3
3
use crate :: util:: { CargoResult , Config , RustfixDiagnosticServer } ;
4
- use anyhow:: bail;
4
+ use anyhow:: { bail, Context as _ } ;
5
5
use cargo_util:: ProcessBuilder ;
6
6
use serde:: ser;
7
7
use std:: cell:: RefCell ;
8
8
use std:: path:: PathBuf ;
9
+ use std:: thread:: available_parallelism;
9
10
10
11
/// Configuration information for a rustc build.
11
12
#[ derive( Debug ) ]
@@ -70,7 +71,12 @@ impl BuildConfig {
70
71
its environment, ignoring the `-j` parameter",
71
72
) ?;
72
73
}
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
+ } ;
74
80
if jobs == 0 {
75
81
anyhow:: bail!( "jobs may not be 0" ) ;
76
82
}
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ use anyhow::Context as _;
13
13
use cargo_util:: paths;
14
14
use std:: collections:: HashMap ;
15
15
use std:: io:: { BufWriter , Write } ;
16
+ use std:: thread:: available_parallelism;
16
17
use std:: time:: { Duration , Instant , SystemTime } ;
17
18
18
19
pub struct Timings < ' cfg > {
@@ -380,6 +381,9 @@ impl<'cfg> Timings<'cfg> {
380
381
} ;
381
382
let total_time = format ! ( "{:.1}s{}" , duration, time_human) ;
382
383
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 ( ) ) ;
383
387
let max_rustc_concurrency = self
384
388
. concurrency
385
389
. iter ( )
@@ -442,7 +446,7 @@ impl<'cfg> Timings<'cfg> {
442
446
self . total_fresh + self . total_dirty,
443
447
max_concurrency,
444
448
bcx. build_config. jobs,
445
- num_cpus:: get ( ) ,
449
+ num_cpus,
446
450
self . start_str,
447
451
total_time,
448
452
rustc_info,
You can’t perform that action at this time.
0 commit comments