Skip to content

Commit 192bfb9

Browse files
committed
Make runtime benchmark skipping more precise
Before, running a runtime benchmark suite would store all found runtime steps into the DB. That meant that if you tried to run a different set of benchmarks with the same artifact ID, they would not be executed at all. Now only the benchmark groups containing the actually selected benchmarks will be stored as steps into the DB, and thus skipped on follow-up executions.
1 parent cf502a0 commit 192bfb9

File tree

2 files changed

+42
-7
lines changed

2 files changed

+42
-7
lines changed

collector/src/bin/collector.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@ struct RuntimeBenchmarkConfig {
8888
iterations: u32,
8989
}
9090

91+
impl RuntimeBenchmarkConfig {
92+
fn new(suite: BenchmarkSuite, filter: BenchmarkFilter, iterations: u32) -> Self {
93+
Self {
94+
runtime_suite: suite.filter(&filter),
95+
filter,
96+
iterations,
97+
}
98+
}
99+
}
100+
91101
struct SharedBenchmarkConfig {
92102
artifact_id: ArtifactId,
93103
toolchain: Toolchain,
@@ -671,11 +681,11 @@ fn main_result() -> anyhow::Result<i32> {
671681
artifact_id,
672682
toolchain,
673683
};
674-
let config = RuntimeBenchmarkConfig {
684+
let config = RuntimeBenchmarkConfig::new(
675685
runtime_suite,
676-
filter: BenchmarkFilter::new(local.exclude, local.include),
686+
BenchmarkFilter::new(local.exclude, local.include),
677687
iterations,
678-
};
688+
);
679689
run_benchmarks(&mut rt, conn, shared, None, Some(config))?;
680690
Ok(0)
681691
}
@@ -1124,11 +1134,11 @@ fn bench_published_artifact(
11241134
is_self_profile: false,
11251135
bench_rustc: false,
11261136
}),
1127-
Some(RuntimeBenchmarkConfig {
1137+
Some(RuntimeBenchmarkConfig::new(
11281138
runtime_suite,
1129-
filter: BenchmarkFilter::keep_all(),
1130-
iterations: DEFAULT_RUNTIME_ITERATIONS,
1131-
}),
1139+
BenchmarkFilter::keep_all(),
1140+
DEFAULT_RUNTIME_ITERATIONS,
1141+
)),
11321142
)
11331143
}
11341144

collector/src/runtime/benchmark.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,31 @@ pub struct BenchmarkSuite {
3838
}
3939

4040
impl BenchmarkSuite {
41+
/// Returns a new suite containing only groups that contains at least a single benchmark
42+
/// that matches the filter.
43+
pub fn filter(self, filter: &BenchmarkFilter) -> Self {
44+
let BenchmarkSuite {
45+
groups,
46+
_tmp_artifacts_dir,
47+
} = self;
48+
49+
Self {
50+
groups: groups
51+
.into_iter()
52+
.filter(|group| {
53+
group.benchmark_names.iter().any(|benchmark| {
54+
passes_filter(
55+
benchmark,
56+
filter.exclude.as_deref(),
57+
filter.include.as_deref(),
58+
)
59+
})
60+
})
61+
.collect(),
62+
_tmp_artifacts_dir,
63+
}
64+
}
65+
4166
pub fn total_benchmark_count(&self) -> u64 {
4267
self.benchmark_names().count() as u64
4368
}

0 commit comments

Comments
 (0)