Skip to content

Commit 1574854

Browse files
committed
bench: Update the benchmark runner to gungraun 0.17
`iai-callgrind` was renamed to `gungraun` and had a new release. Update everything to match. There shouldn't be any changes to observable behavior here.
1 parent 936db7f commit 1574854

File tree

10 files changed

+45
-34
lines changed

10 files changed

+45
-34
lines changed

.github/workflows/main.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,13 +247,13 @@ jobs:
247247
- name: Set up dependencies
248248
run: |
249249
sudo apt-get update
250-
sudo apt-get install -y valgrind gdb libc6-dbg # Needed for iai-callgrind
250+
sudo apt-get install -y valgrind gdb libc6-dbg # Needed for gungraun
251251
rustup update "$BENCHMARK_RUSTC" --no-self-update
252252
rustup default "$BENCHMARK_RUSTC"
253-
# Install the version of iai-callgrind-runner that is specified in Cargo.toml
254-
iai_version="$(cargo metadata --format-version=1 --features icount |
255-
jq -r '.packages[] | select(.name == "iai-callgrind").version')"
256-
cargo binstall -y iai-callgrind-runner --version "$iai_version"
253+
# Install the version of gungraun-runner that is specified in Cargo.toml
254+
gungraun_version="$(cargo metadata --format-version=1 --features icount |
255+
jq -r '.packages[] | select(.name == "gungraun").version')"
256+
cargo binstall -y gungraun-runner --version "$gungraun_version"
257257
sudo apt-get install valgrind
258258
- uses: Swatinem/rust-cache@v2
259259
with:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ compiler-rt
99
# Benchmark cache
1010
baseline-*
1111
iai-home
12+
gungraun-home
1213

1314
# Temporary files
1415
*.bk

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ cargo bench --no-default-features \
150150
```
151151

152152
There are also benchmarks that check instruction count behind the `icount`
153-
feature. These require [`iai-callgrind-runner`] (via Cargo) and [Valgrind]
154-
to be installed, which means these only run on limited platforms.
153+
feature. These require [`gungraun-runner`] (via Cargo) and [Valgrind] to be
154+
installed, which means these only run on limited platforms.
155155

156156
Instruction count benchmarks are run as part of CI to flag performance
157157
regresions.
@@ -163,7 +163,7 @@ cargo bench --no-default-features \
163163
--bench icount --bench mem_icount
164164
```
165165

166-
[`iai-callgrind-runner`]: https://crates.io/crates/iai-callgrind-runner
166+
[`gungraun-runner`]: https://crates.io/crates/gungraun-runner
167167
[Valgrind]: https://valgrind.org/
168168

169169
## Subtree synchronization

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@ codegen-units = 1
5151
lto = "fat"
5252

5353
[profile.bench]
54-
# Required for iai-callgrind
54+
# Required for gungraun
5555
debug = true

builtins-test/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ rand_xoshiro = "0.7"
1414
# To compare float builtins against
1515
rustc_apfloat = "0.2.3"
1616
# Really a dev dependency, but dev dependencies can't be optional
17-
iai-callgrind = { version = "0.15.2", optional = true }
17+
gungraun = { version = "0.17.0", optional = true }
1818

1919
[dependencies.compiler_builtins]
2020
path = "../builtins-shim"
@@ -46,8 +46,8 @@ no-sys-f16-f64-convert = []
4646
# Skip tests that rely on f16 symbols being available on the system
4747
no-sys-f16 = ["no-sys-f16-f64-convert"]
4848

49-
# Enable icount benchmarks (requires iai-callgrind and valgrind)
50-
icount = ["dep:iai-callgrind"]
49+
# Enable icount benchmarks (requires gungraun-runner and valgrind locally)
50+
icount = ["dep:gungraun"]
5151

5252
# Enable report generation without bringing in more dependencies by default
5353
benchmarking-reports = ["criterion/plotters", "criterion/html_reports"]

builtins-test/benches/mem_icount.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
//! Benchmarks that use Callgrind (via `iai_callgrind`) to report instruction count metrics. This
1+
//! Benchmarks that use Callgrind (via `gungraun`) to report instruction count metrics. This
22
//! is stable enough to be tested in CI.
33
44
use std::hint::black_box;
55
use std::{ops, slice};
66

77
use compiler_builtins::mem::{memcmp, memcpy, memmove, memset};
8-
use iai_callgrind::{library_benchmark, library_benchmark_group, main};
8+
use gungraun::{library_benchmark, library_benchmark_group, main};
99

1010
const PAGE_SIZE: usize = 0x1000; // 4 kiB
1111
const MAX_ALIGN: usize = 512; // assume we may use avx512 operations one day

ci/bench-icount.sh

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,18 @@ if [ -z "$target" ]; then
1010
target="$host_target"
1111
fi
1212

13-
iai_home="iai-home"
13+
gungraun_home="gungraun-home"
1414

1515
# Use the arch as a tag to disambiguate artifacts
1616
tag="$(echo "$target" | cut -d'-' -f1)"
1717

1818
# Download the baseline from main
1919
./ci/ci-util.py locate-baseline --download --extract --tag "$tag"
2020

21+
# FIXME: migration from iai-named baselines to gungraun, can be dropped
22+
# after the first run with gungraun.
23+
[ -d "iai-home" ] && mv "iai-home" "$gungraun_home"
24+
2125
# Run benchmarks once
2226
function run_icount_benchmarks() {
2327
cargo_args=(
@@ -26,29 +30,29 @@ function run_icount_benchmarks() {
2630
"--features" "unstable,unstable-float,icount"
2731
)
2832

29-
iai_args=(
30-
"--home" "$(pwd)/$iai_home"
31-
"--callgrind-limits=ir=5.0"
33+
gungraun_args=(
34+
"--home" "$(pwd)/$gungraun_home"
35+
"--callgrind-limits=ir=5.0%"
3236
"--save-summary"
3337
)
3438

35-
# Parse `cargo_arg0 cargo_arg1 -- iai_arg0 iai_arg1` syntax
36-
parsing_iai_args=0
39+
# Parse `cargo_arg0 cargo_arg1 -- gungraun_arg0 gungraun_arg1` syntax
40+
parsing_gungraun_args=0
3741
while [ "$#" -gt 0 ]; do
38-
if [ "$parsing_iai_args" == "1" ]; then
39-
iai_args+=("$1")
42+
if [ "$parsing_gungraun_args" == "1" ]; then
43+
gungraun_args+=("$1")
4044
elif [ "$1" == "--" ]; then
41-
parsing_iai_args=1
45+
parsing_gungraun_args=1
4246
else
4347
cargo_args+=("$1")
4448
fi
4549

4650
shift
4751
done
4852

49-
# Run iai-callgrind benchmarks. Do this in a subshell with `&& true` to
50-
# capture rather than exit on error.
51-
(cargo bench "${cargo_args[@]}" -- "${iai_args[@]}") && true
53+
# Run gungraun benchmarks. Do this in a subshell with `&& true` to capture
54+
# rather than exit on error.
55+
(cargo bench "${cargo_args[@]}" -- "${gungraun_args[@]}") && true
5256
exit_code="$?"
5357

5458
if [ "$exit_code" -eq 0 ]; then
@@ -68,4 +72,4 @@ run_icount_benchmarks -- --save-baseline=hardfloat
6872
# Name and tar the new baseline
6973
name="baseline-icount-$tag-$(date -u +'%Y%m%d%H%M')-${GITHUB_SHA:0:12}"
7074
echo "BASELINE_NAME=$name" >>"$GITHUB_ENV"
71-
tar cJf "$name.tar.xz" "$iai_home"
75+
tar cJf "$name.tar.xz" "$gungraun_home"

ci/ci-util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
`--tag` can be specified to look for artifacts with a specific tag, such as
3939
for a specific architecture.
4040
41-
Note that `--extract` will overwrite files in `iai-home`.
41+
Note that `--extract` will overwrite files in `gungraun-home`.
4242
4343
handle-bench-regressions PR_NUMBER
4444
Exit with success if the pull request contains a line starting with

libm-test/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ build-musl = ["dep:musl-math-sys"]
2121
# Enable report generation without bringing in more dependencies by default
2222
benchmarking-reports = ["criterion/plotters", "criterion/html_reports"]
2323

24-
# Enable icount benchmarks (requires iai-callgrind and valgrind)
25-
icount = ["dep:iai-callgrind"]
24+
# Enable icount benchmarks (requires gungraun-runner and valgrind locally)
25+
icount = ["dep:gungraun"]
2626

2727
# Run with a reduced set of benchmarks, such as for CI
2828
short-benchmarks = []
@@ -31,7 +31,7 @@ short-benchmarks = []
3131
anyhow = "1.0.98"
3232
# This is not directly used but is required so we can enable `gmp-mpfr-sys/force-cross`.
3333
gmp-mpfr-sys = { version = "1.6.5", optional = true, default-features = false }
34-
iai-callgrind = { version = "0.15.2", optional = true }
34+
gungraun = { version = "0.17.0", optional = true }
3535
indicatif = { version = "0.18.0", default-features = false }
3636
libm = { path = "../libm", features = ["unstable-public-internals"] }
3737
libm-macros = { path = "../crates/libm-macros" }

libm-test/benches/icount.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
//! Benchmarks that use `iai-cachegrind` to be reasonably CI-stable.
1+
//! Benchmarks that use `gungraun` to be reasonably CI-stable.
22
#![feature(f16)]
33
#![feature(f128)]
44

55
use std::hint::black_box;
66

7-
use iai_callgrind::{library_benchmark, library_benchmark_group, main};
7+
use gungraun::{library_benchmark, library_benchmark_group, main};
88
use libm::support::{HInt, Hexf, hf16, hf32, hf64, hf128, u256};
99
use libm_test::generate::spaced;
1010
use libm_test::{CheckBasis, CheckCtx, GeneratorKind, MathOp, OpRustArgs, TupleCall, op};
@@ -156,7 +156,13 @@ fn icount_bench_u256_shr(cases: Vec<(u256, u32)>) {
156156

157157
library_benchmark_group!(
158158
name = icount_bench_u128_group;
159-
benchmarks = icount_bench_u128_widen_mul, icount_bench_u256_narrowing_div, icount_bench_u256_add, icount_bench_u256_sub, icount_bench_u256_shl, icount_bench_u256_shr
159+
benchmarks =
160+
icount_bench_u128_widen_mul,
161+
icount_bench_u256_narrowing_div,
162+
icount_bench_u256_add,
163+
icount_bench_u256_sub,
164+
icount_bench_u256_shl,
165+
icount_bench_u256_shr
160166
);
161167

162168
#[library_benchmark]

0 commit comments

Comments
 (0)