Skip to content

Commit

Permalink
Rollup merge of #110442 - ferrocene:pa-build-metrics-dry-run, r=ozkan…
Browse files Browse the repository at this point in the history
…onur

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.
  • Loading branch information
matthiaskrgr committed Apr 18, 2023
2 parents 41ae7fc + 4cd0e00 commit 1e3a384
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2030,7 +2030,7 @@ impl<'a> Builder<'a> {
}

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

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

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

{
let mut stack = self.stack.borrow_mut();
Expand Down
23 changes: 19 additions & 4 deletions src/bootstrap/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! As this module requires additional dependencies not present during local builds, it's cfg'd
//! away whenever the `build.metrics` config option is not set to `true`.

use crate::builder::Step;
use crate::builder::{Builder, Step};
use crate::util::t;
use crate::Build;
use serde_derive::{Deserialize, Serialize};
Expand Down Expand Up @@ -33,7 +33,12 @@ impl BuildMetrics {
BuildMetrics { state }
}

pub(crate) fn enter_step<S: Step>(&self, step: &S) {
pub(crate) fn enter_step<S: Step>(&self, step: &S, builder: &Builder<'_>) {
// Do not record dry runs, as they'd be duplicates of the actual steps.
if builder.config.dry_run() {
return;
}

let mut state = self.state.borrow_mut();

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

pub(crate) fn exit_step(&self) {
pub(crate) fn exit_step(&self, builder: &Builder<'_>) {
// Do not record dry runs, as they'd be duplicates of the actual steps.
if builder.config.dry_run() {
return;
}

let mut state = self.state.borrow_mut();

self.collect_stats(&mut *state);
Expand All @@ -74,7 +84,12 @@ impl BuildMetrics {
}
}

pub(crate) fn record_test(&self, name: &str, outcome: TestOutcome) {
pub(crate) fn record_test(&self, name: &str, outcome: TestOutcome, builder: &Builder<'_>) {
// Do not record dry runs, as they'd be duplicates of the actual steps.
if builder.config.dry_run() {
return;
}

let mut state = self.state.borrow_mut();
state
.running_steps
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/render_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ impl<'a> Renderer<'a> {
ignore_reason: reason.map(|s| s.to_string()),
},
},
self.builder,
);

if self.builder.config.verbose_tests {
Expand Down

0 comments on commit 1e3a384

Please sign in to comment.