Skip to content

Commit 2fd180f

Browse files
committed
Auto merge of #7398 - ehuss:timings-jobs, r=alexcrichton
-Ztimings: show max jobs/cpus <img width="295" alt="image" src="https://user-images.githubusercontent.com/43198/65363872-f611a280-dbc2-11e9-8abc-bb5e6e0966d0.png">
2 parents 317f0f5 + a6ecbad commit 2fd180f

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

src/cargo/core/compiler/job_queue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ impl<'a, 'cfg> JobQueue<'a, 'cfg> {
445445
if !cx.bcx.build_config.build_plan {
446446
cx.bcx.config.shell().status("Finished", message)?;
447447
}
448-
self.timings.finished()?;
448+
self.timings.finished(cx.bcx)?;
449449
Ok(())
450450
} else {
451451
debug!("queue: {:#?}", self.queue);

src/cargo/core/compiler/timings.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ pub struct Timings<'a, 'cfg> {
2727
start: Instant,
2828
/// A rendered string of when compilation started.
2929
start_str: String,
30-
/// Some information to display about rustc.
31-
rustc_info: String,
3230
/// A summary of the root units.
3331
///
3432
/// Tuples of `(package_description, target_descrptions)`.
@@ -118,7 +116,6 @@ impl<'a, 'cfg> Timings<'a, 'cfg> {
118116
})
119117
.collect();
120118
let start_str = humantime::format_rfc3339_seconds(SystemTime::now()).to_string();
121-
let rustc_info = render_rustc_info(bcx);
122119
let profile = if bcx.build_config.release {
123120
"release"
124121
} else {
@@ -134,7 +131,6 @@ impl<'a, 'cfg> Timings<'a, 'cfg> {
134131
report_json,
135132
start: bcx.config.creation_time(),
136133
start_str,
137-
rustc_info,
138134
root_targets,
139135
profile,
140136
total_fresh: 0,
@@ -290,21 +286,21 @@ impl<'a, 'cfg> Timings<'a, 'cfg> {
290286
}
291287

292288
/// Call this when all units are finished.
293-
pub fn finished(&mut self) -> CargoResult<()> {
289+
pub fn finished(&mut self, bcx: &BuildContext<'_, '_>) -> CargoResult<()> {
294290
if !self.enabled {
295291
return Ok(());
296292
}
297293
self.mark_concurrency(0, 0, 0);
298294
self.unit_times
299295
.sort_unstable_by(|a, b| a.start.partial_cmp(&b.start).unwrap());
300296
if self.report_html {
301-
self.report_html()?;
297+
self.report_html(bcx)?;
302298
}
303299
Ok(())
304300
}
305301

306302
/// Save HTML report to disk.
307-
fn report_html(&self) -> CargoResult<()> {
303+
fn report_html(&self, bcx: &BuildContext<'_, '_>) -> CargoResult<()> {
308304
let duration = self.start.elapsed().as_secs() as u32 + 1;
309305
let timestamp = self.start_str.replace(&['-', ':'][..], "");
310306
let filename = format!("cargo-timing-{}.html", timestamp);
@@ -315,7 +311,7 @@ impl<'a, 'cfg> Timings<'a, 'cfg> {
315311
.map(|(name, _targets)| name.as_str())
316312
.collect();
317313
f.write_all(HTML_TMPL.replace("{ROOTS}", &roots.join(", ")).as_bytes())?;
318-
self.write_summary_table(&mut f, duration)?;
314+
self.write_summary_table(&mut f, duration, bcx)?;
319315
f.write_all(HTML_CANVAS.as_bytes())?;
320316
self.write_unit_table(&mut f)?;
321317
writeln!(
@@ -350,7 +346,12 @@ impl<'a, 'cfg> Timings<'a, 'cfg> {
350346
}
351347

352348
/// Render the summary table.
353-
fn write_summary_table(&self, f: &mut impl Write, duration: u32) -> CargoResult<()> {
349+
fn write_summary_table(
350+
&self,
351+
f: &mut impl Write,
352+
duration: u32,
353+
bcx: &BuildContext<'_, '_>,
354+
) -> CargoResult<()> {
354355
let targets: Vec<String> = self
355356
.root_targets
356357
.iter()
@@ -364,6 +365,7 @@ impl<'a, 'cfg> Timings<'a, 'cfg> {
364365
};
365366
let total_time = format!("{}s{}", duration, time_human);
366367
let max_concurrency = self.concurrency.iter().map(|c| c.active).max().unwrap();
368+
let rustc_info = render_rustc_info(bcx);
367369
write!(
368370
f,
369371
r#"
@@ -384,7 +386,7 @@ impl<'a, 'cfg> Timings<'a, 'cfg> {
384386
<td>Total units:</td><td>{}</td>
385387
</tr>
386388
<tr>
387-
<td>Max concurrency:</td><td>{}</td>
389+
<td>Max concurrency:</td><td>{} (jobs={} ncpu={})</td>
388390
</tr>
389391
<tr>
390392
<td>Build start:</td><td>{}</td>
@@ -404,9 +406,11 @@ impl<'a, 'cfg> Timings<'a, 'cfg> {
404406
self.total_dirty,
405407
self.total_fresh + self.total_dirty,
406408
max_concurrency,
409+
bcx.build_config.jobs,
410+
num_cpus::get(),
407411
self.start_str,
408412
total_time,
409-
self.rustc_info,
413+
rustc_info,
410414
)?;
411415
Ok(())
412416
}

0 commit comments

Comments
 (0)