Skip to content

Commit e340b17

Browse files
Refactor benchmark checking in CI
1 parent 6167777 commit e340b17

File tree

3 files changed

+47
-5
lines changed

3 files changed

+47
-5
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,30 @@ jobs:
5555
5656
- name: Check benchmarks
5757
run: sh -x -c "ci/check-benchmarks.sh"
58+
env:
59+
COLLECTOR_ARGS: "--exclude servo,cargo,crates.io,packed-simd,sentry-cli,tuple-stress"
60+
test_benchmarks_2:
61+
name: Benchmark test 2
62+
runs-on: ubuntu-latest
63+
steps:
64+
- name: Checkout the source code
65+
uses: actions/checkout@v2
66+
with:
67+
fetch-depth: 1
68+
69+
- name: Install latest nightly
70+
uses: actions-rs/toolchain@v1
71+
with:
72+
toolchain: nightly
73+
override: true
74+
75+
- name: Configure environment
76+
run: |
77+
sudo apt-get update
78+
sudo apt-get install -y linux-tools-common linux-tools-generic linux-tools-`uname -r`
79+
echo -1 | sudo tee /proc/sys/kernel/perf_event_paranoid
5880
81+
- name: Check benchmarks
82+
run: sh -x -c "ci/check-benchmarks.sh"
83+
env:
84+
COLLECTOR_ARGS: "--filter servo,cargo,crates.io,packed-simd,sentry-cli,tuple-stress"

ci/check-benchmarks.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ bash -c "while true; do sleep 30; echo \$(date) - running ...; done" &
66
PING_LOOP_PID=$!
77
trap - ERR
88
cargo build -p collector;
9-
RUST_BACKTRACE=1 RUST_LOG=collector=trace,rust_sysroot=debug \
9+
RUST_BACKTRACE=1 RUST_LOG=collector=debug,rust_sysroot=debug \
1010
cargo run -p collector --bin collector -- \
1111
--db temporary.db \
12-
--exclude servo,cargo,crates.io,packed-simd,sentry-cli,tuple-stress test_benchmarks;
12+
$COLLECTOR_ARGS \
13+
test_benchmarks;
1314
code=$?
1415
kill $PING_LOOP_PID
1516
exit $code

collector/src/bin/rustc-perf-collector/main.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,17 @@ fn n_benchmarks_remaining(n: usize) -> String {
201201
format!("{} benchmark{} remaining", n, suffix)
202202
}
203203

204+
struct BenchmarkErrors(usize);
205+
206+
impl BenchmarkErrors {
207+
fn fail_if_error(self) -> anyhow::Result<()> {
208+
if self.0 > 0 {
209+
anyhow::bail!("{} benchmarks failed", self.0)
210+
}
211+
Ok(())
212+
}
213+
}
214+
204215
fn bench_commit(
205216
rt: &mut Runtime,
206217
mut conn: Box<dyn Connection>,
@@ -212,7 +223,8 @@ fn bench_commit(
212223
iterations: usize,
213224
call_home: bool,
214225
self_profile: bool,
215-
) {
226+
) -> BenchmarkErrors {
227+
let mut errors_recorded = 0;
216228
eprintln!("Benchmarking {} for triple {}", cid, compiler.triple);
217229

218230
if call_home {
@@ -245,7 +257,7 @@ fn bench_commit(
245257
"Note that this behavior is likely to change in the future \
246258
to collect and append the data instead."
247259
);
248-
return;
260+
return BenchmarkErrors(errors_recorded);
249261
}
250262
let interned_cid = rt.block_on(tx.conn().artifact_id(&cid));
251263

@@ -270,6 +282,7 @@ fn bench_commit(
270282
benchmark.measure(&mut processor, build_kinds, run_kinds, compiler, iterations);
271283
if let Err(s) = result {
272284
eprintln!("Failed to benchmark {}, recorded: {}", benchmark.name, s);
285+
errors_recorded += 1;
273286
rt.block_on(tx.conn().record_error(
274287
interned_cid,
275288
benchmark.name.0.as_str(),
@@ -294,6 +307,7 @@ fn bench_commit(
294307
// This ensures that we're good to go with the just updated data.
295308
conn.maybe_create_indices().await;
296309
});
310+
BenchmarkErrors(errors_recorded)
297311
}
298312

299313
fn get_benchmarks(
@@ -612,7 +626,7 @@ fn main_result() -> anyhow::Result<i32> {
612626
let sysroot = Sysroot::install(commit.sha.to_string(), "x86_64-unknown-linux-gnu")?;
613627
// filter out servo benchmarks as they simply take too long
614628
let conn = rt.block_on(pool.expect("--db passed").connection());
615-
bench_commit(
629+
let res = bench_commit(
616630
&mut rt,
617631
conn,
618632
&ArtifactId::Commit(commit),
@@ -624,6 +638,7 @@ fn main_result() -> anyhow::Result<i32> {
624638
false,
625639
self_profile,
626640
);
641+
res.fail_if_error()?;
627642
Ok(0)
628643
}
629644

0 commit comments

Comments
 (0)