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

Avoid including dry run steps in the build metrics #110442

Merged
merged 1 commit into from
Apr 18, 2023
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
4 changes: 2 additions & 2 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2010,7 +2010,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 @@ -2036,7 +2036,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