Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .claude/ci/benchmarks.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@
| `benchmarks-tracer` | `$MICROBENCHMARKS_CI_IMAGE` (see `.gitlab/benchmarks.yml`; built in-repo from `.gitlab/benchmarks/container/`) | Runs PHP tracer microbenchmarks via the Benchmarking Platform framework, one `TRACER_PART` (phpbench, phpbench-opcache, tea) and, for the phpbench parts, one `PHPBENCH_SHARD` (1, 2) per matrix job; skips automatically if no tracer-relevant files changed |
| `benchmarks-appsec` | same | Runs appsec microbenchmarks; produces `candidate.tar.gz` and `baseline.tar.gz` artifacts |
| `benchmarks-profiler` | same | Runs profiler microbenchmarks |
| `benchmarks-pr-comment` | `$MICROBENCHMARKS_CI_IMAGE` (see `.gitlab/benchmarks.yml`; built in-repo from `.gitlab/benchmarks/container/`) | Runs `.gitlab/benchmarks/bp-runner.pr-comment.yml`: posts the tracer comparison as a PR comment and uploads the results to the Benchmarking Platform API; needs `benchmarks-tracer`; allow_failure |
| `benchmarks-pr-comment-appsec` | same | Same flow for AppSec, with its own comment header; needs `benchmarks-appsec` |
| `benchmarks-pr-comment-profiler` | same | Same flow for the profiler, with its own comment header; needs `benchmarks-profiler` |
| `benchmarks-pr-comment` | `$BENCHMARKING_PLATFORM_TOOLS_IMAGE` (see `.gitlab/benchmarks.yml`) | Posts the tracer comparison as a PR comment (bp-runner config generated inline; no checkout); needs `benchmarks-tracer`; allow_failure |
| `benchmarks-upload-bp-api` | same | Uploads the tracer results to the Benchmarking Platform API, in parallel with the comment; needs `benchmarks-tracer`; allow_failure |
| `benchmarks-pr-comment-appsec` | same | Posts the AppSec comparison as a PR comment (bp-runner config generated inline; no checkout); needs `benchmarks-appsec`; allow_failure |
| `benchmarks-upload-bp-api-appsec` | same | Uploads the AppSec results to the Benchmarking Platform API, in parallel with the comment; needs `benchmarks-appsec`; allow_failure |
| `benchmarks-pr-comment-profiler` | same | Posts the profiler comparison as a PR comment (bp-runner config generated inline; no checkout); needs `benchmarks-profiler`; allow_failure |
| `benchmarks-upload-bp-api-profiler` | same | Uploads the profiler results to the Benchmarking Platform API, in parallel with the comment; needs `benchmarks-profiler`; allow_failure |
| `build-benchmark-ci-images` | (built in-repo from `.gitlab/benchmarks/container/`) | Manual job that builds the microbenchmark CI image from `.gitlab/benchmarks/container/`; described in `.gitlab/benchmarks/README.md` § How to rebuild the CI Docker image |
| `build-llvm-bolt-align-image` | (built in-repo from `.gitlab/benchmarks/container/llvm-bolt-align/`) | Manual job that builds the static `llvm-bolt-align` tool image copied into the microbenchmark CI image; described in `.gitlab/benchmarks/README.md` § Rebuilding the `llvm-bolt-align` image |
| `macrobenchmarks: [{PHP_VERSION}]` | `486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/benchmarking-platform:php_laravel-realworld` | Runs a Laravel Realworld application under k6 load at three traffic levels; PHP 7.4 and 8.1 |
| `check-big-regressions` | `registry.ddbuild.io/images/benchmarking-platform-tools-ubuntu@sha256:b682acae509fa391ac559705b66df07cac876e4c46641d2457077972a1c0bbb8` | Post-benchmark gate: fails if `benchmarks-tracer` results contain a regression above threshold, or if any part's candidate results (or baseline results, when there is a baseline branch) are missing |
| `check-big-regressions` | `$BENCHMARKING_PLATFORM_TOOLS_IMAGE` | Post-benchmark gate: fails if `benchmarks-tracer` results contain a regression above threshold, or if any part's candidate results (or baseline results, when there is a baseline branch) are missing |
| `check-slo-breaches` | (benchmarking-platform-tools template) | Post-macrobenchmark gate: evaluates SLO breaches |
| `notify-slo-breaches` | (benchmarking-platform-tools template) | Posts SLO breach notifications to `#guild-dd-php` Slack channel |

Expand Down
4 changes: 3 additions & 1 deletion .claude/ci/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,9 @@ Dedicated performance hardware — not easily reproducible locally.
→ **[benchmarks.md](benchmarks.md)**
Covers: `benchmarks-tracer`, `benchmarks-appsec`, `benchmarks-profiler`,
`benchmarks-pr-comment`, `benchmarks-pr-comment-appsec`,
`benchmarks-pr-comment-profiler`, `macrobenchmarks [7.4]`, `macrobenchmarks [8.1]`,
`benchmarks-pr-comment-profiler`, `benchmarks-upload-bp-api`,
`benchmarks-upload-bp-api-appsec`, `benchmarks-upload-bp-api-profiler`,
`macrobenchmarks [7.4]`, `macrobenchmarks [8.1]`,
`build-benchmark-ci-images`

---
Expand Down
113 changes: 87 additions & 26 deletions .gitlab/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ variables:
# `.gitlab/benchmarks/container/` (see `.gitlab/benchmarks/README.md`).
# Built here: https://gitlab.ddbuild.io/DataDog/apm-reliability/dd-trace-php/-/jobs/2300686392
MICROBENCHMARKS_CI_IMAGE: registry.ddbuild.io/ci/benchmarking-platform:dd-trace-php-156499868
# Benchmarking Platform tools image for the jobs that only read reports/.
# Keep in sync with the FROM of .gitlab/benchmarks/container/Dockerfile.
BENCHMARKING_PLATFORM_TOOLS_IMAGE: registry.ddbuild.io/images/benchmarking-platform-tools-ubuntu@sha256:dbdd7f39672099fca20799a44b38e472a029376c98115b449debe68fb8f38856
# The Dockerfile is located at: .gitlab/benchmarks/container/Dockerfile
BASE_CI_IMAGE_SUFFIX: dd-trace-php-${CI_PIPELINE_ID}
BASE_CI_IMAGE_CONTAINER_DIR: .gitlab/benchmarks/container
Expand Down Expand Up @@ -320,22 +323,28 @@ benchmarks-appsec:
variables:
SCENARIO: "appsec"

# Posts the comparison and uploads results. allow_failure preserves the old || :
# semantics, and a separate job avoids the parallel-teardown race with the S3
# upload.
# One reporting job per scenario: appsec and profiler benchmarks are manual,
# tracer is not, and a need on an unplayed manual job makes GitLab skip the
# dependent.
.benchmarks-report-rules: &benchmarks-report-rules
- when: on_success

# Reporting jobs: a PR comment plus a parallel Benchmarking Platform API
# upload. allow_failure preserves the old || : semantics.
# One pair per scenario: appsec and profiler benchmarks are manual, tracer
# is not, and a need on an unplayed manual job makes GitLab skip the dependent.
.benchmarks-report:
stage: benchmarks-report
allow_failure: true
when: on_success
tags: ["arch:amd64"]
image: $MICROBENCHMARKS_CI_IMAGE
image: $BENCHMARKING_PLATFORM_TOOLS_IMAGE
timeout: 30m
variables:
GIT_STRATEGY: none
# See https://datadoghq.atlassian.net/wiki/spaces/APMINT/pages/7223313012/Flaky+Benchmarks+Monitoring for more details.
FLAKY_BENCHMARKS_REGEX: ""

.benchmarks-report-guard:
script:
- export ARTIFACTS_DIR="$(pwd)/reports" && (mkdir "${ARTIFACTS_DIR}" || :)
- git config --global url."https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ddbuild.io/DataDog/".insteadOf "https://github.com/DataDog/"
- |
if [ -f "reports/skip-reason.txt" ] && ! ls reports/candidate*.converted.json >/dev/null 2>&1; then
echo "Benchmarks were skipped (no relevant file changes) - nothing to report"
Expand All @@ -344,42 +353,94 @@ benchmarks-appsec:
echo "ERROR: Reports directory exists but is empty - benchmarks job had issues"
exit 1
fi
- bp-runner "${CI_PROJECT_DIR}/.gitlab/benchmarks/$BP_RUNNER_PR_COMMENT_CONFIG" --debug

.benchmarks-report-pr-comment:
extends: .benchmarks-report
variables:
# Analyzer settings the PR comment's comparison output depends on.
SIGNIFICANT_IMPACT_THRESHOLD: "5.0"
MD_REPORT_ONLY_CHANGES: "1"
script:
- !reference [.benchmarks-report-guard, script]
# pr-commenter identifies its comment by this header.
- |
cat > /tmp/bp-runner.pr-comment.yml <<EOF
experiments:
- name: Post PR comment
steps:
- name: Post PR comment
run: post_pr_comment
header: Benchmarks [ ${BP_REPORT_SCENARIO:?} ]
EOF
- bp-runner /tmp/bp-runner.pr-comment.yml --debug
artifacts:
name: "reports"
when: always
paths:
- reports/
expire_in: 3 months
variables:
# See https://datadoghq.atlassian.net/wiki/spaces/APMINT/pages/7223313012/Flaky+Benchmarks+Monitoring for more details.
FLAKY_BENCHMARKS_REGEX: ""
# Analyzer settings the PR comment's comparison output depends on.
SIGNIFICANT_IMPACT_THRESHOLD: "5.0"
MD_REPORT_ONLY_CHANGES: "1"

benchmarks-pr-comment:
.benchmarks-report-upload-bp-api:
extends: .benchmarks-report
script:
- !reference [.benchmarks-report-guard, script]
- |
cat > /tmp/bp-runner.upload-bp-api.yml <<EOF
experiments:
- name: Upload to BP API
steps:
- name: No-op
run: shell
script: "true"
global_teardown:
- name: Upload to BP API
run: upload_to_bp_api
retries_on_failure: 3
project: dd-trace-php
EOF
- bp-runner /tmp/bp-runner.upload-bp-api.yml --debug
artifacts:
name: "bp-api-uploaded"
when: always
paths:
- reports/*.bp-api-uploaded.json
expire_in: 3 months

benchmarks-pr-comment:
extends: .benchmarks-report-pr-comment
rules: *benchmarks-tracer-rules
needs: [benchmarks-tracer]
variables:
BP_RUNNER_PR_COMMENT_CONFIG: "bp-runner.pr-comment.yml"
BP_REPORT_SCENARIO: tracer

benchmarks-upload-bp-api:
extends: .benchmarks-report-upload-bp-api
rules: *benchmarks-tracer-rules
needs: [benchmarks-tracer]

benchmarks-pr-comment-appsec:
extends: .benchmarks-report
rules:
- when: on_success
extends: .benchmarks-report-pr-comment
rules: *benchmarks-report-rules
needs: [benchmarks-appsec]
variables:
BP_RUNNER_PR_COMMENT_CONFIG: "bp-runner.pr-comment-appsec.yml"
BP_REPORT_SCENARIO: appsec

benchmarks-upload-bp-api-appsec:
extends: .benchmarks-report-upload-bp-api
rules: *benchmarks-report-rules
needs: [benchmarks-appsec]

benchmarks-pr-comment-profiler:
extends: .benchmarks-report
rules:
- when: on_success
extends: .benchmarks-report-pr-comment
rules: *benchmarks-report-rules
needs: [benchmarks-profiler]
variables:
BP_RUNNER_PR_COMMENT_CONFIG: "bp-runner.pr-comment-profiler.yml"
BP_REPORT_SCENARIO: profiler

benchmarks-upload-bp-api-profiler:
extends: .benchmarks-report-upload-bp-api
rules: *benchmarks-report-rules
needs: [benchmarks-profiler]

# Kafka and RabbitMQ produce/consume throughput with Data Streams Monitoring
# off and on, against real brokers and agent; fails if DSM adds more than 3%
Expand Down Expand Up @@ -431,7 +492,7 @@ check-big-regressions:
stage: gate
needs: [ "benchmarks-tracer" ]
tags: [ "arch:amd64" ]
image: registry.ddbuild.io/images/benchmarking-platform-tools-ubuntu@sha256:b682acae509fa391ac559705b66df07cac876e4c46641d2457077972a1c0bbb8
image: $BENCHMARKING_PLATFORM_TOOLS_IMAGE
script: |
if [ -f "reports/skip-reason.txt" ] && ! ls reports/candidate*.converted.json >/dev/null 2>&1; then
echo "Benchmarks were skipped (no relevant file changes) - regression check not needed"
Expand Down
40 changes: 23 additions & 17 deletions .gitlab/benchmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,16 @@ This directory holds everything the microbenchmark jobs need:
sysctl), clones the candidate and the baseline and runs `benchmark/runall.sh`
on pinned CPUs, converts the results per framework (PHPBench, tea's Google
Benchmark, Sirun), and uploads the reports to S3.
- **`bp-runner.pr-comment.yml`**: posts the comparison on the PR and uploads
the converted results to the Benchmarking Platform API (run by the separate
`benchmarks-pr-comment` job; `bp-runner.pr-comment-appsec.yml` and
`bp-runner.pr-comment-profiler.yml` are the same flow with the AppSec and
profiler comment headers, run by `benchmarks-pr-comment-appsec` and
`benchmarks-pr-comment-profiler`).
- **`bp-runner.fail-on-regression.yml`**: gate config used by
`check-big-regressions` to fail the pipeline on regressions above its
threshold (10%).

The reporting jobs' bp-runner configs are generated inline in
`.gitlab/benchmarks.yml`, since those jobs run without a checkout.

The jobs themselves (`benchmarks-tracer`, `benchmarks-appsec`,
`benchmarks-profiler`, `benchmarks-pr-comment`, `benchmarks-pr-comment-appsec`,
`benchmarks-pr-comment-profiler`, `check-big-regressions`) are defined in
`benchmarks-profiler`, `benchmarks-pr-comment*`, `benchmarks-upload-bp-api*`,
`check-big-regressions`) are defined in
[`.gitlab/benchmarks.yml`](../benchmarks.yml), which runs as a child pipeline
of `package-trigger` (the stage list it validates against is generated by
`.gitlab/generate-package.php`).
Expand All @@ -61,15 +58,17 @@ Execution flow on each PR:
also uploads the logs, tarred as `candidate.tar.gz`/`baseline.tar.gz`.
3. The config's analyze steps convert the results per framework (PHPBench,
GoogleBenchmark for tea, Sirun) and the S3 teardown archives the reports;
`benchmarks-pr-comment*` jobs run their `bp-runner.pr-comment*.yml` to
push the converted results to the Benchmarking Platform API so they land on
the project's trend series.
4. `check-big-regressions` and `benchmarks-pr-comment` merge the five
tracer jobs' `reports/`. The gate fails if any part's candidate (or, when
there is a baseline branch, baseline) `.converted.json` is missing, or on
the `benchmarks-upload-bp-api*` jobs push the converted results to the
Benchmarking Platform API so they land on the project's trend series.
4. `check-big-regressions`, `benchmarks-pr-comment` and
`benchmarks-upload-bp-api` merge the five tracer jobs' `reports/`. The
gate fails if any part's candidate (or, when there is a baseline branch,
baseline) `.converted.json` is missing, or on
regressions above the threshold of 10% in
`bp-runner.fail-on-regression.yml`, and
`benchmarks-pr-comment*` comments the comparison on the PR.
`benchmarks-pr-comment*` comments the comparison on the PR. The reporting
jobs only read `reports/`, so they skip the checkout and run on
`BENCHMARKING_PLATFORM_TOOLS_IMAGE`.

## Binary layout processing

Expand Down Expand Up @@ -158,7 +157,8 @@ you iterate, see
Changes to the benchmark CI (this directory, `.gitlab/benchmarks.yml`) run
`benchmarks-tracer` like tracer changes do. AppSec and profiler stay manual
unless their sources change: play the benchmark job to exercise a CI change
there; its `benchmarks-pr-comment-*` job follows automatically.
there; its `benchmarks-pr-comment-*` and `benchmarks-upload-bp-api-*` jobs
follow automatically.

## How to mark a benchmark as known flaky

Expand Down Expand Up @@ -186,7 +186,7 @@ Open a ticket to fix or remove it. See
The `MICROBENCHMARKS_CI_IMAGE` used by the microbenchmark jobs is built from
`container/Dockerfile` in this directory. Rebuild and repin it whenever you
change anything in that directory (e.g. bumping PHP, adding system packages,
or updating `sirun`).
updating `sirun`, or bumping the tools base digest).

1. Edit the relevant file(s) under `.gitlab/benchmarks/container/`. Push the
branch and open a PR.
Expand All @@ -213,6 +213,12 @@ or updating `sirun`).
MICROBENCHMARKS_CI_IMAGE: registry.ddbuild.io/ci/benchmarking-platform:dd-trace-php-<NEW_PIPELINE_ID>
```

The container builds `FROM` the digest pinned in
`BENCHMARKING_PLATFORM_TOOLS_IMAGE` (see `.gitlab/benchmarks.yml`), so a
rebuild can't silently pick up a newer tools base: to bump the tools, repin
the digest in both places together. This keeps the reporting jobs reading
the results with the same tools that wrote them.

5. Push the update. The microbenchmarks now run against the rebuilt image.
Verify a green benchmark pipeline before merging.

Expand Down
12 changes: 0 additions & 12 deletions .gitlab/benchmarks/bp-runner.pr-comment-appsec.yml

This file was deleted.

12 changes: 0 additions & 12 deletions .gitlab/benchmarks/bp-runner.pr-comment-profiler.yml

This file was deleted.

12 changes: 0 additions & 12 deletions .gitlab/benchmarks/bp-runner.pr-comment.yml

This file was deleted.

4 changes: 3 additions & 1 deletion .gitlab/benchmarks/container/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
# the build-llvm-bolt-align-image job from container/llvm-bolt-align/.
FROM registry.ddbuild.io/ci/benchmarking-platform:llvm-bolt-align-156483907@sha256:800c006534c5182a29fef46d6f963398606485194b924c7d5636fd06d155d7fb AS bolt-align

FROM registry.ddbuild.io/images/benchmarking-platform-tools-ubuntu:latest
# Pinned by digest; keep in sync with BENCHMARKING_PLATFORM_TOOLS_IMAGE in
# .gitlab/benchmarks.yml (see README § How to rebuild the CI Docker image).
FROM registry.ddbuild.io/images/benchmarking-platform-tools-ubuntu@sha256:dbdd7f39672099fca20799a44b38e472a029376c98115b449debe68fb8f38856

ARG CI_JOB_TOKEN
ARG RUST_VERSION=1.91.1
Expand Down
Loading