Skip to content

Commit 3a115ba

Browse files
committed
Print step timings also when the stap starts to execute
So that it is easier to see which was the last started step when a failure happens on CI.
1 parent aad5795 commit 3a115ba

File tree

1 file changed

+18
-6
lines changed
  • src/bootstrap/src/core/builder

1 file changed

+18
-6
lines changed

src/bootstrap/src/core/builder/mod.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,24 +1700,25 @@ You have to build a stage1 compiler for `{}` first, and then use it to build a s
17001700
#[cfg(feature = "build-metrics")]
17011701
self.metrics.enter_step(&step, self);
17021702

1703+
if self.config.print_step_timings && !self.config.dry_run() {
1704+
println!("[TIMING:start] {}", pretty_print_step(&step));
1705+
}
1706+
17031707
let (out, dur) = {
17041708
let start = Instant::now();
17051709
let zero = Duration::new(0, 0);
17061710
let parent = self.time_spent_on_dependencies.replace(zero);
1711+
17071712
let out = step.clone().run(self);
17081713
let dur = start.elapsed();
17091714
let deps = self.time_spent_on_dependencies.replace(parent + dur);
17101715
(out, dur.saturating_sub(deps))
17111716
};
17121717

17131718
if self.config.print_step_timings && !self.config.dry_run() {
1714-
let step_string = format!("{step:?}");
1715-
let brace_index = step_string.find('{').unwrap_or(0);
1716-
let type_string = type_name::<S>();
17171719
println!(
1718-
"[TIMING] {} {} -- {}.{:03}",
1719-
&type_string.strip_prefix("bootstrap::").unwrap_or(type_string),
1720-
&step_string[brace_index..],
1720+
"[TIMING:end] {} -- {}.{:03}",
1721+
pretty_print_step(&step),
17211722
dur.as_secs(),
17221723
dur.subsec_millis()
17231724
);
@@ -1804,6 +1805,17 @@ You have to build a stage1 compiler for `{}` first, and then use it to build a s
18041805
}
18051806
}
18061807

1808+
fn pretty_print_step<S: Step>(step: &S) -> String {
1809+
let step_dbg_repr = format!("{step:?}");
1810+
let brace_index = step_dbg_repr.find('{').unwrap_or(0);
1811+
1812+
// Normalize step type path to only keep the module and the type name
1813+
let path = type_name::<S>().rsplit("::").take(2).collect::<Vec<_>>();
1814+
let type_string = path.into_iter().rev().collect::<Vec<_>>().join("::");
1815+
1816+
format!("{type_string} {}", &step_dbg_repr[brace_index..])
1817+
}
1818+
18071819
impl<'a> AsRef<ExecutionContext> for Builder<'a> {
18081820
fn as_ref(&self) -> &ExecutionContext {
18091821
self.exec_ctx()

0 commit comments

Comments
 (0)