Skip to content

Commit 83c5faa

Browse files
committed
test(runner-shared): keep instrumented module event benches to 1M events
Generating and searching artifacts much larger than 1M events outlasts the CI job under the simulation and memory instruments. Pick the sizes from CODSPEED_RUNNER_MODE so these modes only search the smallest artifact, leaving walltime and plain divan runs free to cover larger ones.
1 parent 02b1261 commit 83c5faa

1 file changed

Lines changed: 22 additions & 5 deletions

File tree

‎crates/runner-shared/benches/memtrack_reader.rs‎

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,39 @@
33
//! handful of records among millions of allocation events, so the cost is
44
//! dominated by everything the search has to read past.
55
6+
use clap::ValueEnum;
67
use divan::Bencher;
78
use divan::counter::{BytesCount, ItemsCount};
89
use rand::rngs::StdRng;
910
use rand::{Rng, SeedableRng};
1011
use runner_shared::artifacts::{
1112
MemtrackArtifact, MemtrackEvent, MemtrackEventKind, StackRecord, encode_events,
1213
};
14+
use runner_shared::measurement_mode::MeasurementMode;
15+
use runner_shared::runtime_env::RUNNER_MODE_ENV;
1316
use std::io::Write;
1417

1518
fn main() {
1619
divan::main();
1720
}
1821

19-
/// Artifact sizes in events. CI-sized artifacts take minutes per case with the
20-
/// streamed decoder under the simulation instrument.
21-
const SIZES: &[usize] = &[1_000_000];
22+
/// Artifact sizes in events.
23+
const WALLTIME_MODE_SIZES: &[usize] = &[1_000_000];
24+
25+
/// Under the simulation and memory instruments, generating and searching
26+
/// larger artifacts outlasts the CI job, so these modes only search the
27+
/// smallest artifact.
28+
const ANALYSIS_MODE_SIZES: &[usize] = &[1_000_000];
29+
30+
fn sizes() -> &'static [usize] {
31+
let mode = std::env::var(RUNNER_MODE_ENV)
32+
.ok()
33+
.and_then(|mode| MeasurementMode::from_str(&mode, true).ok());
34+
match mode {
35+
Some(MeasurementMode::Simulation | MeasurementMode::Memory) => ANALYSIS_MODE_SIZES,
36+
Some(MeasurementMode::Walltime) | None => WALLTIME_MODE_SIZES,
37+
}
38+
}
2239

2340
#[derive(Clone, Copy)]
2441
enum Payload {
@@ -27,13 +44,13 @@ enum Payload {
2744
}
2845

2946
/// An artifact without stack capture.
30-
#[divan::bench(args = SIZES, max_time = 10.0)]
47+
#[divan::bench(args = sizes(), max_time = 10.0)]
3148
fn find_module_events(bencher: Bencher, n: usize) {
3249
bench(bencher, n, Payload::Allocations);
3350
}
3451

3552
/// An artifact with captured stacks, which make up most of its bytes.
36-
#[divan::bench(args = SIZES, max_time = 10.0)]
53+
#[divan::bench(args = sizes(), max_time = 10.0)]
3754
fn find_module_events_with_stacks(bencher: Bencher, n: usize) {
3855
bench(bencher, n, Payload::AllocationsAndStacks);
3956
}

0 commit comments

Comments
 (0)