Skip to content

Commit c257f55

Browse files
committed
Enable icount benchmarks in CI
1 parent 897e60a commit c257f55

File tree

4 files changed

+55
-3
lines changed

4 files changed

+55
-3
lines changed

.github/workflows/main.yaml

+53-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ env:
1313
RUSTDOCFLAGS: -Dwarnings
1414
RUSTFLAGS: -Dwarnings
1515
RUST_BACKTRACE: full
16+
BENCHMARK_RUSTC: nightly-2025-01-16 # Pin the toolchain for reproducable results
1617

1718
jobs:
1819
test:
@@ -161,6 +162,55 @@ jobs:
161162
- uses: Swatinem/rust-cache@v2
162163
- run: cargo clippy -- -D clippy::all
163164

165+
benchmarks:
166+
name: Benchmarks
167+
runs-on: ubuntu-24.04
168+
timeout-minutes: 20
169+
steps:
170+
- uses: actions/checkout@master
171+
with:
172+
submodules: true
173+
- uses: taiki-e/install-action@cargo-binstall
174+
175+
- name: Set up dependencies
176+
run: |
177+
sudo apt-get update
178+
sudo apt-get install -y valgrind gdb libc6-dbg # Needed for iai-callgrind
179+
rustup update "$BENCHMARK_RUSTC" --no-self-update
180+
rustup default "$BENCHMARK_RUSTC"
181+
# Install the version of iai-callgrind-runner that is specified in Cargo.toml
182+
iai_version="$(cargo metadata --format-version=1 --features icount |
183+
jq -r '.packages[] | select(.name == "iai-callgrind").version')"
184+
cargo binstall -y iai-callgrind-runner --version "$iai_version"
185+
sudo apt-get install valgrind
186+
- uses: Swatinem/rust-cache@v2
187+
188+
- name: Run icount benchmarks
189+
env:
190+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
191+
PR_NUMBER: ${{ github.event.pull_request.number }}
192+
run: ./ci/bench-icount.sh
193+
194+
- name: Upload the benchmark baseline
195+
uses: actions/upload-artifact@v4
196+
with:
197+
name: ${{ env.BASELINE_NAME }}
198+
path: ${{ env.BASELINE_NAME }}.tar.xz
199+
200+
- name: Run wall time benchmarks
201+
run: |
202+
# Always use the same seed for benchmarks. Ideally we should switch to a
203+
# non-random generator.
204+
export LIBM_SEED=benchesbenchesbenchesbencheswoo!
205+
cargo bench --package libm-test \
206+
--no-default-features \
207+
--features short-benchmarks,build-musl,libm/force-soft-floats
208+
209+
- name: Print test logs if available
210+
if: always()
211+
run: if [ -f "target/test-log.txt" ]; then cat target/test-log.txt; fi
212+
shell: bash
213+
164214
miri:
165215
name: Miri
166216
runs-on: ubuntu-24.04
@@ -189,10 +239,11 @@ jobs:
189239

190240
success:
191241
needs:
192-
- test
193-
- rustfmt
242+
- benchmarks
194243
- clippy
195244
- miri
245+
- rustfmt
246+
- test
196247
runs-on: ubuntu-24.04
197248
# GitHub branch protection is exceedingly silly and treats "jobs skipped because a dependency
198249
# failed" as success. So we have to do some contortions to ensure the job fails if any of its
File renamed without changes.
File renamed without changes.

compiler-builtins/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,5 @@ rustc-dep-of-std = ['compiler-builtins', 'core']
7373
public-test-deps = []
7474

7575
[lints.rust]
76-
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(bootstrap)'] }
76+
# The cygwin config can be dropped after our benchmark toolchain is bumped
77+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(bootstrap)', 'cfg(target_os, values("cygwin"))'] }

0 commit comments

Comments
 (0)