Skip to content

Commit 1e3a384

Browse files
authored
Rollup merge of #110442 - ferrocene:pa-build-metrics-dry-run, r=ozkanonur
Avoid including dry run steps in the build metrics Including steps executed during the dry run will result in a duplication of all the steps in the build metrics, which just adds noise.
2 parents 41ae7fc + 4cd0e00 commit 1e3a384

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

src/bootstrap/builder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2030,7 +2030,7 @@ impl<'a> Builder<'a> {
20302030
}
20312031

20322032
#[cfg(feature = "build-metrics")]
2033-
self.metrics.enter_step(&step);
2033+
self.metrics.enter_step(&step, self);
20342034

20352035
let (out, dur) = {
20362036
let start = Instant::now();
@@ -2056,7 +2056,7 @@ impl<'a> Builder<'a> {
20562056
}
20572057

20582058
#[cfg(feature = "build-metrics")]
2059-
self.metrics.exit_step();
2059+
self.metrics.exit_step(self);
20602060

20612061
{
20622062
let mut stack = self.stack.borrow_mut();

src/bootstrap/metrics.rs

+19-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//! As this module requires additional dependencies not present during local builds, it's cfg'd
55
//! away whenever the `build.metrics` config option is not set to `true`.
66
7-
use crate::builder::Step;
7+
use crate::builder::{Builder, Step};
88
use crate::util::t;
99
use crate::Build;
1010
use serde_derive::{Deserialize, Serialize};
@@ -33,7 +33,12 @@ impl BuildMetrics {
3333
BuildMetrics { state }
3434
}
3535

36-
pub(crate) fn enter_step<S: Step>(&self, step: &S) {
36+
pub(crate) fn enter_step<S: Step>(&self, step: &S, builder: &Builder<'_>) {
37+
// Do not record dry runs, as they'd be duplicates of the actual steps.
38+
if builder.config.dry_run() {
39+
return;
40+
}
41+
3742
let mut state = self.state.borrow_mut();
3843

3944
// Consider all the stats gathered so far as the parent's.
@@ -56,7 +61,12 @@ impl BuildMetrics {
5661
});
5762
}
5863

59-
pub(crate) fn exit_step(&self) {
64+
pub(crate) fn exit_step(&self, builder: &Builder<'_>) {
65+
// Do not record dry runs, as they'd be duplicates of the actual steps.
66+
if builder.config.dry_run() {
67+
return;
68+
}
69+
6070
let mut state = self.state.borrow_mut();
6171

6272
self.collect_stats(&mut *state);
@@ -74,7 +84,12 @@ impl BuildMetrics {
7484
}
7585
}
7686

77-
pub(crate) fn record_test(&self, name: &str, outcome: TestOutcome) {
87+
pub(crate) fn record_test(&self, name: &str, outcome: TestOutcome, builder: &Builder<'_>) {
88+
// Do not record dry runs, as they'd be duplicates of the actual steps.
89+
if builder.config.dry_run() {
90+
return;
91+
}
92+
7893
let mut state = self.state.borrow_mut();
7994
state
8095
.running_steps

src/bootstrap/render_tests.rs

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ impl<'a> Renderer<'a> {
124124
ignore_reason: reason.map(|s| s.to_string()),
125125
},
126126
},
127+
self.builder,
127128
);
128129

129130
if self.builder.config.verbose_tests {

0 commit comments

Comments
 (0)