Skip to content

Commit

Permalink
Create a composite action for the actual benchmarking
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Dec 18, 2024
1 parent 3f85a61 commit ee9e1a4
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 25 deletions.
File renamed without changes.
51 changes: 51 additions & 0 deletions .github/actions/benchmarker/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: 'Benchmarker'
inputs:
deploy-key:
description: 'Deploy key to use for pushing to the benchmark data repo (ed25519 secret key)'
required: true
bench-repo:
description: 'The benchmarking data repo (ssh clone url)'
required: true
metric-key:
description: 'Unique key for this set of metrics'
required: true
benchmarks:
description: 'The benchmarks to run as a json file'
required: true
outputs:
random-number:
description: "Random number"
value: ${{ steps.random-number-generator.outputs.random-number }}
runs:
using: "composite"
steps:
- name: Fetch previous benchmark results
shell: bash
run: |
mkdir -p ~/.ssh
echo "${{ inputs.deploy-key }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
chmod 700 ~/.ssh
git clone --depth 1 "${{ inputs.bench-repo }}" bench_data
- name: Benchmark
shell: bash
run: |
cd "${{ github.action_path }}" && cargo build --release
"${{ github.action_path }}/target/release/benchmarker" "${{ inputs.benchmarks }}" "bench_data/metrics-${{ inputs.metric-key }}.json" > bench_results.json
- name: Upload benchmark results to artifacts
uses: actions/upload-artifact@v4
with:
name: "benchmark-results-${{ inputs.metric-key }}"
path: bench_results.json
- name: Upload benchmark results to bench repo
if: github.event_name == 'push'
shell: bash
run: |
cd bench_data
git pull # ensure we have the latest state when another job pushed changes while benchmarking
cat ../bench_results.json >> "metrics-${{ inputs.metric-key }}.json"
git add .
git -c user.name="Perf bot" -c [email protected] commit --message 📈
# git pull --rebase in case of a race condition with another job
git push origin main || (git -c user.name="Perf bot" -c [email protected] pull --rebase && git push origin main)
File renamed without changes.
File renamed without changes.
30 changes: 5 additions & 25 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,30 +48,10 @@ jobs:
RUSTFLAGS="-Ctarget-cpu=native -Cllvm-args=-enable-dfa-jump-thread" cargo build --target ${{matrix.target}} -p test-libz-rs-sys --release --examples
cp target/${{matrix.target}}/release/examples/blogpost-compress .
cp target/${{matrix.target}}/release/examples/blogpost-uncompress .
- name: Fetch previous benchmark results
run: |
mkdir -p ~/.ssh
echo "${{ secrets.BENCH_DATA_DEPLOY_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
chmod 700 ~/.ssh
git clone --depth 1 [email protected]:trifectatechfoundation/zlib-rs-bench.git
- name: Benchmark
run: |
cd benchmarker && cargo build --release
benchmarker/target/release/benchmarker zlib_benchmarks.json zlib-rs-bench/metrics-${{matrix.name}}.json > bench_results.json
- name: Upload benchmark results to artifacts
uses: actions/upload-artifact@v4
uses: ./.github/actions/benchmarker
with:
name: "benchmark-results-${{matrix.name}}"
path: bench_results.json
- name: Upload benchmark results to bench repo
if: github.event_name == 'push'
run: |
cd zlib-rs-bench
git pull # ensure we have the latest state when another job pushed changes while benchmarking
cat ../bench_results.json >> metrics-${{matrix.name}}.json
git add .
git -c user.name="Perf bot" -c [email protected] commit --message 📈
# git pull --rebase in case of a race condition with another job
git push origin main || (git -c user.name="Perf bot" -c [email protected] pull --rebase && git push origin main)
deploy-key: "${{ secrets.BENCH_DATA_DEPLOY_KEY }}"
bench-repo: "[email protected]:trifectatechfoundation/zlib-rs-bench.git"
metric-key: "${{ matrix.name }}"
benchmarks: "zlib_benchmarks.json"

0 comments on commit ee9e1a4

Please sign in to comment.