Skip to content

Commit 9df514b

Browse files
committed
ci: optimize benchmark workflow with shared cache
- Add Rust cache sharing with other Linux workflows using shared-key - Use same runner (ubuntu-latest-8-cores) as test workflows for cache reuse - Switch to dtolnay/rust-toolchain for consistency with other workflows - Add build step to warm cache before running benchmarks - Enable cache-targets and cache-all-crates for comprehensive caching This allows the benchmark workflow to reuse cached dependencies from test runs and vice versa, significantly reducing CI build times.
1 parent 2fcfdf2 commit 9df514b

1 file changed

Lines changed: 24 additions & 6 deletions

File tree

.github/workflows/benchmark.yml

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,41 @@ name: Benchmarks
33
on:
44
workflow_dispatch:
55
pull_request:
6-
branches:
7-
# workflow dispatch cannot be triggered off the main branch,
8-
# so we have this one execption
9-
- bench
6+
branches: [main]
7+
paths:
8+
- 'src/rules/**'
9+
- 'benches/**'
10+
- '.github/workflows/benchmark.yml'
11+
12+
env:
13+
CARGO_TERM_COLOR: always
14+
RUST_BACKTRACE: 1
1015

1116
jobs:
1217
benchmark:
13-
runs-on: ubuntu-latest
18+
runs-on: ubuntu-latest-8-cores
1419

1520
steps:
1621
- uses: actions/checkout@v4
1722

1823
- name: Install Rust
19-
uses: actions-rust-lang/setup-rust-toolchain@v1
24+
uses: dtolnay/rust-toolchain@stable
2025
with:
2126
toolchain: stable
2227

28+
- name: Setup Rust cache
29+
uses: Swatinem/rust-cache@v2
30+
with:
31+
shared-key: ${{ runner.os }}
32+
# Share cache with other Linux workflows
33+
cache-on-failure: true
34+
# Cache benchmark-specific dependencies
35+
cache-targets: true
36+
cache-all-crates: true
37+
38+
- name: Build benchmarks first (populates cache)
39+
run: cargo build --release --bench rule_engines
40+
2341
- name: Run benchmarks
2442
run: cargo bench --bench rule_engines
2543

0 commit comments

Comments
 (0)