138 lines
4.3 KiB
YAML
138 lines
4.3 KiB
YAML
name: Reusable Bench
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
CONCURRENCY:
|
|
required: true
|
|
type: string
|
|
SAVE_BENCHES:
|
|
required: false
|
|
type: boolean
|
|
default: false
|
|
BENCH_NAME:
|
|
required: false
|
|
type: string
|
|
default: ""
|
|
COMPARE_TO:
|
|
required: false
|
|
type: string
|
|
default: ""
|
|
|
|
concurrency:
|
|
group: ${{ inputs.CONCURRENCY }}-bench
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
PYTHON_VERSION: "3.10"
|
|
|
|
RUSTFLAGS: --deny warnings
|
|
RUSTDOCFLAGS: --deny warnings
|
|
|
|
defaults:
|
|
run:
|
|
shell: bash --noprofile --norc -euo pipefail {0}
|
|
|
|
permissions:
|
|
# contents permission to update benchmark contents in gh-pages branch
|
|
contents: write
|
|
id-token: "write"
|
|
# deployments permission to deploy GitHub pages website
|
|
deployments: write
|
|
|
|
jobs:
|
|
# ---------------------------------------------------------------------------
|
|
|
|
rs-benchmarks:
|
|
name: Rust Criterion benchmarks
|
|
timeout-minutes: 60
|
|
runs-on: ubuntu-latest-16-cores
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0 # we need full history
|
|
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || '' }}
|
|
|
|
- name: Set up Rust
|
|
uses: ./.github/actions/setup-rust
|
|
with:
|
|
cache_key: "build-linux"
|
|
# Cache will be produced by `reusable_checks/rs-lints`
|
|
save_cache: false
|
|
workload_identity_provider: ${{ secrets.GOOGLE_WORKLOAD_IDENTITY_PROVIDER }}
|
|
service_account: ${{ secrets.GOOGLE_SERVICE_ACCOUNT }}
|
|
|
|
- uses: prefix-dev/setup-pixi@v0.10.0
|
|
with:
|
|
pixi-version: v0.71.3
|
|
|
|
- name: Add SHORT_SHA env property with commit short sha
|
|
run: echo "SHORT_SHA=`echo ${{github.sha}} | cut -c1-7`" >> $GITHUB_ENV
|
|
|
|
- name: Run benchmark
|
|
# Use bash shell so we get pipefail behavior with tee
|
|
# Running under `pixi` so we get `nasm`
|
|
run: |
|
|
pixi run cargo bench \
|
|
--all-features \
|
|
-p re_entity_db \
|
|
-p re_log_encoding \
|
|
-p re_query \
|
|
-p re_tuid \
|
|
-p re_video \
|
|
-- --output-format=bencher | tee /tmp/${{ env.SHORT_SHA }}
|
|
|
|
- name: "Set up Cloud SDK"
|
|
uses: "google-github-actions/setup-gcloud@v2"
|
|
with:
|
|
version: ">= 363.0.0"
|
|
|
|
# TODO(jleibs) make this whole thing a python script
|
|
- name: "Upload bench to GCS based on SHA"
|
|
uses: google-github-actions/upload-cloud-storage@v3
|
|
with:
|
|
path: /tmp/${{ env.SHORT_SHA }}
|
|
destination: "rerun-builds/benches/"
|
|
process_gcloudignore: false
|
|
|
|
- name: Download comparison bench from GCS
|
|
if: ${{ inputs.COMPARE_TO != '' }}
|
|
run: |
|
|
mkdir /tmp/compare/
|
|
gsutil cp gs://rerun-builds/benches/${{inputs.COMPARE_TO}} /tmp/compare/${{ inputs.COMPARE_TO }}
|
|
|
|
- name: Install cargo-benchcmp
|
|
run: pixi run cargo install cargo-benchcmp
|
|
|
|
- name: Compare results with benchcmp
|
|
if: ${{ inputs.COMPARE_TO != '' }}
|
|
run: pixi run cargo benchcmp /tmp/compare/${{ inputs.COMPARE_TO }} /tmp/${{ env.SHORT_SHA }} > /tmp/bench_results.txt
|
|
|
|
- name: "Upload bench-results to GCS"
|
|
if: ${{ inputs.COMPARE_TO != '' }}
|
|
uses: google-github-actions/upload-cloud-storage@v3
|
|
with:
|
|
path: /tmp/bench_results.txt
|
|
destination: "rerun-builds/commit/${{env.SHORT_SHA}}/"
|
|
process_gcloudignore: false
|
|
|
|
- name: "Copy bench to named file"
|
|
if: ${{ inputs.BENCH_NAME != '' }}
|
|
run: cp /tmp/${{ env.SHORT_SHA }} /tmp/${{ inputs.BENCH_NAME }}
|
|
|
|
# Don't upload the new named bench until the end in case the names are the same
|
|
- name: "Upload named bench to GCS"
|
|
if: ${{ inputs.BENCH_NAME != '' }}
|
|
uses: google-github-actions/upload-cloud-storage@v3
|
|
with:
|
|
path: /tmp/${{ inputs.BENCH_NAME }}
|
|
destination: "rerun-builds/benches/"
|
|
process_gcloudignore: false
|
|
|
|
- name: Render benchmark result
|
|
if: github.ref == 'refs/heads/main'
|
|
run: |
|
|
pixi run python scripts/ci/render_bench.py crates \
|
|
--after $(date -d"30 days ago" +%Y-%m-%d) \
|
|
--output "gs://rerun-builds/graphs"
|