Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit report on error with Ztimings. #7872

Merged
merged 1 commit into from
Feb 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Emit report on error with Ztimings.
  • Loading branch information
ehuss committed Feb 6, 2020
commit 2061e8661271fd3d1a8935a9f104114c6b3c6904
2 changes: 1 addition & 1 deletion src/cargo/core/compiler/job_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 676,7 @@ impl<'a, 'cfg> DrainState<'a, 'cfg> {
}

let time_elapsed = util::elapsed(cx.bcx.config.creation_time().elapsed());
self.timings.finished(cx.bcx, &error)?;

if let Some(e) = error {
Err(e)
Expand All @@ -687,7 688,6 @@ impl<'a, 'cfg> DrainState<'a, 'cfg> {
if !cx.bcx.build_config.build_plan {
cx.bcx.config.shell().status("Finished", message)?;
}
self.timings.finished(cx.bcx)?;
Ok(())
} else {
debug!("queue: {:#?}", self.queue);
Expand Down
35 changes: 30 additions & 5 deletions src/cargo/core/compiler/timings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,21 293,29 @@ impl<'a, 'cfg> Timings<'a, 'cfg> {
}

/// Call this when all units are finished.
pub fn finished(&mut self, bcx: &BuildContext<'_, '_>) -> CargoResult<()> {
pub fn finished(
&mut self,
bcx: &BuildContext<'_, '_>,
error: &Option<anyhow::Error>,
) -> CargoResult<()> {
if !self.enabled {
return Ok(());
}
self.mark_concurrency(0, 0, 0, 0);
self.unit_times
.sort_unstable_by(|a, b| a.start.partial_cmp(&b.start).unwrap());
if self.report_html {
self.report_html(bcx)?;
self.report_html(bcx, error)?;
}
Ok(())
}

/// Save HTML report to disk.
fn report_html(&self, bcx: &BuildContext<'_, '_>) -> CargoResult<()> {
fn report_html(
&self,
bcx: &BuildContext<'_, '_>,
error: &Option<anyhow::Error>,
) -> CargoResult<()> {
let duration = d_as_f64(self.start.elapsed());
let timestamp = self.start_str.replace(&['-', ':'][..], "");
let filename = format!("cargo-timing-{}.html", timestamp);
Expand All @@ -318,7 326,7 @@ impl<'a, 'cfg> Timings<'a, 'cfg> {
.map(|(name, _targets)| name.as_str())
.collect();
f.write_all(HTML_TMPL.replace("{ROOTS}", &roots.join(", ")).as_bytes())?;
self.write_summary_table(&mut f, duration, bcx)?;
self.write_summary_table(&mut f, duration, bcx, error)?;
f.write_all(HTML_CANVAS.as_bytes())?;
self.write_unit_table(&mut f)?;
// It helps with pixel alignment to use whole numbers.
Expand Down Expand Up @@ -359,6 367,7 @@ impl<'a, 'cfg> Timings<'a, 'cfg> {
f: &mut impl Write,
duration: f64,
bcx: &BuildContext<'_, '_>,
error: &Option<anyhow::Error>,
) -> CargoResult<()> {
let targets: Vec<String> = self
.root_targets
Expand All @@ -380,6 389,17 @@ impl<'a, 'cfg> Timings<'a, 'cfg> {
.max()
.unwrap();
let rustc_info = render_rustc_info(bcx);
let error_msg = match error {
Some(e) => format!(
r#"\
<tr>
<td class="error-text">Error:</td><td>{}</td>
</tr>
"#,
e
),
None => "".to_string(),
};
write!(
f,
r#"
Expand Down Expand Up @@ -414,7 434,7 @@ impl<'a, 'cfg> Timings<'a, 'cfg> {
<tr>
<td>Max (global) rustc threads concurrency:</td><td>{}</td>
</tr>

{}
</table>
"#,
targets,
Expand All @@ -429,6 449,7 @@ impl<'a, 'cfg> Timings<'a, 'cfg> {
total_time,
rustc_info,
max_rustc_concurrency,
error_msg,
)?;
Ok(())
}
Expand Down Expand Up @@ -698,6 719,10 @@ h1 {
text-align: center;
}

.error-text {
color: #e80000;
}

</style>
</head>
<body>
Expand Down