Repository navigation
chore(main): release bindings 0.16.0 #1726
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Bench | |
| # Proves keccak_gkr's hash batch at a PR's merge commit and at its base (the merge commit's first | |
| # parent) in turns on one runner, so the comparison is free of which machine the job landed | |
| # on: each job builds both sides and runs them `ROUNDS` times in the order base, PR, PR, | |
| # base, ... It saves its runs as the artifact `ab-<testbed>-<benchmark>`, and | |
| # bench-comment.yml posts what changed on the PR. It gates nothing. | |
| # | |
| # The testbeds are GitHub-hosted runners, forks' PRs included. Each pins its ISA: | |
| # `target-cpu=native` would build for whichever CPU the job lands on, and a cached build then | |
| # dies of SIGILL on an older one (see rust.yml). | |
| on: | |
| pull_request: | |
| # Not `edited`: a description edit would restart, and so cancel, the PR's run. | |
| types: [ opened, reopened, synchronize ] | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: bench-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| CARGO_TERM_COLOR: always | |
| RUST_BACKTRACE: 1 | |
| ROUNDS: 5 | |
| jobs: | |
| ab: | |
| name: ${{ matrix.benchmark }} (${{ matrix.testbed.name }}) | |
| runs-on: ${{ matrix.testbed.runner }} | |
| timeout-minutes: 60 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| testbed: | |
| - name: x86-64 | |
| runner: ubuntu-latest | |
| rustflags: -C target-cpu=haswell | |
| # The NEON kernels, which are chosen at compile time on `aes` (PMULL) and `sha3` | |
| # (EOR3), neither of which a generic aarch64 target enables. | |
| - name: arm64 | |
| runner: ubuntu-24.04-arm | |
| rustflags: -C target-cpu=neoverse-n2 -C target-feature=+aes,+sha3 | |
| benchmark: [ keccak-hash-batch-262144 ] | |
| env: | |
| RUSTFLAGS: ${{ matrix.testbed.rustflags }} | |
| KECCAK_N_LOG: 18 | |
| BENCH_REPEAT: 1 | |
| BENCH_COOLDOWN: 0 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| # The merge commit and its first parent, the base. | |
| fetch-depth: 2 | |
| - uses: dtolnay/rust-toolchain@stable | |
| # The CPU the testbed's ISA is pinned for must have what it enables, or it dies of SIGILL. | |
| - name: CPU features | |
| if: runner.os == 'Linux' && runner.arch == 'ARM64' | |
| run: | | |
| grep -m1 -E '^Features' /proc/cpuinfo | |
| for f in aes pmull sha3 sve2; do grep -qw "$f" <(grep -m1 -E '^Features' /proc/cpuinfo) || { echo "::error::no $f on this runner"; exit 1; }; done | |
| # One cache per testbed; RUSTFLAGS is part of its key. | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: ${{ matrix.testbed.name }} | |
| # A base without the bench (the PR that adds it) has nothing to compare: the job then | |
| # builds the PR alone, so a broken bench still fails it, and saves no runs. | |
| - name: Build the PR and its base | |
| id: build | |
| run: | | |
| # The experimental prover's Keccak GKR, named `keccak_gkr` before the provers split. | |
| package() { | |
| cargo metadata --no-deps --format-version 1 \ | |
| | jq -r '[.packages[] | select(.name == "experimental_keccak_gkr" or .name == "keccak_gkr") | select(any(.targets[]; .name == "hash_batch")) | .name] | first // empty' | |
| } | |
| build() { | |
| mkdir -p "ab/$1" | |
| exe=$(cargo bench -p "$(package)" --bench hash_batch --no-run --message-format=json \ | |
| | jq -r 'select(.reason == "compiler-artifact" and .target.name == "hash_batch") | .executable') | |
| cp "$exe" "ab/$1/bench" | |
| } | |
| build head | |
| git checkout --quiet --detach HEAD^1 | |
| if [ -n "$(package)" ]; then | |
| build base | |
| echo "compare=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "::notice::The base has no keccak_gkr hash_batch bench, so there is nothing to compare." | |
| echo "compare=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| git checkout --quiet --detach "$GITHUB_SHA" | |
| - name: Prove in turns | |
| if: steps.build.outputs.compare == 'true' | |
| run: | | |
| for round in $(seq "$ROUNDS"); do | |
| if [ $((round % 2)) = 1 ]; then order="base head"; else order="head base"; fi | |
| for side in $order; do | |
| "ab/$side/bench" --json > result.json | |
| jq -c --argjson round "$round" --arg side "$side" '{round: $round, side: $side, results: .}' result.json | tee -a runs.jsonl | |
| done | |
| done | |
| - name: Save the runs | |
| if: steps.build.outputs.compare == 'true' | |
| env: | |
| PR: ${{ github.event.number }} | |
| TESTBED: ${{ matrix.testbed.name }} | |
| run: | | |
| cpu=$(lscpu | sed -n 's/^Model name: *//p' | head -n1) | |
| jq -n --argjson pr "$PR" --arg base "$(git rev-parse HEAD^1)" --arg testbed "$TESTBED" --arg cpu "$cpu" \ | |
| --slurpfile runs runs.jsonl '{pr: $pr, base: $base, testbed: $testbed, cpu: $cpu, runs: $runs}' > ab.json | |
| - uses: actions/upload-artifact@v4 | |
| if: steps.build.outputs.compare == 'true' | |
| with: | |
| name: ab-${{ matrix.testbed.name }}-${{ matrix.benchmark }} | |
| path: ab.json |