From 27436d8545f474fb88701a9bfaa0ae99e2fd4d94 Mon Sep 17 00:00:00 2001 From: Aaron Clawson <3766680+MadVikingGod@users.noreply.github.com> Date: Tue, 26 Sep 2023 09:33:25 -0500 Subject: [PATCH 1/5] Add a benchmark target to makefile --- Makefile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Makefile b/Makefile index 5c311706b0c..228231a4f14 100644 --- a/Makefile +++ b/Makefile @@ -189,6 +189,18 @@ test-coverage: | $(GOCOVMERGE) done; \ $(GOCOVMERGE) $$(find . -name coverage.out) > coverage.txt +# Adding a directory will include all benchmarks in that direcotry if a filter is not specified. +BENCHMARK_TARGETS := sdk/trace +.PHONY: benchmark +benchmark: $(BENCHMARK_TARGETS:%=benchmark/%) +BENCHMARK_FILTER = . +# You can override the filter for a particular directory by adding a rule here. +benchmark/sdk/trace: BENCHMARK_FILTER = SpanWithAttributes_8/AlwaysSample +benchmark/%: + @echo "$(GO) test -timeout $(TIMEOUT)s -run=xxxxxMatchNothingxxxxx -bench=$(BENCHMARK_FILTER) $*..." \ + && cd $* \ + $(foreach filter, $(BENCHMARK_FILTER), && $(GO) test -timeout $(TIMEOUT)s -run=xxxxxMatchNothingxxxxx -bench=$(filter)) + .PHONY: golangci-lint golangci-lint-fix golangci-lint-fix: ARGS=--fix golangci-lint-fix: golangci-lint From 0cdfff87ebde5153b18569186d3dec510b8c49cf Mon Sep 17 00:00:00 2001 From: Aaron Clawson <3766680+MadVikingGod@users.noreply.github.com> Date: Tue, 26 Sep 2023 09:39:38 -0500 Subject: [PATCH 2/5] update CI to reflect how the benchmarks will be used --- .github/workflows/benchmark.yml | 9 ++++++--- .github/workflows/ci.yml | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 6d546b9b49c..94134d8d1fc 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -1,21 +1,24 @@ name: Benchmark on: push: - branches: - - main + tags: + - v1.* + workflow_dispatch: + env: DEFAULT_GO_VERSION: "~1.21.1" jobs: benchmark: name: Benchmarks runs-on: ubuntu-latest + timeout-minutes: 15 steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v4 with: go-version: ${{ env.DEFAULT_GO_VERSION }} - name: Run benchmarks - run: make test-bench | tee output.txt + run: make benchmark | tee output.txt - name: Download previous benchmark data uses: actions/cache@v3 with: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 30b8e1250bd..f7686c7b03d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,6 +45,22 @@ jobs: run: make build - name: Check clean repository run: make check-clean-work-tree + test-bench: + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + - name: Setup Environment + run: | + echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV + echo "$(go env GOPATH)/bin" >> $GITHUB_PATH + - name: Install Go + uses: actions/setup-go@v4 + with: + go-version: ${{ env.DEFAULT_GO_VERSION }} + cache-dependency-path: "**/go.sum" + - name: Run benchmarks to check functionality + run: make test-bench test-race: runs-on: ubuntu-latest From b5c53d96436137e2272010d003aa30a6a5b460fa Mon Sep 17 00:00:00 2001 From: Aaron Clawson <3766680+MadVikingGod@users.noreply.github.com> Date: Thu, 28 Sep 2023 09:52:52 -0500 Subject: [PATCH 3/5] Fix benchmark --- sdk/metric/internal/aggregate/exponential_histogram_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/metric/internal/aggregate/exponential_histogram_test.go b/sdk/metric/internal/aggregate/exponential_histogram_test.go index 7dbb71b15bd..26b89f0ba50 100644 --- a/sdk/metric/internal/aggregate/exponential_histogram_test.go +++ b/sdk/metric/internal/aggregate/exponential_histogram_test.go @@ -676,7 +676,7 @@ func BenchmarkPrepend(b *testing.B) { func BenchmarkAppend(b *testing.B) { for i := 0; i < b.N; i++ { - agg := newExpoHistogramDataPoint[float64](1024, 200, false, false) + agg := newExpoHistogramDataPoint[float64](1024, 20, false, false) n := smallestNonZeroNormalFloat64 for j := 0; j < 1024; j++ { agg.record(n) From 58ab83226bcb832ece9440ebdf1f87b0ec4111b0 Mon Sep 17 00:00:00 2001 From: Aaron Clawson <3766680+MadVikingGod@users.noreply.github.com> Date: Thu, 28 Sep 2023 11:09:17 -0500 Subject: [PATCH 4/5] Add auto-push to benchmarks branch. --- .github/workflows/benchmark.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 94134d8d1fc..70dddd888a2 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -1,7 +1,7 @@ name: Benchmark on: push: - tags: + tags: - v1.* workflow_dispatch: @@ -31,6 +31,8 @@ jobs: tool: 'go' output-file-path: output.txt external-data-json-path: ./benchmarks/data.json - auto-push: false + github-token: ${{ secrets.GITHUB_TOKEN }} + gh-pages-branch: benchmarks + auto-push: true fail-on-alert: false alert-threshold: "400%" From e211326f231c4f7e0f9022da0b32a142707c4cee Mon Sep 17 00:00:00 2001 From: Aaron Clawson <3766680+MadVikingGod@users.noreply.github.com> Date: Thu, 28 Sep 2023 11:11:04 -0500 Subject: [PATCH 5/5] fix spacing --- .github/workflows/benchmark.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 70dddd888a2..24d99c2a6c0 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -1,7 +1,7 @@ name: Benchmark on: push: - tags: + tags: - v1.* workflow_dispatch: