[ci] add differential benchmark workflows (#63100)

This commit does the following:
- Move existing smoke benchmark workflows to seperate workflow.
- Add differential benchmark workflows
- Split benchmarks into heavy and micro categories
- Add make target arguments for benchmark time and count
- Move smoketests to run only on PRs
- Differential benchmarks run on merge queue

Benchmarks above 1ms/op are considered heavy and should make
use of iteration based benchtime to prevent the CI job from taking
too much time. Benchmarks are skipped based on env vars, this is an
alternative to splitting benchmark targets into seperate files with
build tags.

The smoke tests should be much faster and as such are set to run
on PRs to ensure the targets are not broken in the change.

The current parameters for differential benchmarks attempt to balance
CI runner time and confidence for benchstat.

Differential benchmarks determine the base commit to run the tests against,
this happens within the same job to remove the runner to runner variance.
This commit is contained in:
Luke Okraszewski
2026-02-20 15:31:03 +00:00
committed by GitHub
parent ea7d11fd73
commit c223947413
23 changed files with 343 additions and 48 deletions
+9 -3
View File
@@ -999,7 +999,7 @@ ifneq ("$(TOUCHID_TAG)", "")
| $(GOTESTSUM) --junitfile $(TEST_LOG_DIR)/unit-tests-touchid.xml --jsonfile $(TEST_LOG_DIR)/unit-tests-touchid.json --raw-command -- cat
endif
# Runs benchmarks once to make sure they pass.
# By default, the parameters run each benchmark only once.
# This is intended to run in CI during unit testing to make sure benchmarks don't break.
# To limit noise and improve speed this will only run on packages that have benchmarks.
# Race detection is not enabled because it significantly slows down benchmarks.
@@ -1007,26 +1007,32 @@ endif
.PHONY: test-go-bench
test-go-bench: BENCHMARK_SKIP_PATTERN = "^BenchmarkRoot"
test-go-bench: BENCH_OUTPUT ?= $(TEST_LOG_DIR)/bench.txt
test-go-bench: BENCH_ARGS ?=
test-go-bench: BENCH_TIME ?= "1x"
test-go-bench: BENCH_COUNT ?= 1
test-go-bench: $(BENCHFIND) | $(TEST_LOG_DIR)
@PKGS=$$($(BENCHFIND) --tags=$(BUILD_TAGS)) ; \
if [ -z "$$PKGS" ]; then \
echo "No benchmark packages found"; \
exit 1; \
fi ; \
go test -run ^$$ -bench . -skip $(BENCHMARK_SKIP_PATTERN) -benchtime 1x $$PKGS \
go test -run ^$$ -bench . -skip $(BENCHMARK_SKIP_PATTERN) -count $(BENCH_COUNT) -benchtime $(BENCH_TIME) $(BENCH_ARGS) $$PKGS \
| tee $(BENCH_OUTPUT)
.PHONY: test-go-bench-root
test-go-bench-root: BENCHMARK_PATTERN = "^BenchmarkRoot"
test-go-bench-root: BENCHMARK_SKIP_PATTERN = ""
test-go-bench-root: BENCH_OUTPUT ?= $(TEST_LOG_DIR)/bench.txt
test-go-bench-root: BENCH_ARGS ?=
test-go-bench-root: BENCH_TIME ?= "1x"
test-go-bench-root: BENCH_COUNT ?= 1
test-go-bench-root: $(BENCHFIND) | $(TEST_LOG_DIR)
@PKGS=$$($(BENCHFIND) --tags=$(BUILD_TAGS)) ; \
if [ -z "$$PKGS" ]; then \
echo "No benchmark packages found"; \
exit 1; \
fi ; \
go test -run ^$$ -bench $(BENCHMARK_PATTERN) -skip $(BENCHMARK_SKIP_PATTERN) -benchtime 1x $$PKGS \
go test -run ^$$ -bench $(BENCHMARK_PATTERN) -skip $(BENCHMARK_SKIP_PATTERN) -count $(BENCH_COUNT) -benchtime $(BENCH_TIME) $(BENCH_ARGS) $$PKGS \
| tee $(BENCH_OUTPUT)
# Make sure untagged vnetdaemon code build/tests.