File tree Expand file tree Collapse file tree 5 files changed +17
-3
lines changed
Expand file tree Collapse file tree 5 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -437,6 +437,9 @@ impl<'gctx> Timings<'gctx> {
437437 . iter ( )
438438 . map ( |kind| build_runner. bcx . target_data . short_name ( kind) )
439439 . collect :: < Vec < _ > > ( ) ;
440+ let num_cpus = std:: thread:: available_parallelism ( )
441+ . ok ( )
442+ . map ( |x| x. get ( ) as u64 ) ;
440443
441444 let unit_data = report:: to_unit_data ( & self . unit_times , & self . unit_to_index ) ;
442445 let concurrency = report:: compute_concurrency ( & unit_data) ;
@@ -454,6 +457,7 @@ impl<'gctx> Timings<'gctx> {
454457 host : & build_runner. bcx . rustc ( ) . host ,
455458 requested_targets,
456459 jobs : build_runner. bcx . jobs ( ) ,
460+ num_cpus,
457461 error,
458462 } ;
459463 report:: write_html ( ctx, & mut f) ?;
Original file line number Diff line number Diff line change @@ -124,6 +124,8 @@ pub struct RenderContext<'a> {
124124 pub requested_targets : & ' a [ & ' a str ] ,
125125 /// The number of jobs specified for this build.
126126 pub jobs : u32 ,
127+ /// Available parallelism of the compilation environment.
128+ pub num_cpus : Option < u64 > ,
127129 /// Fatal error during the build.
128130 pub error : & ' a Option < anyhow:: Error > ,
129131}
@@ -185,9 +187,10 @@ fn write_summary_table(
185187 let total_time = format ! ( "{:.1}s{}" , duration, time_human) ;
186188
187189 let max_concurrency = ctx. concurrency . iter ( ) . map ( |c| c. active ) . max ( ) . unwrap_or ( 0 ) ;
188- let num_cpus = std:: thread:: available_parallelism ( )
189- . map ( |x| x. get ( ) . to_string ( ) )
190- . unwrap_or_else ( |_| "n/a" . into ( ) ) ;
190+ let num_cpus = ctx
191+ . num_cpus
192+ . map ( |x| x. to_string ( ) )
193+ . unwrap_or_else ( || "n/a" . into ( ) ) ;
191194
192195 let requested_targets = ctx. requested_targets . join ( ", " ) ;
193196
Original file line number Diff line number Diff line change @@ -162,10 +162,14 @@ pub fn compile_ws<'a>(
162162
163163 if let Some ( ref logger) = logger {
164164 let rustc = ws. gctx ( ) . load_global_rustc ( Some ( ws) ) ?;
165+ let num_cpus = std:: thread:: available_parallelism ( )
166+ . ok ( )
167+ . map ( |x| x. get ( ) as u64 ) ;
165168 logger. log ( LogMessage :: BuildStarted {
166169 cwd : ws. gctx ( ) . cwd ( ) . to_path_buf ( ) ,
167170 host : rustc. host . to_string ( ) ,
168171 jobs : options. build_config . jobs ,
172+ num_cpus,
169173 profile : options. build_config . requested_profile . to_string ( ) ,
170174 rustc_version : rustc. version . to_string ( ) ,
171175 rustc_version_verbose : rustc. verbose_version . clone ( ) ,
Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ pub enum LogMessage {
2424 host : String ,
2525 /// Number of parallel jobs.
2626 jobs : u32 ,
27+ /// Available parallelism of the compilation environment.
28+ num_cpus : Option < u64 > ,
2729 /// Build profile name (e.g., "dev", "release").
2830 profile : String ,
2931 /// The rustc version (`1.23.4-beta.2`).
Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ fn log_msg_build_started() {
8080 "cwd": "[ROOT]/foo",
8181 "host": "[HOST_TARGET]",
8282 "jobs": "{...}",
83+ "num_cpus": "{...}",
8384 "profile": "dev",
8485 "reason": "build-started",
8586 "run_id": "[..]T[..]Z-[..]",
You can’t perform that action at this time.
0 commit comments