Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.gitlab: add trigger for benchmarks #1588

Merged
merged 13 commits into from
Nov 18, 2022
4 changes: 4 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
stages:
- benchmarks

include: ".gitlab/benchmarks.yml"
28 changes: 28 additions & 0 deletions .gitlab/benchmarks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
variables:
# This base image is created here: https://gitlab.ddbuild.io/DataDog/apm-reliability/relenv-microbenchmarking-platform
BASE_CI_IMAGE: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/relenv-microbenchmarking-platform:dd-trace-go_knusbaum_test
INDEX_FILE: index.txt

benchmark:
stage: benchmarks
image: $BASE_CI_IMAGE
timeout: 1h
only:
refs:
- branches
interruptible: true
tags: ["runner:apm-k8s-tweaked-metal"]
script:
- ./.gitlab/scripts/capture-hardware-software-info.sh
- ./.gitlab/scripts/run-benchmarks.sh
# - ./.gitlab/scripts/upload-results-to-s3.sh #commented out until we have merged our permissions changes
- ./.gitlab/scripts/analyze-results.sh
- ./.gitlab/scripts/post-pr-comment.sh
artifacts:
name: "reports"
paths:
- reports/
expire_in: 3 months
variables:
KUBERNETES_SERVICE_ACCOUNT_OVERWRITE: dd-trace-go
FF_USE_LEGACY_KUBERNETES_EXECUTION_STRATEGY: "true"
26 changes: 26 additions & 0 deletions .gitlab/scripts/analyze-results.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

ARTIFACTS_DIR="/artifacts/${CI_JOB_ID}"
REPORTS_DIR="$(pwd)/reports/"
mkdir "${REPORTS_DIR}" || :

BASELINE_BRANCH=$(github-find-merge-into-branch --for-repo="$CI_PROJECT_NAME" --for-pr="$CI_COMMIT_REF_NAME" || :)

source /benchmark-analyzer/.venv/bin/activate
cd /benchmark-analyzer

./benchmark_analyzer convert \
--framework=GoBench \
--outpath="pr.json" \
--extra-params="{\"dd_trace_go\":\"${CI_COMMIT_REF_NAME}\"}" \
"${ARTIFACTS_DIR}/pr_bench.txt"

./benchmark_analyzer convert \
--framework=GoBench \
--outpath="main.json" \
--extra-params="{\"dd_trace_go\":\"main\"}" \
"${ARTIFACTS_DIR}/main_bench.txt"

./benchmark_analyzer compare pairwise --outpath ${REPORTS_DIR}/report.md --format md-nodejs pr.json main.json
./benchmark_analyzer compare pairwise --outpath ${REPORTS_DIR}/report_full.html --format html pr.json main.json

27 changes: 27 additions & 0 deletions .gitlab/scripts/capture-hardware-software-info.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

REPORTS_DIR="$(pwd)/reports/"
mkdir "${REPORTS_DIR}" || :

ARTIFACTS_DIR="/artifacts/${CI_JOB_ID}"
mkdir -p "${ARTIFACTS_DIR}" && cd "${ARTIFACTS_DIR}"

# Collect software information

(which top && top -b -n 1 > top.txt) || :
(which uname && uname -a > uname.txt) || :
(which ldconfig && ldconfig -v > ldconfig.txt) || :
(which sysctl && sysctl -a > sysctl.txt) || :

# Collect hardware information

(which lscpu && lscpu -e > lscpu-e.txt) || :
(which lscpu && lscpu > lscpu.txt) || :
(which hwinfo && hwinfo --short > hwinfo-short.txt) || :
(which hwinfo && hwinfo > hwinfo-full.txt) || :
#cpupower frequency-info > cpupower-frequency-info.txt
#turbostat -n 1 > turbostat.txt

# Save all collected information to Gitlab reports as well

cp * "${REPORTS_DIR}"
5 changes: 5 additions & 0 deletions .gitlab/scripts/post-pr-comment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

REPORTS_DIR="$(pwd)/reports/"

cat ${REPORTS_DIR}/report.md | /usr/local/bin/pr-commenter --for-repo="$CI_PROJECT_NAME" --for-pr="$CI_COMMIT_REF_NAME" --header="Benchmarks"
12 changes: 12 additions & 0 deletions .gitlab/scripts/run-benchmarks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

ARTIFACTS_DIR="/artifacts/${CI_JOB_ID}"
mkdir -p "${ARTIFACTS_DIR}"

git clone --branch ${CI_COMMIT_REF_NAME} https://github.com/DataDog/dd-trace-go

cd dd-trace-go/ddtrace/tracer/
go test -run=XXX -bench "BenchmarkConcurrentTracing|BenchmarkStartSpan" -benchmem -count 10 -benchtime 2s ./... | tee ${ARTIFACTS_DIR}/pr_bench.txt

git checkout main
go test -run=XXX -bench "BenchmarkConcurrentTracing|BenchmarkStartSpan" -benchmem -count 10 -benchtime 2s ./... | tee ${ARTIFACTS_DIR}/main_bench.txt
8 changes: 8 additions & 0 deletions .gitlab/scripts/upload-results-to-s3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

PROJECT="${CI_PROJECT_NAME:-$CI_PROJECT_NAME}"
BRANCH="${CI_COMMIT_REF_NAME:-$CI_COMMIT_REF_NAME}"

S3_URL=s3://relenv-benchmarking-data/${PROJECT}/${BRANCH}/${CI_JOB_ID}/

aws s3 cp --recursive --acl bucket-owner-full-control /artifacts/${CI_JOB_ID}/ $S3_URL
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,7 @@ git update-index --no-assume-unchanged go.*
### Milestones

The maintainers of this repository assign milestones to pull requests to classify them. `Triage` indicates that it is yet to be decided which version the change will go into. Pull requests that are ready get the upcoming release version assigned.

### Benchmarks

Some benchmarks will run on any new PR commits, the results will be commented into the PR on completion. To see the list of benchmarks or to add additional benchmarks run go to `.gitlab/scripts/run-benchmarks.sh`.
1 change: 1 addition & 0 deletions ddtrace/tracer/tracer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1730,6 +1730,7 @@ func BenchmarkTracerAddSpans(b *testing.B) {
func BenchmarkStartSpan(b *testing.B) {
tracer, _, _, stop := startTestTracer(b, WithLogger(log.DiscardLogger{}), WithSampler(NewRateSampler(0)))
defer stop()

root := tracer.StartSpan("pylons.request", ServiceName("pylons"), ResourceName("/"))
ctx := ContextWithSpan(context.TODO(), root)

Expand Down