|
| 1 | +# Continuous benchmarking with Bencher (https://bencher.dev) |
| 2 | +# |
| 3 | +# PREREQUISITES: |
| 4 | +# 1. Create a project at https://bencher.dev and note its slug. |
| 5 | +# 2. Add the following secrets in GitHub → Settings → Secrets and variables → Actions: |
| 6 | +# - BENCHER_API_TOKEN: API token from bencher.dev |
| 7 | +# - BENCHER_PROJECT: your project slug |
| 8 | +# 3. GITHUB_TOKEN is provided automatically — no setup needed. |
| 9 | +# |
| 10 | +# overhead_bench uses a custom harness (not Criterion). Its --bmf flag |
| 11 | +# outputs Bencher Metric Format directly. |
| 12 | + |
| 13 | +name: Benchmarks |
| 14 | + |
| 15 | +on: |
| 16 | + push: |
| 17 | + branches: |
| 18 | + - main |
| 19 | + pull_request: |
| 20 | + workflow_dispatch: |
| 21 | + |
| 22 | +permissions: |
| 23 | + checks: write |
| 24 | + pull-requests: write |
| 25 | + |
| 26 | +jobs: |
| 27 | + # Runs on every push to main to build the statistical baseline. |
| 28 | + benchmark_main: |
| 29 | + name: Benchmark (main baseline) |
| 30 | + if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' |
| 31 | + runs-on: ubuntu-latest |
| 32 | + timeout-minutes: 30 |
| 33 | + env: |
| 34 | + RUST_BACKTRACE: 1 |
| 35 | + BENCHER_PROJECT: ${{ secrets.BENCHER_PROJECT }} |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@v4 |
| 38 | + - uses: dtolnay/rust-toolchain@stable |
| 39 | + - uses: Swatinem/rust-cache@v2 |
| 40 | + |
| 41 | + - name: Enable perf_event_open and kallsyms |
| 42 | + run: | |
| 43 | + sudo sysctl kernel.perf_event_paranoid=1 |
| 44 | + sudo sysctl kernel.kptr_restrict=0 |
| 45 | +
|
| 46 | + - uses: bencherdev/bencher@main |
| 47 | + |
| 48 | + - name: Benchmark — poll_overhead |
| 49 | + run: | |
| 50 | + bencher run \ |
| 51 | + --token '${{ secrets.BENCHER_API_TOKEN }}' \ |
| 52 | + --branch '${{ github.ref_name }}' \ |
| 53 | + --testbed ubuntu-latest \ |
| 54 | + --adapter rust_criterion \ |
| 55 | + "cargo bench --package dial9-tokio-telemetry --bench poll_overhead --features task-dump" |
| 56 | +
|
| 57 | + - name: Benchmark — writer_encode |
| 58 | + run: | |
| 59 | + bencher run \ |
| 60 | + --token '${{ secrets.BENCHER_API_TOKEN }}' \ |
| 61 | + --branch '${{ github.ref_name }}' \ |
| 62 | + --testbed ubuntu-latest \ |
| 63 | + --adapter rust_criterion \ |
| 64 | + "cargo bench --package dial9-tokio-telemetry --bench writer_encode" |
| 65 | +
|
| 66 | + - name: Benchmark — codec |
| 67 | + run: | |
| 68 | + bencher run \ |
| 69 | + --token '${{ secrets.BENCHER_API_TOKEN }}' \ |
| 70 | + --branch '${{ github.ref_name }}' \ |
| 71 | + --testbed ubuntu-latest \ |
| 72 | + --adapter rust_criterion \ |
| 73 | + "cargo bench --package dial9-trace-format --bench codec" |
| 74 | +
|
| 75 | + - name: Benchmark — overhead_bench |
| 76 | + run: | |
| 77 | + bencher run \ |
| 78 | + --token '${{ secrets.BENCHER_API_TOKEN }}' \ |
| 79 | + --branch '${{ github.ref_name }}' \ |
| 80 | + --testbed ubuntu-latest \ |
| 81 | + --adapter json \ |
| 82 | + "cargo bench --bench overhead_bench -- --bmf 10" |
| 83 | +
|
| 84 | + - name: Benchmark — e2e_workload |
| 85 | + run: | |
| 86 | + bencher run \ |
| 87 | + --token '${{ secrets.BENCHER_API_TOKEN }}' \ |
| 88 | + --branch '${{ github.ref_name }}' \ |
| 89 | + --testbed ubuntu-latest \ |
| 90 | + --adapter json \ |
| 91 | + "cargo bench --bench e2e_workload -- --bmf 10" |
| 92 | +
|
| 93 | + # Runs on same-repo PRs. Fork PRs are skipped — they have no access to |
| 94 | + # BENCHER_API_TOKEN, so the job would fail rather than silently skip. |
| 95 | + benchmark_pr: |
| 96 | + name: Benchmark (PR regression check) |
| 97 | + if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository |
| 98 | + runs-on: ubuntu-latest |
| 99 | + timeout-minutes: 30 |
| 100 | + env: |
| 101 | + RUST_BACKTRACE: 1 |
| 102 | + BENCHER_PROJECT: ${{ secrets.BENCHER_PROJECT }} |
| 103 | + steps: |
| 104 | + - uses: actions/checkout@v4 |
| 105 | + - uses: dtolnay/rust-toolchain@stable |
| 106 | + - uses: Swatinem/rust-cache@v2 |
| 107 | + |
| 108 | + - name: Enable perf_event_open and kallsyms |
| 109 | + run: | |
| 110 | + sudo sysctl kernel.perf_event_paranoid=1 |
| 111 | + sudo sysctl kernel.kptr_restrict=0 |
| 112 | +
|
| 113 | + - uses: bencherdev/bencher@main |
| 114 | + |
| 115 | + - name: Benchmark — poll_overhead |
| 116 | + run: | |
| 117 | + bencher run \ |
| 118 | + --token '${{ secrets.BENCHER_API_TOKEN }}' \ |
| 119 | + --branch '${{ github.head_ref }}' \ |
| 120 | + --start-point main \ |
| 121 | + --start-point-reset \ |
| 122 | + --testbed ubuntu-latest \ |
| 123 | + --adapter rust_criterion \ |
| 124 | + --threshold-measure latency \ |
| 125 | + --threshold-test percentage \ |
| 126 | + --threshold-upper-boundary 0.25 \ |
| 127 | + --threshold-measure throughput \ |
| 128 | + --threshold-test percentage \ |
| 129 | + --threshold-lower-boundary 0.25 \ |
| 130 | + --error-on-alert \ |
| 131 | + --github-actions '${{ secrets.GITHUB_TOKEN }}' \ |
| 132 | + "cargo bench --package dial9-tokio-telemetry --bench poll_overhead --features task-dump" |
| 133 | +
|
| 134 | + - name: Benchmark — writer_encode |
| 135 | + run: | |
| 136 | + bencher run \ |
| 137 | + --token '${{ secrets.BENCHER_API_TOKEN }}' \ |
| 138 | + --branch '${{ github.head_ref }}' \ |
| 139 | + --start-point main \ |
| 140 | + --start-point-reset \ |
| 141 | + --testbed ubuntu-latest \ |
| 142 | + --adapter rust_criterion \ |
| 143 | + --threshold-measure latency \ |
| 144 | + --threshold-test percentage \ |
| 145 | + --threshold-upper-boundary 0.25 \ |
| 146 | + --threshold-measure throughput \ |
| 147 | + --threshold-test percentage \ |
| 148 | + --threshold-lower-boundary 0.25 \ |
| 149 | + --error-on-alert \ |
| 150 | + --github-actions '${{ secrets.GITHUB_TOKEN }}' \ |
| 151 | + "cargo bench --package dial9-tokio-telemetry --bench writer_encode" |
| 152 | +
|
| 153 | + - name: Benchmark — codec |
| 154 | + run: | |
| 155 | + bencher run \ |
| 156 | + --token '${{ secrets.BENCHER_API_TOKEN }}' \ |
| 157 | + --branch '${{ github.head_ref }}' \ |
| 158 | + --start-point main \ |
| 159 | + --start-point-reset \ |
| 160 | + --testbed ubuntu-latest \ |
| 161 | + --adapter rust_criterion \ |
| 162 | + --threshold-measure latency \ |
| 163 | + --threshold-test percentage \ |
| 164 | + --threshold-upper-boundary 0.25 \ |
| 165 | + --threshold-measure throughput \ |
| 166 | + --threshold-test percentage \ |
| 167 | + --threshold-lower-boundary 0.25 \ |
| 168 | + --error-on-alert \ |
| 169 | + --github-actions '${{ secrets.GITHUB_TOKEN }}' \ |
| 170 | + "cargo bench --package dial9-trace-format --bench codec" |
| 171 | +
|
| 172 | + - name: Benchmark — overhead_bench |
| 173 | + run: | |
| 174 | + bencher run \ |
| 175 | + --token '${{ secrets.BENCHER_API_TOKEN }}' \ |
| 176 | + --branch '${{ github.head_ref }}' \ |
| 177 | + --start-point main \ |
| 178 | + --start-point-reset \ |
| 179 | + --testbed ubuntu-latest \ |
| 180 | + --adapter json \ |
| 181 | + --threshold-measure latency \ |
| 182 | + --threshold-test percentage \ |
| 183 | + --threshold-upper-boundary 0.25 \ |
| 184 | + --threshold-measure throughput \ |
| 185 | + --threshold-test percentage \ |
| 186 | + --threshold-lower-boundary 0.25 \ |
| 187 | + --error-on-alert \ |
| 188 | + --github-actions '${{ secrets.GITHUB_TOKEN }}' \ |
| 189 | + "cargo bench --bench overhead_bench -- --bmf 10" |
| 190 | +
|
| 191 | + - name: Benchmark — e2e_workload |
| 192 | + run: | |
| 193 | + bencher run \ |
| 194 | + --token '${{ secrets.BENCHER_API_TOKEN }}' \ |
| 195 | + --branch '${{ github.head_ref }}' \ |
| 196 | + --start-point main \ |
| 197 | + --start-point-reset \ |
| 198 | + --testbed ubuntu-latest \ |
| 199 | + --adapter json \ |
| 200 | + --threshold-measure latency \ |
| 201 | + --threshold-test percentage \ |
| 202 | + --threshold-upper-boundary 0.25 \ |
| 203 | + --threshold-measure throughput \ |
| 204 | + --threshold-test percentage \ |
| 205 | + --threshold-lower-boundary 0.25 \ |
| 206 | + --error-on-alert \ |
| 207 | + --github-actions '${{ secrets.GITHUB_TOKEN }}' \ |
| 208 | + "cargo bench --bench e2e_workload -- --bmf 10" |
0 commit comments