From e79aa4eb91ff134b225c6fde42d6ba5e268ae482 Mon Sep 17 00:00:00 2001 From: Dan Draper Date: Sat, 2 May 2026 11:25:48 +1000 Subject: [PATCH] ci: add manual `bench` workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds `.github/workflows/bench.yml` for on-demand benchmark runs on the GitHub Actions Ubuntu x86_64 runner. Trigger via the Actions tab or `gh workflow run bench --ref `. The shared runner produces noisy numbers (~5–15% variance) so this isn't a regression gate, but it's useful for: - First-pass validation that the x86 SSE path actually beats scalar before we invest in dedicated benchmarking hardware. - Relative `base85` vs `base85-simd` comparison on the same silicon (noise mostly cancels). Workflow steps: - Print CPU model + available SIMD feature flags from /proc/cpuinfo. - Install stable Rust + Swatinem/rust-cache@v2. - `cargo bench --bench encode --locked` with output captured. - Print a `time:` summary at the end of the log. - Upload `bench-output.txt` and the full criterion HTML report (`target/criterion/`) as a 30-day artifact. Manual-only (`workflow_dispatch`) so it doesn't run on every PR (the bench takes ~5–10 min and we don't gate on its numbers). --- .github/workflows/bench.yml | 69 +++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/bench.yml diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml new file mode 100644 index 0000000..70ce797 --- /dev/null +++ b/.github/workflows/bench.yml @@ -0,0 +1,69 @@ +name: bench + +# Manual-only trigger. Bench numbers from a shared GitHub Actions runner +# are noisy (~5–15% variance), but useful for relative comparison between +# `base85` and `base85-simd` on the same hardware, and for first-pass +# validation that an x86 SIMD path actually beats scalar without needing +# dedicated metal. +# +# Run via: +# gh workflow run bench --ref +# or from the Actions tab in the GitHub UI. + +on: + workflow_dispatch: + inputs: + ref: + description: "Git ref to bench (defaults to the workflow's ref)" + required: false + default: "" + +permissions: + contents: read + +jobs: + bench: + name: cargo bench (ubuntu x86_64) + runs-on: ubuntu-latest + timeout-minutes: 30 + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref || github.ref }} + + - name: Hardware / feature inventory + run: | + echo "=== CPU ===" + lscpu | grep -E "^(Model name|Vendor ID|CPU\(s\)|CPU max MHz|CPU MHz|Caches|L[123])" || true + echo + echo "=== SIMD features available ===" + grep -oE '\b(sse[0-9._]*|ssse3|avx[0-9_]*)\b' /proc/cpuinfo \ + | sort -u | tr '\n' ' ' + echo + + - name: Install Rust stable + uses: dtolnay/rust-toolchain@stable + + - uses: Swatinem/rust-cache@v2 + + - name: cargo bench + run: cargo bench --bench encode --locked 2>&1 | tee bench-output.txt + + - name: Summary table + if: always() + run: | + echo "## Encode/decode timings" + grep -E '^(encode|decode)/(base85|base85_simd)/' bench-output.txt \ + | grep 'time:' || true + + - name: Upload raw output + criterion HTML report + if: always() + uses: actions/upload-artifact@v4 + with: + name: bench-results + path: | + bench-output.txt + target/criterion/ + if-no-files-found: error + retention-days: 30