From f6d6b4bc000908502a3385d570f0eb17c736df40 Mon Sep 17 00:00:00 2001 From: Rey Abolofia Date: Mon, 27 Nov 2023 12:04:16 -0800 Subject: [PATCH] Github action to run serverless benchmarks. --- .github/workflows/serverless-benchmarks.yml | 73 +++++++++++++++++++++ pkg/serverless/daemon/routes.go | 1 + 2 files changed, 74 insertions(+) create mode 100644 .github/workflows/serverless-benchmarks.yml diff --git a/.github/workflows/serverless-benchmarks.yml b/.github/workflows/serverless-benchmarks.yml new file mode 100644 index 00000000000000..666270908f7c71 --- /dev/null +++ b/.github/workflows/serverless-benchmarks.yml @@ -0,0 +1,73 @@ +name: "Serverless Benchmarks" + +on: + push: + paths: + - 'cmd/serverless/**' + - 'pkg/serverless/**' + - '.github/workflows/serverless-benchmarks.yml' + +env: + DD_API_KEY: must-be-set + +jobs: + run: + runs-on: ubuntu-latest + steps: + - name: Install Go + uses: actions/setup-go@v4 + with: + go-version: stable + + - name: Install benchstat + run: | + go install golang.org/x/perf/cmd/benchstat@latest + + - name: Checkout datadog-agent repository + uses: actions/checkout@v3 + with: + path: go/src/github.com/DataDog/datadog-agent + + - name: Checkout datadog-agent base branch + run: | + cd go/src/github.com/DataDog/datadog-agent + git fetch origin $GITHUB_BASE_REF --depth 1 + git checkout $GITHUB_BASE_REF + + - name: Previous benchmark results + run: | + cd go/src/github.com/DataDog/datadog-agent + go test -tags=test -run='^$' -bench=StartEndInvocation -count=4 -benchtime=10x -timeout=60m \ + ./pkg/serverless/... | tee previous.txt + + - name: Checkout datadog-agent pr branch + run: | + cd go/src/github.com/DataDog/datadog-agent + git fetch origin $GITHUB_SHA --depth 1 + git checkout $GITHUB_SHA + + - name: Current benchmark results + run: | + cd go/src/github.com/DataDog/datadog-agent + go test -tags=test -run='^$' -bench=StartEndInvocation -count=4 -benchtime=10x -timeout=60m \ + ./pkg/serverless/... | tee current.txt + + - name: Analyze results + id: analyze + run: | + cd go/src/github.com/DataDog/datadog-agent + benchstat -row /event previous.txt current.txt | tee output.txt + OUTPUT=$(cat output.txt) + echo "analyze=$OUTPUT" >> $GITHUB_OUTPUT + + - name: Post comment + uses: marocchino/sticky-pull-request-comment@v2.5.0 + with: + hide_and_recreate: true + hide_classify: "RESOLVED" + message: | + ## Serverless Benchmark Results + + ``` + ${{ steps.analyze.outputs.analyze }} + ``` diff --git a/pkg/serverless/daemon/routes.go b/pkg/serverless/daemon/routes.go index 599d9cb879ec2a..89de80fbbf3299 100644 --- a/pkg/serverless/daemon/routes.go +++ b/pkg/serverless/daemon/routes.go @@ -74,6 +74,7 @@ func (s *StartInvocation) ServeHTTP(w http.ResponseWriter, r *http.Request) { w.Header().Set(invocationlifecycle.TraceIDHeader, fmt.Sprintf("%v", s.daemon.InvocationProcessor.GetExecutionInfo().TraceID)) w.Header().Set(invocationlifecycle.SamplingPriorityHeader, fmt.Sprintf("%v", s.daemon.InvocationProcessor.GetExecutionInfo().SamplingPriority)) } + time.Sleep(time.Millisecond) } // EndInvocation is a route that can be called at the end of an invocation to enable