about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTrevor Gross <tmgross@umich.edu>2025-04-20 03:28:17 +0000
committerTrevor Gross <t.gross35@gmail.com>2025-04-20 00:58:50 -0400
commit0d0d3172424cfc4386976d35fc1ce7710a07d1eb (patch)
tree64e3cb963b163bcca82a2053c807fec3f70b313e
parent141c7b06c416e123ec4c6785c104785987cbe894 (diff)
downloadrust-0d0d3172424cfc4386976d35fc1ce7710a07d1eb.tar.gz
rust-0d0d3172424cfc4386976d35fc1ce7710a07d1eb.zip
Enable icount benchmarks in CI
-rw-r--r--library/compiler-builtins/.github/workflows/main.yaml55
-rwxr-xr-xlibrary/compiler-builtins/ci/bench-icount.sh (renamed from library/compiler-builtins/etc/libm/ci/bench-icount.sh)0
-rwxr-xr-xlibrary/compiler-builtins/ci/ci-util.py (renamed from library/compiler-builtins/etc/libm/ci/ci-util.py)0
-rw-r--r--library/compiler-builtins/compiler-builtins/Cargo.toml3
4 files changed, 55 insertions, 3 deletions
diff --git a/library/compiler-builtins/.github/workflows/main.yaml b/library/compiler-builtins/.github/workflows/main.yaml
index eec747a2436..54cfd506e83 100644
--- a/library/compiler-builtins/.github/workflows/main.yaml
+++ b/library/compiler-builtins/.github/workflows/main.yaml
@@ -13,6 +13,7 @@ env:
   RUSTDOCFLAGS: -Dwarnings
   RUSTFLAGS: -Dwarnings
   RUST_BACKTRACE: full
+  BENCHMARK_RUSTC: nightly-2025-01-16 # Pin the toolchain for reproducable results
 
 jobs:
   test:
@@ -161,6 +162,55 @@ jobs:
     - uses: Swatinem/rust-cache@v2
     - run: cargo clippy -- -D clippy::all
 
+  benchmarks:
+    name: Benchmarks
+    runs-on: ubuntu-24.04
+    timeout-minutes: 20
+    steps:
+    - uses: actions/checkout@master
+      with:
+        submodules: true
+    - uses: taiki-e/install-action@cargo-binstall
+
+    - name: Set up dependencies
+      run: |
+        sudo apt-get update
+        sudo apt-get install -y valgrind gdb libc6-dbg # Needed for iai-callgrind
+        rustup update "$BENCHMARK_RUSTC" --no-self-update
+        rustup default "$BENCHMARK_RUSTC"
+        # Install the version of iai-callgrind-runner that is specified in Cargo.toml
+        iai_version="$(cargo metadata --format-version=1 --features icount |
+           jq -r '.packages[] | select(.name == "iai-callgrind").version')"
+        cargo binstall -y iai-callgrind-runner --version "$iai_version"
+        sudo apt-get install valgrind
+    - uses: Swatinem/rust-cache@v2
+
+    - name: Run icount benchmarks
+      env:
+        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        PR_NUMBER: ${{ github.event.pull_request.number }}
+      run: ./ci/bench-icount.sh
+
+    - name: Upload the benchmark baseline
+      uses: actions/upload-artifact@v4
+      with:
+        name: ${{ env.BASELINE_NAME }}
+        path: ${{ env.BASELINE_NAME }}.tar.xz
+    
+    - name: Run wall time benchmarks
+      run: |
+        # Always use the same seed for benchmarks. Ideally we should switch to a
+        # non-random generator.
+        export LIBM_SEED=benchesbenchesbenchesbencheswoo!
+        cargo bench --package libm-test \
+          --no-default-features \
+          --features short-benchmarks,build-musl,libm/force-soft-floats
+
+    - name: Print test logs if available
+      if: always()
+      run: if [ -f "target/test-log.txt" ]; then cat target/test-log.txt; fi
+      shell: bash
+
   miri:
     name: Miri
     runs-on: ubuntu-24.04
@@ -189,10 +239,11 @@ jobs:
 
   success:
     needs:
-      - test
-      - rustfmt
+      - benchmarks
       - clippy
       - miri
+      - rustfmt
+      - test
     runs-on: ubuntu-24.04
     # GitHub branch protection is exceedingly silly and treats "jobs skipped because a dependency
     # failed" as success. So we have to do some contortions to ensure the job fails if any of its
diff --git a/library/compiler-builtins/etc/libm/ci/bench-icount.sh b/library/compiler-builtins/ci/bench-icount.sh
index 4d93e257a6c..4d93e257a6c 100755
--- a/library/compiler-builtins/etc/libm/ci/bench-icount.sh
+++ b/library/compiler-builtins/ci/bench-icount.sh
diff --git a/library/compiler-builtins/etc/libm/ci/ci-util.py b/library/compiler-builtins/ci/ci-util.py
index d9e402d6bd7..d9e402d6bd7 100755
--- a/library/compiler-builtins/etc/libm/ci/ci-util.py
+++ b/library/compiler-builtins/ci/ci-util.py
diff --git a/library/compiler-builtins/compiler-builtins/Cargo.toml b/library/compiler-builtins/compiler-builtins/Cargo.toml
index c9503bbce8e..a014baf040a 100644
--- a/library/compiler-builtins/compiler-builtins/Cargo.toml
+++ b/library/compiler-builtins/compiler-builtins/Cargo.toml
@@ -73,4 +73,5 @@ rustc-dep-of-std = ['compiler-builtins', 'core']
 public-test-deps = []
 
 [lints.rust]
-unexpected_cfgs = { level = "warn", check-cfg = ['cfg(bootstrap)'] }
+# The cygwin config can be dropped after our benchmark toolchain is bumped
+unexpected_cfgs = { level = "warn", check-cfg = ['cfg(bootstrap)', 'cfg(target_os, values("cygwin"))'] }