Skip to content

Commit 7fdd44a

Browse files
authored
ci: parallelize benchmark tests across 3 runners (#54)
* ci: parallelize benchmark tests across 3 runners Split the single Benchmark Tests job into a matrix of 3 parallel jobs, one per package (controller, metrics, recommendation). This reduces wall-clock time from ~10 minutes (sum of all) to ~max(controller), roughly a 2-3x speedup. Each shard maintains its own baseline cache for benchstat comparison. Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca> * ci: split controller benchmarks into core and scale shards Further split the controller benchmark shard (8m41s) into two parallel jobs using -bench regex filtering: - controller-core: fast benchmarks (BuildPrometheusQuery, Reconcile, ComputeRecommendations) -- ~1 min expected - controller-scale: scale benchmarks (ManyWorkloads, ManyPolicies, ConcurrentPolicies up to 1000) -- the heavy tail Total shards: 4 (controller-core, controller-scale, metrics, recommendation) Expected wall-clock: max(controller-scale) instead of sum(all). Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca> --------- Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
1 parent ef8cc5c commit 7fdd44a

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,27 @@ jobs:
300300
fail_ci_if_error: false
301301

302302
test-bench:
303-
name: Benchmark Tests
303+
name: Benchmark Tests (${{ matrix.pkg }})
304304
runs-on: ${{ vars.RUNNER || 'ubuntu-latest' }}
305305
timeout-minutes: 15
306306
needs: changes
307307
if: needs.changes.outputs.go == 'true'
308+
strategy:
309+
fail-fast: false
310+
matrix:
311+
include:
312+
- pkg: controller-core
313+
path: ./internal/controller/...
314+
bench: '^Benchmark(BuildPrometheusQuery|Reconcile$|ComputeRecommendations)'
315+
- pkg: controller-scale
316+
path: ./internal/controller/...
317+
bench: '^BenchmarkReconcile_(Many|Concurrent)'
318+
- pkg: metrics
319+
path: ./internal/metrics/...
320+
bench: '.'
321+
- pkg: recommendation
322+
path: ./internal/recommendation/...
323+
bench: '.'
308324
steps:
309325
- uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
310326
with:
@@ -324,13 +340,13 @@ jobs:
324340
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
325341
with:
326342
path: bench-baseline.txt
327-
key: bench-baseline-${{ runner.os }}-${{ hashFiles('go.sum') }}
328-
restore-keys: bench-baseline-${{ runner.os }}-
343+
key: bench-baseline-${{ matrix.pkg }}-${{ runner.os }}-${{ hashFiles('go.sum') }}
344+
restore-keys: bench-baseline-${{ matrix.pkg }}-${{ runner.os }}-
329345

330346
- name: Run benchmarks
331347
shell: bash -Eeuo pipefail -x {0}
332348
run: |
333-
go test ./internal/... -bench=. -benchmem -run='^$' \
349+
go test ${{ matrix.path }} -bench='${{ matrix.bench }}' -benchmem -run='^$' \
334350
-count=5 -timeout=10m | tee bench-current.txt
335351
336352
- name: Compare with baseline
@@ -360,7 +376,7 @@ jobs:
360376
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
361377
with:
362378
path: bench-baseline.txt
363-
key: bench-baseline-${{ runner.os }}-${{ hashFiles('go.sum') }}
379+
key: bench-baseline-${{ matrix.pkg }}-${{ runner.os }}-${{ hashFiles('go.sum') }}
364380

365381
test-integration:
366382
name: Integration Tests

0 commit comments

Comments
 (0)