Benchmarks #4
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: Benchmarks | |
| # Runs benchmarks to track performance and detect regressions. | |
| # - On push to main: automatically updates baseline in Bencher | |
| # - On manual dispatch: run specific benchmarks on-demand | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| # Only run benchmarks if relevant code changes | |
| - "src/**" | |
| - "benches/**" | |
| - "Cargo.toml" | |
| - "Cargo.lock" | |
| workflow_dispatch: | |
| inputs: | |
| benchmark: | |
| description: "Benchmark to run" | |
| required: true | |
| default: "all" | |
| type: choice | |
| options: | |
| - all | |
| - historic_scanning | |
| - latest_events_scanning | |
| permissions: | |
| contents: read | |
| checks: write | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| # Run historic benchmarks | |
| benchmark_historic: | |
| name: Run Historic Benchmarks | |
| runs-on: ubuntu-latest | |
| # Run on push to main, or when manually selecting 'all' or 'historic_scanning' | |
| if: ${{ github.event_name == 'push' || inputs.benchmark == 'all' || inputs.benchmark == 'historic_scanning' }} | |
| steps: | |
| - name: Harden the runner (Audit all outbound calls) | |
| uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0 | |
| with: | |
| egress-policy: audit | |
| - name: Checkout repository | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 | |
| - name: Install Rust toolchain | |
| uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2 | |
| - name: Install Foundry (Anvil) | |
| uses: foundry-rs/foundry-toolchain@8b0419c685ef46cb79ec93fbdc131174afceb730 # v1.6.0 | |
| - name: Install Bencher CLI | |
| uses: bencherdev/bencher@2f1532643adc0e69e52acaec936d227ff14da24f # v0.5.9 | |
| - name: Decompress benchmark state dumps | |
| run: | | |
| echo "Decompressing Anvil state dumps..." | |
| gunzip -k benches/dumps/*.json.gz | |
| ls -lh benches/dumps/ | |
| - name: Run historic benchmarks and track with Bencher | |
| env: | |
| BENCHER_API_TOKEN: ${{ secrets.BENCHER_API_TOKEN }} | |
| BENCHER_PROJECT: ${{ vars.BENCHER_PROJECT }} | |
| run: | | |
| bencher run \ | |
| --project "$BENCHER_PROJECT" \ | |
| --token "$BENCHER_API_TOKEN" \ | |
| --branch main \ | |
| --testbed ubuntu-latest \ | |
| --threshold-measure latency \ | |
| --threshold-test t_test \ | |
| --threshold-max-sample-size 64 \ | |
| --threshold-upper-boundary 0.99 \ | |
| --thresholds-reset \ | |
| --err \ | |
| --adapter rust_criterion \ | |
| --github-actions "${{ secrets.GITHUB_TOKEN }}" \ | |
| "cargo bench --manifest-path benches/Cargo.toml --bench historic_scanning" | |
| # Run latest events benchmarks | |
| benchmark_latest: | |
| name: Run Latest Events Benchmarks | |
| runs-on: ubuntu-latest | |
| # Run on push to main, or when manually selecting 'all' or 'latest_events_scanning' | |
| if: ${{ github.event_name == 'push' || inputs.benchmark == 'all' || inputs.benchmark == 'latest_events_scanning' }} | |
| steps: | |
| - name: Harden the runner (Audit all outbound calls) | |
| uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0 | |
| with: | |
| egress-policy: audit | |
| - name: Checkout repository | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 | |
| - name: Install Rust toolchain | |
| uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2 | |
| - name: Install Foundry (Anvil) | |
| uses: foundry-rs/foundry-toolchain@8b0419c685ef46cb79ec93fbdc131174afceb730 # v1.6.0 | |
| - name: Install Bencher CLI | |
| uses: bencherdev/bencher@2f1532643adc0e69e52acaec936d227ff14da24f # v0.5.9 | |
| - name: Decompress benchmark state dumps | |
| run: | | |
| echo "Decompressing Anvil state dumps..." | |
| gunzip -k benches/dumps/*.json.gz | |
| ls -lh benches/dumps/ | |
| - name: Run latest events benchmarks and track with Bencher | |
| env: | |
| BENCHER_API_TOKEN: ${{ secrets.BENCHER_API_TOKEN }} | |
| BENCHER_PROJECT: ${{ vars.BENCHER_PROJECT }} | |
| run: | | |
| bencher run \ | |
| --project "$BENCHER_PROJECT" \ | |
| --token "$BENCHER_API_TOKEN" \ | |
| --branch main \ | |
| --testbed ubuntu-latest \ | |
| --threshold-measure latency \ | |
| --threshold-test t_test \ | |
| --threshold-max-sample-size 64 \ | |
| --threshold-upper-boundary 0.99 \ | |
| --thresholds-reset \ | |
| --err \ | |
| --adapter rust_criterion \ | |
| --github-actions "${{ secrets.GITHUB_TOKEN }}" \ | |
| "cargo bench --manifest-path benches/Cargo.toml --bench latest_events_scanning" |