From b6db9d80f05f38d9db492180c479006066fb51f6 Mon Sep 17 00:00:00 2001 From: Brian Marks Date: Sat, 21 Nov 2026 01:09:03 -0500 Subject: [PATCH 01/18] ci: build the PHP 7.0 extension variants in parallel jobs The single PHP 7.0 compile job ran six builds back to back (static NTS/ZTS, then ThinLTO and SSI for NTS and ZTS) and only started after the sidecar job. It became the head of the PR pipeline's critical path (~55 min on arm64 musl). Split it per platform into: - the static build (build-tracing.sh), needing only prepare code: with --enable-ddtrace-rust-library-split it links no Rust library; - one ThinLTO job per flavour, needing only prepare code; - one SSI job building NTS then ZTS, which still needs the sidecar for the common-DSO identity check and keeps sharing tmp/ssi-rust-target. Each job keeps MAKE_JOBS: 12; without it build-profiler.sh runs make -j$(nproc) and the LTO jobs hit their 8Gi limit. --- .claude/ci/compile-artifacts.md | 11 ++-- .gitlab/generate-package.php | 101 ++++++++++++++++++++++++++------ 2 files changed, 89 insertions(+), 23 deletions(-) diff --git a/.claude/ci/compile-artifacts.md b/.claude/ci/compile-artifacts.md index 34fcf2b028..9be568dc39 100644 --- a/.claude/ci/compile-artifacts.md +++ b/.claude/ci/compile-artifacts.md @@ -71,7 +71,9 @@ stage. `make generate` produces three files via `classpreloader`: |--------|-------|--------------| | `prepare code` | `composer:2.10.3` | `.gitlab/append-build-id.sh` (bumps VERSION first) + `composer update` + `make generate`; produces VERSION + generated bridge files | | `cache cargo deps: [{arch}, {triplet}]` | `dd-trace-ci:php-8.1_{platform}` (alpine uses `php-compile-extension-alpine-8.1`) | `cargo fetch` to warm the Cargo cache for the given target triplet | -| `compile tracing extension: [7.0, {arch}, {triplet}]` | `dd-trace-ci:php-7.0_{platform}` | Tracer-only path: `build-tracing.sh` produces legacy C archives, then `make xlang-lto` and `make build-ssi-ddtrace` replace NTS/ZTS self-contained and SSI DSOs. SSI rebuilds common without a PHP-ABI archive and checks it against the sidecar job’s canonical DSO. Debug remains non-LTO (GNU only). Outputs `extensions_{arch}/`, `standalone_{arch}/`, and legacy link metadata. | +| `compile tracing extension: [7.0, {arch}, {triplet}]` | `dd-trace-ci:php-7.0_{platform}` | Tracer-only static path: `build-tracing.sh` produces legacy C archives (and the GNU-only non-LTO debug DSO) plus legacy link metadata. Needs only `prepare code`. | +| `compile tracing extension LTO: [7.0, {arch}, {triplet}, {nts,zts}]` | `dd-trace-ci:php-7.0_{platform}` | `make xlang-lto` for one flavour; outputs the self-contained NTS or ZTS DSO in `extensions_{arch}/`. Needs only `prepare code`. | +| `compile tracing extension SSI: [7.0, {arch}, {triplet}]` | `dd-trace-ci:php-7.0_{platform}` | `make build-ssi-ddtrace` for NTS then ZTS; rebuilds common without a PHP-ABI archive and checks it against the sidecar job’s canonical DSO. Outputs `standalone_{arch}/`. | | `compile tracing sidecar: [{arch}, {triplet}]` | `dd-trace-ci:php-8.1_{platform}` | `build-sidecar.sh` uses `build-xlang-lto ssi-common` to build `libdatadog_php_{arch}[-alpine].so` (common runtime plus embedded AppSec helper), once per platform. Also retains a Rust archive solely for the legacy debug link; it is not shipped. | | `link tracing extension: [{arch}, {triplet}]` | `dd-trace-ci:php-8.1_{platform}` | Fans in PHP 7.0 and PHP 7.1+ combined artifacts. Skips already-built `.so` files, links the remaining legacy debug archive with matched LLD, and deletes intermediate `.a` files from `extensions_*`. | | `aggregate tracing extension: [{arch}]` | `dd-trace-ci:php-7.4_bookworm-11` | No-op `ls` that collects the completed link-job artifacts for ordinary extension packaging. | @@ -144,7 +146,7 @@ version for test jobs, not for release packaging. ``` prepare code + cache cargo deps +-- compile combined extension (PHP 7.1+) ------------------. - +-- compile tracing extension (PHP 7.0) -------------------+-- link tracing extension + +-- compile tracing extension [LTO] (PHP 7.0) -------------+-- link tracing extension +-- compile tracing sidecar (common DSO + legacy archive) -' | | | v | | aggregate tracing extension @@ -155,7 +157,8 @@ prepare code + cache cargo deps | | +-- compile loader ---------------------------------------------+-- package loader (+ common DSO - and PHP 7.0 SSI) + and compile tracing + extension SSI, PHP 7.0) ``` The separate ASAN and Windows @@ -179,7 +182,7 @@ See `.gitlab/generate-package.php` for the exact per-platform `needs:` lists. - The Cargo cache uses the default `pull-push` policy in `cache cargo deps` and `policy: pull` (read-only) in `compile combined extension`, `compile SSI combined extension`, and `compile tracing sidecar`. The PHP 7.0 `compile tracing extension` - has no explicit `cache:` block, but its release ThinLTO steps do build Rust. + LTO and SSI jobs have no explicit `cache:` block, but they do build Rust. - Windows compile jobs use Docker on the Windows runner (not DinD): the script starts a long-lived container with `docker run -d`, then drives it via `docker exec`. The diff --git a/.gitlab/generate-package.php b/.gitlab/generate-package.php index 0574c80c1c..b04324b37d 100644 --- a/.gitlab/generate-package.php +++ b/.gitlab/generate-package.php @@ -424,6 +424,7 @@ function manual_unless_changed(array $globs, array $never_if = []): string } $image = sprintf($platform['image_template'], $major_minor); $suffix = ($platform['triplet'] === "x86_64-alpine-linux-musl" || $platform['triplet'] === "aarch64-alpine-linux-musl") ? "-alpine" : ""; + $arch_dir = $platform['arch'] === 'amd64' ? 'x86_64' : 'aarch64'; ?> "compile tracing extension: [, , ]": stage: tracing @@ -432,8 +433,6 @@ function manual_unless_changed(array $globs, array $never_if = []): string needs: - job: "prepare code" artifacts: true - - job: "compile tracing sidecar: [, ]" - artifacts: true variables: IMAGE: "" TRIPLET: "" @@ -448,35 +447,93 @@ function manual_unless_changed(array $globs, array $never_if = []): string # Fix for $BASH_ENV not having a newline at the end of the file - echo "" >> "$BASH_ENV" - ./.gitlab/build-tracing.sh "" + - rm -f "standalone_/ddtrace-${ABI_NO}.so" "standalone_/ddtrace-${ABI_NO}-zts.so" + artifacts: + paths: + - "extensions_*" + - "standalone_*" + - "ddtrace_*-fat.ldflags" + - "ddtrace_*-fat.sym" + + "", "zts" => "-zts"] as $flavour => $zts_suffix): ?> +"compile tracing extension LTO: [, , , ]": + stage: tracing + image: $IMAGE + tags: [ "arch:$ARCH" ] + needs: + - job: "prepare code" + artifacts: true + variables: + IMAGE: "" + TRIPLET: "" + ARCH: "" + ABI_NO: "" + PHP_VERSION: "" + MAKE_JOBS: 12 + CARGO_BUILD_JOBS: 12 + KUBERNETES_CPU_REQUEST: 12 + KUBERNETES_MEMORY_REQUEST: 4Gi + KUBERNETES_MEMORY_LIMIT: 8Gi + script: - # Load the function in this shell too, not just the build-tracing subprocess. - source "$BASH_ENV" + - switch_php "${PHP_VERSION}" + + - switch-php "${PHP_VERSION}" # PHP 7.0 remains tracer-only in both self-contained and SSI builds. - # Every SSI common rebuild must match the canonical DSO, including DWARF. - - export SSI_COMMON_REFERENCE="$PWD/libdatadog_php_.so" - - export CARGO_BUILD_JOBS=12 - - "${PHP_VERSION}" - - make -s xlang-lto - - cp "tmp/release-variants//php-${PHP_VERSION}/nts/combined/ddtrace.so" "extensions_/ddtrace-${ABI_NO}.so" - - make -s build-ssi-ddtrace - - cp "tmp/release-variants//php-${PHP_VERSION}/nts/ssi/ddtrace.so" "standalone_/ddtrace-${ABI_NO}.so" - - rm "tmp/release-variants//php-${PHP_VERSION}/nts/ssi/libdatadog_php.so" - - "${PHP_VERSION}-zts" - make -s xlang-lto - - cp "tmp/release-variants//php-${PHP_VERSION}/zts/combined/ddtrace.so" "extensions_/ddtrace-${ABI_NO}-zts.so" + - mkdir -p "extensions_" + - cp "tmp/release-variants//php-${PHP_VERSION}//combined/ddtrace.so" "extensions_/ddtrace-${ABI_NO}.so" + artifacts: + paths: + - "extensions_*" + + +"compile tracing extension SSI: [, , ]": + stage: tracing + image: $IMAGE + tags: [ "arch:$ARCH" ] + needs: + - job: "prepare code" + artifacts: true + - job: "compile tracing sidecar: [, ]" + artifacts: true + variables: + IMAGE: "" + TRIPLET: "" + ARCH: "" + ABI_NO: "" + PHP_VERSION: "" + MAKE_JOBS: 12 + CARGO_BUILD_JOBS: 12 + KUBERNETES_CPU_REQUEST: 12 + KUBERNETES_MEMORY_REQUEST: 4Gi + KUBERNETES_MEMORY_LIMIT: 8Gi + script: + + - source "$BASH_ENV" + + # Every SSI common rebuild must match the canonical DSO, including DWARF. + - export SSI_COMMON_REFERENCE="$PWD/libdatadog_php_.so" + - mkdir -p "standalone_" + "", "zts" => "-zts"] as $flavour => $zts_suffix): ?> + + - switch_php "${PHP_VERSION}" + + - switch-php "${PHP_VERSION}" + - make -s build-ssi-ddtrace - - cp "tmp/release-variants//php-${PHP_VERSION}/zts/ssi/ddtrace.so" "standalone_/ddtrace-${ABI_NO}-zts.so" - - rm "tmp/release-variants//php-${PHP_VERSION}/zts/ssi/libdatadog_php.so" + - cp "tmp/release-variants//php-${PHP_VERSION}//ssi/ddtrace.so" "standalone_/ddtrace-${ABI_NO}.so" + - rm "tmp/release-variants//php-${PHP_VERSION}//ssi/libdatadog_php.so" + artifacts: when: always paths: - - "extensions_*" - "standalone_*" # Retain the candidate common DSO if its identity check failed. - "tmp/release-variants/**/ssi/libdatadog_php.so" - - "ddtrace_*-fat.ldflags" - - "ddtrace_*-fat.sym" + , ]" artifacts: true + - job: "compile tracing extension LTO: [7.0, , , nts]" + artifacts: true + - job: "compile tracing extension LTO: [7.0, , , zts]" + artifacts: true @@ -946,6 +1007,8 @@ function manual_unless_changed(array $globs, array $never_if = []): string # PHP 7.0 still uses the split SSI extension (tracer and AppSec only). - job: "compile tracing extension: [7.0, , ]" artifacts: true + - job: "compile tracing extension SSI: [7.0, , ]" + artifacts: true - job: "compile tracing sidecar: [, ]" artifacts: true Date: Sat, 21 Nov 2026 01:09:05 -0500 Subject: [PATCH 02/18] ci: preload mimalloc in the Alpine Rust/LTO compile jobs On Alpine, rustc links the scudo allocator and clang/lld use musl's malloc. Container CPU metrics show the arm64 musl combined build spending 4.5 of its 9.6 busy cores in the kernel, against 0.7 on glibc. Install mimalloc2-insecure (the non-hardened build; libmimalloc.so.2 is the secure one) and LD_PRELOAD it in the musl compile jobs (combined, SSI combined, sidecar and the PHP 7.0 jobs), exiting 75 on a failed install so GitLab retries. Only the build tools are affected; the shipped binaries are unchanged. --- .claude/ci/compile-artifacts.md | 4 ++++ .gitlab/generate-package.php | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/.claude/ci/compile-artifacts.md b/.claude/ci/compile-artifacts.md index 9be568dc39..69b9476cd0 100644 --- a/.claude/ci/compile-artifacts.md +++ b/.claude/ci/compile-artifacts.md @@ -184,6 +184,10 @@ See `.gitlab/generate-package.php` for the exact per-platform `needs:` lists. extension`, and `compile tracing sidecar`. The PHP 7.0 `compile tracing extension` LTO and SSI jobs have no explicit `cache:` block, but they do build Rust. +- The musl compile jobs (combined, SSI combined, sidecar and the PHP 7.0 jobs) + `apk add mimalloc2-insecure` and `LD_PRELOAD` it: Alpine's rustc links scudo and + clang/lld use musl's malloc, which spend much of a parallel build in the kernel. + - Windows compile jobs use Docker on the Windows runner (not DinD): the script starts a long-lived container with `docker run -d`, then drives it via `docker exec`. The `GIT_STRATEGY: none` variable means the runner does not clone the repo -- instead the diff --git a/.gitlab/generate-package.php b/.gitlab/generate-package.php index b04324b37d..e9f2dc0a06 100644 --- a/.gitlab/generate-package.php +++ b/.gitlab/generate-package.php @@ -156,6 +156,18 @@ function manual_unless_changed(array $globs, array $never_if = []): string ?> + + - apk add -q --no-cache mimalloc2-insecure || exit 75 + - export LD_PRELOAD=/usr/lib/libmimalloc-insecure.so.2 + stages: - prepare - combined @@ -338,6 +350,7 @@ function manual_unless_changed(array $globs, array $never_if = []): string KUBERNETES_MEMORY_REQUEST: 4Gi KUBERNETES_MEMORY_LIMIT: 8Gi script: + # CentOS 7 release artifacts use Clang/Rust ThinLTO for NTS and ZTS. @@ -444,6 +457,7 @@ function manual_unless_changed(array $globs, array $never_if = []): string KUBERNETES_MEMORY_REQUEST: 4Gi KUBERNETES_MEMORY_LIMIT: 8Gi script: + # Fix for $BASH_ENV not having a newline at the end of the file - echo "" >> "$BASH_ENV" - ./.gitlab/build-tracing.sh "" @@ -475,6 +489,7 @@ function manual_unless_changed(array $globs, array $never_if = []): string KUBERNETES_MEMORY_REQUEST: 4Gi KUBERNETES_MEMORY_LIMIT: 8Gi script: + - source "$BASH_ENV" - switch_php "${PHP_VERSION}" @@ -511,6 +526,7 @@ function manual_unless_changed(array $globs, array $never_if = []): string KUBERNETES_MEMORY_REQUEST: 4Gi KUBERNETES_MEMORY_LIMIT: 8Gi script: + - source "$BASH_ENV" @@ -594,6 +610,7 @@ function manual_unless_changed(array $globs, array $never_if = []): string KUBERNETES_MEMORY_REQUEST: 5Gi KUBERNETES_MEMORY_LIMIT: 8Gi script: + - echo "" >> "$BASH_ENV" - ./.gitlab/build-sidecar.sh "" artifacts: @@ -633,6 +650,7 @@ function manual_unless_changed(array $globs, array $never_if = []): string KUBERNETES_MEMORY_REQUEST: 5Gi KUBERNETES_MEMORY_LIMIT: 10Gi script: + - echo "" >> "$BASH_ENV" - mkdir -p "ssi_" - export SSI_COMMON_REFERENCE="$PWD/libdatadog_php_.so" From ba645ee1614998a5f9c79762fcdb4d86665e0c73 Mon Sep 17 00:00:00 2001 From: Brian Marks Date: Fri, 20 Nov 2026 17:55:26 -0500 Subject: [PATCH 03/18] ci: stop rebuilding bindgen-cli in the Alpine sidecar job The Alpine compile image already installs bindgen-cli in /usr/local/bin. The per-run 'cargo install --force bindgen-cli' installed into $CARGO_HOME/bin (${CI_PROJECT_DIR}/.cache/cargo/bin), which is not on PATH; the /root/.cargo/bin PATH entry it added does not exist in the image. So every run compiled bindgen-cli and then used the image's copy. --- .claude/ci/compile-artifacts.md | 5 ++--- .gitlab/build-sidecar.sh | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.claude/ci/compile-artifacts.md b/.claude/ci/compile-artifacts.md index 69b9476cd0..ebfe94451c 100644 --- a/.claude/ci/compile-artifacts.md +++ b/.claude/ci/compile-artifacts.md @@ -175,9 +175,8 @@ See `.gitlab/generate-package.php` for the exact per-platform `needs:` lists. variants without a prebuilt DSO. `aggregate tracing extension` is a no-op fan-in **after linking**, not a collector of all-version pre-link archives. -- `compile tracing sidecar` on alpine: the `-alpine` suffix variant force-installs - `bindgen-cli` via `cargo install --force --locked` before building, as a workaround - for `aws-lc-sys` build failures on musl targets. +- `compile tracing sidecar` on alpine uses the `bindgen-cli` the image installs in + `/usr/local/bin` (needed by `aws-lc-sys` on musl targets). - The Cargo cache uses the default `pull-push` policy in `cache cargo deps` and `policy: pull` (read-only) in `compile combined extension`, `compile SSI combined diff --git a/.gitlab/build-sidecar.sh b/.gitlab/build-sidecar.sh index 84ddf88d29..d9eee23cf9 100755 --- a/.gitlab/build-sidecar.sh +++ b/.gitlab/build-sidecar.sh @@ -13,10 +13,9 @@ set -u suffix="${1:-}" -# Workaround "error: failed to run custom build command for `aws-lc-sys v0.20.0`" +# The Alpine image ships bindgen-cli (alpine_compile_extension base.Dockerfile). if [ "${suffix}" = "-alpine" ]; then - cargo install --force --locked bindgen-cli - export PATH="/root/.cargo/bin:$PATH" + command -v bindgen fi # Both release images have matched Clang/LLD and rust-src. The common DSO is From 9f3158d494824a10a74713d4d9725df83e10a521 Mon Sep 17 00:00:00 2001 From: Brian Marks Date: Sat, 21 Nov 2026 01:09:06 -0500 Subject: [PATCH 04/18] ci: run installer tests in parallel The 44 installer test scripts each run in their own throwaway container and only read the checkout, and every datadog-setup.php call passes --php-bin so none reads stdin, but make ran them one at a time (~18 min, at the end of the PR critical path). Run 8 at once with per-target output, and size the job to match. --- .claude/ci/package-dind-verification.md | 4 ++-- .gitlab/generate-package.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.claude/ci/package-dind-verification.md b/.claude/ci/package-dind-verification.md index 82e38ccea5..61cf3b2e7c 100644 --- a/.claude/ci/package-dind-verification.md +++ b/.claude/ci/package-dind-verification.md @@ -20,7 +20,7 @@ Docker-in-Docker runners because they spin up containers internally. | CI Job | Image | What it does | |--------|-------|--------------| | `framework test: [{suite}]` | `docker:29.4.0-noble` | Spins up a framework-specific Docker Compose stack and runs the framework's own test suite with ddtrace installed | -| `installer tests` | `docker:29.4.0-noble` | Runs `make -C dockerfiles/verify_packages test_installer`; verifies `datadog-setup.php` installer works on both amd64 and arm64 packages | +| `installer tests` | `docker:29.4.0-noble` | Runs `make -C dockerfiles/verify_packages -j 8 --output-sync=target test_installer`; verifies `datadog-setup.php` installer works on both amd64 and arm64 packages | | `randomized tests: [amd64, {no-asan,asan}, {1..5}]` | `docker:29.4.0-noble` | Generates random PHP scenarios and runs them with ddtrace for 1m30s each; checks for crashes and unexpected behavior | Runner: `docker-in-docker:amd64` @@ -210,7 +210,7 @@ docker-compose \ ### installer tests The installer tests (`make -C dockerfiles/verify_packages test_installer`) run -~39 test scripts. Each spins up a Docker container, runs +~44 test scripts, 8 at a time in CI. Each spins up a Docker container, runs `php ./build/packages/datadog-setup.php --php-bin php`, and verifies the installed extension version matches `cat VERSION`. diff --git a/.gitlab/generate-package.php b/.gitlab/generate-package.php index e9f2dc0a06..a71e0409b5 100644 --- a/.gitlab/generate-package.php +++ b/.gitlab/generate-package.php @@ -1362,9 +1362,9 @@ function alpine_mimalloc(array $platform): void INSTALLER_ARTIFACT_SERVER: installer-artifacts INSTALLER_DOCKER_NETWORK: installer-tests INSTALLER_REPOSITORY_URL: http://installer-artifacts - KUBERNETES_CPU_REQUEST: 2 - KUBERNETES_MEMORY_REQUEST: 2Gi - KUBERNETES_MEMORY_LIMIT: 4Gi + KUBERNETES_CPU_REQUEST: 8 + KUBERNETES_MEMORY_REQUEST: 8Gi + KUBERNETES_MEMORY_LIMIT: 16Gi RUST_BACKTRACE: 1 before_script: @@ -1412,7 +1412,7 @@ function alpine_mimalloc(array $platform): void sleep 1 done script: - - make -C dockerfiles/verify_packages test_installer + - make -C dockerfiles/verify_packages -j 8 --output-sync=target test_installer after_script: - docker rm --force "$INSTALLER_ARTIFACT_SERVER" || true - docker network rm "$INSTALLER_DOCKER_NETWORK" || true From 5053265e34cc6b1b16a0b969b311fead3d4c6e45 Mon Sep 17 00:00:00 2001 From: Brian Marks Date: Sat, 21 Nov 2026 01:09:08 -0500 Subject: [PATCH 05/18] ci: shard benchmarks-tracer into phpbench, opcache and tea jobs benchmarks-tracer runs every part for the candidate, then rebuilds and reruns them all for the baseline, on one bare-metal runner (~68-72 min), and check-big-regressions waits for it. Run one part per matrix job, each still comparing candidate and baseline on the same machine, as dd-trace-rb, dd-trace-js and libdatadog do. Running both sides at once on one host (dd-trace-py's approach) does not fit here: install_all writes ddtrace.so into the shared PHP extension directory. runall.sh takes TRACER_PART. The sharded jobs patch the platform's run-benchmarks.sh, analyze-results.sh and post-pr-comment.sh at runtime (benchmark/ci-patch-bp-steps.sh) so that the baseline runs the candidate's runall.sh, parts a shard did not run are skipped, the analysis reuses the baseline branch the run step recorded, and each part gets its own PR comment. These belong in the benchmarking-platform dd-trace-php branch long term. --- .claude/ci/benchmarks.md | 6 +++--- .gitlab/BENCHMARKS.md | 2 ++ .gitlab/benchmarks.yml | 4 ++++ benchmark/ci-patch-bp-steps.sh | 26 ++++++++++++++++++++++++++ benchmark/runall.sh | 24 ++++++++++++++++-------- 5 files changed, 51 insertions(+), 11 deletions(-) create mode 100755 benchmark/ci-patch-bp-steps.sh diff --git a/.claude/ci/benchmarks.md b/.claude/ci/benchmarks.md index 0670f0a720..f1ef3695fe 100644 --- a/.claude/ci/benchmarks.md +++ b/.claude/ci/benchmarks.md @@ -8,7 +8,7 @@ | CI Job | Image | What it does | |--------|-------|--------------| -| `benchmarks-tracer` | `486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/benchmarking-platform:dd-trace-php-82-dev` | Runs PHP tracer microbenchmarks via the `benchmarking-platform` framework; skips automatically if no tracer-relevant files changed | +| `benchmarks-tracer` | `486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/benchmarking-platform:dd-trace-php-82-dev` | Runs PHP tracer microbenchmarks via the `benchmarking-platform` framework, one `TRACER_PART` (phpbench, phpbench-opcache, tea) 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 | | `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 | @@ -48,9 +48,9 @@ outside CI. **Local runs produce numbers incomparable to CI results**, but they are useful for before/after comparisons on the same machine and for verifying that benchmark code runs without errors. -The CI `benchmarks-tracer` job ultimately runs `make benchmarks`, +The CI `benchmarks-tracer` jobs ultimately run `make benchmarks`, `make benchmarks_opcache`, and `make benchmarks_tea` (via -`benchmark/runall.sh`). You can run these same targets locally inside a +`benchmark/runall.sh`, one per `TRACER_PART` matrix job). You can run these same targets locally inside a dev container. ### Running the benchmarks diff --git a/.gitlab/BENCHMARKS.md b/.gitlab/BENCHMARKS.md index ad24ce9f71..296d9e7bf7 100644 --- a/.gitlab/BENCHMARKS.md +++ b/.gitlab/BENCHMARKS.md @@ -12,6 +12,8 @@ All benchmark jobs are defined in `benchmarks.yml`. - Run on a dedicated bare-metal runner, then convert, upload and comment on the PR. - Steps live in the `dd-trace-php` branch of [benchmarking-platform](https://github.com/DataDog/benchmarking-platform). + - `benchmarks-tracer` runs one `TRACER_PART` (phpbench, phpbench-opcache, tea) per matrix job; + `benchmark/ci-patch-bp-steps.sh` patches the platform steps at runtime for that. - `check-big-regressions` gates `benchmarks-tracer` on regressions above the threshold defined on `bp-runner.fail-on-regression.yml`. - `macrobenchmarks`: k6 load test against a sample Laravel app, extends `.macrobenchmarks`. diff --git a/.gitlab/benchmarks.yml b/.gitlab/benchmarks.yml index d28b58d061..fe0cd6f7e4 100644 --- a/.gitlab/benchmarks.yml +++ b/.gitlab/benchmarks.yml @@ -220,6 +220,7 @@ workflow: echo "Tracer-related file changes detected - proceeding with benchmarks" fi - git clone --branch dd-trace-php https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ddbuild.io/DataDog/benchmarking-platform /platform && cd /platform + - if [ -n "${TRACER_PART:-}" ]; then "$CI_PROJECT_DIR/benchmark/ci-patch-bp-steps.sh" /platform; fi - ./steps/capture-hardware-software-info.sh # Keep submodules at the selected candidate and baseline revisions. - >- @@ -253,6 +254,9 @@ benchmarks-profiler: benchmarks-tracer: extends: .microbenchmarks rules: *benchmarks-tracer-rules + parallel: + matrix: + - TRACER_PART: [ phpbench, phpbench-opcache, tea ] artifacts: name: "reports" when: always diff --git a/benchmark/ci-patch-bp-steps.sh b/benchmark/ci-patch-bp-steps.sh new file mode 100755 index 0000000000..91192cca1d --- /dev/null +++ b/benchmark/ci-patch-bp-steps.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +# Usage: ci-patch-bp-steps.sh +set -euo pipefail + +steps="$1/steps" + +patch_file() { + local file="$1" expr="$2" + PATCH_EXPR="$expr" perl -0pi -e ' + my $n = eval $ENV{PATCH_EXPR}; + die "pattern did not match in $ARGV\n" unless $n; + ' "$file" +} + +run="$steps/run-benchmarks.sh" +patch_file "$run" 's{^( # Run benchmarks for baseline release\n)}{ cp "\$CANDIDATE_SRC/benchmark/runall.sh" "\$BASELINE_SRC/benchmark/runall.sh"\n$1}m' +patch_file "$run" 's{^( awk [^\n]*tracer-bench-results-opcache\.csv > [^\n]*\n mv [^\n]*tracer-bench-results-opcache\.csv) && \\\n}{ if [ -f \$ARTIFACTS_DIR/tracer-bench-results-opcache.csv ]; then\n$1\n fi\n}m' +patch_file "$run" 's{^([ \t]*)cp (\$ARTIFACTS_DIR/tracer-[a-z-]+\.(?:csv|json)) "\$OUTPUT_DIR"$}{$1if [ -f $2 ]; then cp $2 "\$OUTPUT_DIR"; fi}mg' + +comment="$steps/post-pr-comment.sh" +patch_file "$comment" 's{--header="Benchmarks \[ \$SCENARIO \]"}{--header="Benchmarks [ \$SCENARIO \$TRACER_PART ]"}' + +analyze="$steps/analyze-results.sh" +patch_file "$analyze" 's{^([ \t]*)BASELINE_BRANCH=\$\(github-find-merge-into-branch ([^\n]*) \|\| :\)$}{$1BASELINE_BRANCH=\$(cat "\$ARTIFACTS_DIR/baseline_branch.txt" 2>/dev/null || github-find-merge-into-branch $2 || :)}m' +patch_file "$analyze" 's{^([ \t]*)(benchmark_analyzer convert \\\n(?:[^\n]*\\\n)*?\s*("\$ARTIFACTS_DIR/(?:candidate|baseline)/\$\{SCENARIO\}-(?:bench-results(?:-opcache)?\.csv|tea-bench-results\.json)")\n)}{$1if [ -f $3 ]; then\n$1$2$1fi\n}mg' +patch_file "$analyze" 's{^([ \t]*)(benchmark_analyzer compare pairwise \\\n(?:[^\n]*\\\n)*?)\s*"\$ARTIFACTS_DIR/baseline_\$\{SCENARIO\}_bench\.converted\.json"[^\n]*\\\n[^\n]*bench_opcache[^\n]*\\\n[^\n]*tea_bench[^\n]*\n}{$1pairs=()\n$1for p in bench bench_opcache tea_bench; do\n$1 b="\$ARTIFACTS_DIR/baseline_\${SCENARIO}_\$p.converted.json"; c="\$ARTIFACTS_DIR/candidate_\${SCENARIO}_\$p.converted.json"\n$1 if [ -f "\$b" ] && [ -f "\$c" ]; then pairs+=("\$b" "\$c"); fi\n$1done\n$1$2$1 "\${pairs[\@]}"\n}m' diff --git a/benchmark/runall.sh b/benchmark/runall.sh index 4b6f1a37e1..d396eb2be9 100755 --- a/benchmark/runall.sh +++ b/benchmark/runall.sh @@ -44,19 +44,27 @@ elif [ "$SCENARIO" = "tracer" ]; then make composer_tests_update make_combined benchmarks_run_dependencies + part="${TRACER_PART:-}" + ## Non-OPCache Benchmarks - make_combined call_benchmarks - cp tests/Benchmarks/reports/tracer-bench-results.csv "$ARTIFACTS_DIR/tracer-bench-results.csv" + if [ -z "$part" ] || [ "$part" = phpbench ]; then + make_combined call_benchmarks + cp tests/Benchmarks/reports/tracer-bench-results.csv "$ARTIFACTS_DIR/tracer-bench-results.csv" + fi ## OPCache Benchmarks - # Start from a cleared Symfony cache, like the non-OPCache run. - make_combined benchmarks_run_dependencies - make_combined call_benchmarks_opcache - cp tests/Benchmarks/reports/tracer-bench-results-opcache.csv "$ARTIFACTS_DIR/tracer-bench-results-opcache.csv" + if [ -z "$part" ] || [ "$part" = phpbench-opcache ]; then + # Start from a cleared Symfony cache, like the non-OPCache run. + make_combined benchmarks_run_dependencies + make_combined call_benchmarks_opcache + cp tests/Benchmarks/reports/tracer-bench-results-opcache.csv "$ARTIFACTS_DIR/tracer-bench-results-opcache.csv" + fi ## Request Startup/Shutdown Benchmarks - make benchmarks_tea - cp tea/benchmarks/reports/tracer-tea-bench-results.json "$ARTIFACTS_DIR/tracer-tea-bench-results.json" + if [ -z "$part" ] || [ "$part" = tea ]; then + make benchmarks_tea + cp tea/benchmarks/reports/tracer-tea-bench-results.json "$ARTIFACTS_DIR/tracer-tea-bench-results.json" + fi elif [ "$SCENARIO" = "appsec" ]; then # Run Appsec Benchmarks # AppSec itself is enabled only in the measured web servers, by From 6809327b4eb23ad2f27bb00fa82480dac364e878 Mon Sep 17 00:00:00 2001 From: Brian Marks Date: Sat, 21 Nov 2026 01:09:09 -0500 Subject: [PATCH 06/18] ci: skip the repository clone in system-tests jobs System-tests jobs cloned dd-trace-php (85-100 s through the git cache) only to run a few .gitlab helper scripts; everything else comes from artifacts and the system-tests checkout. Ship those scripts with the prepare code artifacts and set GIT_STRATEGY: none. --- .claude/ci/system-tests.md | 4 +++- .gitlab/generate-package.php | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.claude/ci/system-tests.md b/.claude/ci/system-tests.md index c324393a41..b4ea7b1eb0 100644 --- a/.claude/ci/system-tests.md +++ b/.claude/ci/system-tests.md @@ -5,7 +5,9 @@ **Source:** `.gitlab/generate-package.php` -- the `.system_tests` template and individual job definitions immediately below it. The template defines the base image, `before_script` (Docker + Python setup, clone of `system-tests` repo, -artifact placement, `./build.sh`), and artifact collection. Each concrete job +artifact placement, `./build.sh`), and artifact collection. The jobs set +`GIT_STRATEGY: none`: the `.gitlab` helpers they run come with the `prepare code` +artifacts. Each concrete job extends this template and runs `./run.sh` with the appropriate scenario. | CI Job | Weblog | Scenario argument | What it does | diff --git a/.gitlab/generate-package.php b/.gitlab/generate-package.php index a71e0409b5..332e0095e5 100644 --- a/.gitlab/generate-package.php +++ b/.gitlab/generate-package.php @@ -323,6 +323,11 @@ function alpine_mimalloc(array $platform): void paths: - VERSION - ./src/bridge/_generated*.php + - .gitlab/dockerhub-login.sh + - .gitlab/silent-upload-junit-to-datadog.sh + - .gitlab/upload-junit-to-datadog.sh + - .gitlab/download-file.sh + - .gitlab/transient-curl-error.sh reports: dotenv: system-tests.env @@ -1844,6 +1849,7 @@ function alpine_mimalloc(array $platform): void image: $SYSTEM_TESTS_CI_IMAGE tags: [ "docker-in-docker:amd64" ] variables: + GIT_STRATEGY: none GIT_SUBMODULE_STRATEGY: none TEST_LIBRARY: php KUBERNETES_CPU_REQUEST: 8 From fb64b0d741255fad1b4276adf2c5caeb0b0d38ce Mon Sep 17 00:00:00 2001 From: Brian Marks Date: Sat, 21 Nov 2026 01:09:10 -0500 Subject: [PATCH 07/18] ci: build system-tests weblogs with the docker driver With USE_IMAGE_MIRROR=1, build.sh builds on a docker-container buildx builder and then exports the whole image into the daemon: ~2 of the ~3.4 min weblog build. Pull the weblog's locked base images from the system-tests mirror and tag them with their Docker Hub names, then run build.sh with USE_IMAGE_MIRROR=0 so it builds on the default docker driver straight into the daemon. Scenario services still come through the mirror. Prune the build cache afterwards, as removing the mirror builder used to, to keep disk free for the scenarios. --- .claude/ci/system-tests.md | 4 +++- .gitlab/generate-package.php | 13 ++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.claude/ci/system-tests.md b/.claude/ci/system-tests.md index b4ea7b1eb0..49c78196d5 100644 --- a/.claude/ci/system-tests.md +++ b/.claude/ci/system-tests.md @@ -7,7 +7,9 @@ individual job definitions immediately below it. The template defines the base image, `before_script` (Docker + Python setup, clone of `system-tests` repo, artifact placement, `./build.sh`), and artifact collection. The jobs set `GIT_STRATEGY: none`: the `.gitlab` helpers they run come with the `prepare code` -artifacts. Each concrete job +artifacts. Weblogs build on the default docker driver (`USE_IMAGE_MIRROR=0`) +after their locked base images are pulled from the system-tests mirror and tagged +with their Docker Hub names; scenarios still use the mirror. Each concrete job extends this template and runs `./run.sh` with the appropriate scenario. | CI Job | Weblog | Scenario argument | What it does | diff --git a/.gitlab/generate-package.php b/.gitlab/generate-package.php index 332e0095e5..175732ac7c 100644 --- a/.gitlab/generate-package.php +++ b/.gitlab/generate-package.php @@ -1890,11 +1890,18 @@ function alpine_mimalloc(array $platform): void - ln -sf /system-tests/venv venv - source venv/bin/activate - export PYTHONPATH="$CI_PROJECT_DIR/system-tests" - - if [ -n "$BUILD_SH_ARGS" ]; then ./build.sh $BUILD_SH_ARGS; fi - # The mirror builder keeps another copy of the weblog layers and of the library bundle in its build context. + - | + if [ -n "$BUILD_SH_ARGS" ]; then + weblog=$(echo " $BUILD_SH_ARGS " | sed -n 's/.* -w \([^ ]*\) .*/\1/p') + for image in $(python3 utils/scripts/resolve-base-images-contexts.py --build-contexts "utils/build/docker/php/${weblog:-apache-mod-8.0}.Dockerfile" | sed 's|^[^=]*=docker-image://||'); do + { docker pull -q "registry.ddbuild.io/system-tests/mirror/$image" && docker tag "registry.ddbuild.io/system-tests/mirror/$image" "$image"; } || exit 75 + done + USE_IMAGE_MIRROR=0 ./build.sh $BUILD_SH_ARGS + fi + # The build cache keeps another copy of the weblog layers and of the library bundle in its build context. # The scenarios only run the loaded images: free that space for their services, RabbitMQ blocks publishers # below 50 MB of free disk. - - docker buildx rm --force system-tests-mirror 2>/dev/null || true + - docker builder prune -af 2>/dev/null || true - docker system df || true after_script: - DATADOG_API_KEY=$(cat /tmp/.dd-api-key 2>/dev/null) || true From fd06a2464f0f62689a4f4da53b0b89079b0dda38 Mon Sep 17 00:00:00 2001 From: Brian Marks Date: Sat, 21 Nov 2026 01:09:11 -0500 Subject: [PATCH 08/18] ci: shard tracer-release system tests 8 ways Each 4-way shard takes ~46 min of a ~149 min scenario budget. At 8 ways the shards measured 23-27 min. --- .gitlab/generate-package.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab/generate-package.php b/.gitlab/generate-package.php index 175732ac7c..6afc011d36 100644 --- a/.gitlab/generate-package.php +++ b/.gitlab/generate-package.php @@ -1983,7 +1983,7 @@ function alpine_mimalloc(array $platform): void // Pack the tracer-release scenarios longest-first into the least-loaded shard, from measured durations // (refresh them with .gitlab/refresh-system-tests-durations.py). Every weblog takes ~the same time per scenario. -$system_tests_shard_count = 4; +$system_tests_shard_count = 8; $system_tests_durations = json_decode(file_get_contents(__DIR__ . "/system-tests-durations.json"), true)["scenarios"]; arsort($system_tests_durations); $system_tests_shards = array_fill(0, $system_tests_shard_count, []); @@ -2005,8 +2005,8 @@ function alpine_mimalloc(array $platform): void "System Tests: [, tracer-release]": extends: [ .system_tests, .system_tests_tracer_release_shards ] parallel: - # ~2x the expected worst shard (~52 min), so a hung DinD job is retried sooner. - timeout: 1h 45m + # ~2x the expected worst shard (~27 min), so a hung DinD job is retried sooner. + timeout: 55m variables: BUILD_SH_ARGS: "-i weblog -w php" # Expand the DinD loopback volume to avoid running out of disk space. From 563a2dcb6a02f53f4208dede76e4c9979837365d Mon Sep 17 00:00:00 2001 From: Brian Marks Date: Sat, 21 Nov 2026 01:09:12 -0500 Subject: [PATCH 09/18] ci: build tracer-release Rust with 16 codegen units tracer-release sets codegen-units = 1, so rustc compiles each crate on one thread and the final ThinLTO link spends its last ~50 s on the largest single-crate module (lld time trace: 255 modules, on average 7.8 of 64 threads busy). Override it to 16 for every package-pipeline build, so the SSI common identity check still compares like with like. With mimalloc on Alpine this makes the Rust/LTO compile jobs 2-3x faster, but the unstripped ddtrace.so grows ~19% (49.7 -> 59.3 MB on arm64 musl). Kept as a separate commit so it can be dropped. --- .gitlab/generate-package.php | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab/generate-package.php b/.gitlab/generate-package.php index 6afc011d36..39080acf0c 100644 --- a/.gitlab/generate-package.php +++ b/.gitlab/generate-package.php @@ -198,6 +198,7 @@ function alpine_mimalloc(array $platform): void RELIABILITY_ENV_BRANCH: "master" SYSTEM_TESTS_LIBRARY: php CARGO_HOME: "${CI_PROJECT_DIR}/.cache/cargo" + CARGO_PROFILE_TRACER_RELEASE_CODEGEN_UNITS: "16" # One pipeline injection package size ratchet. # LIB_INJECTION_IMAGE_MAX_SIZE_BYTES was set to 210M in April as a tightening From 9a8c339599002a92ebfbff0d643bd7f943e2234b Mon Sep 17 00:00:00 2001 From: datadog-bits <263423550+datadog-bits@users.noreply.github.com> Date: Tue, 24 Nov 2026 14:15:12 +0000 Subject: [PATCH 10/18] ci: fail on unknown TRACER_PART or missing benchmark shard results runall.sh now rejects unknown TRACER_PART values before building, and check-big-regressions requires the baseline and candidate converted results of all three benchmarks-tracer parts, so a missing part fails the gate instead of passing on the remaining ones. Co-Authored-By: Claude Opus 5.5 (1M context) Co-authored-by: bm1549 <12128670+bm1549@users.noreply.github.com> --- .claude/ci/benchmarks.md | 2 +- .gitlab/benchmarks.yml | 8 ++++++++ benchmark/runall.sh | 5 +++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.claude/ci/benchmarks.md b/.claude/ci/benchmarks.md index f1ef3695fe..7e9c5263a4 100644 --- a/.claude/ci/benchmarks.md +++ b/.claude/ci/benchmarks.md @@ -12,7 +12,7 @@ | `benchmarks-appsec` | same | Runs appsec microbenchmarks; produces `candidate.tar.gz` and `baseline.tar.gz` artifacts | | `benchmarks-profiler` | same | Runs profiler microbenchmarks | | `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 | +| `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 shard's baseline or candidate results 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 | diff --git a/.gitlab/benchmarks.yml b/.gitlab/benchmarks.yml index fe0cd6f7e4..f06ee8e7ea 100644 --- a/.gitlab/benchmarks.yml +++ b/.gitlab/benchmarks.yml @@ -339,6 +339,14 @@ check-big-regressions: exit 1 else echo "Reports directory found with content - running regression check" + for part in bench bench_opcache tea_bench; do + for side in baseline candidate; do + if [ ! -f "reports/${side}_tracer_${part}.converted.json" ]; then + echo "ERROR: reports/${side}_tracer_${part}.converted.json is missing - a benchmarks-tracer shard had issues" + exit 1 + fi + done + done export ARTIFACTS_DIR="$(pwd)/reports/" if [[ -n "$CI_JOB_TOKEN" ]]; then git config --global url."https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ddbuild.io/DataDog/".insteadOf "https://github.com/DataDog/" diff --git a/benchmark/runall.sh b/benchmark/runall.sh index d396eb2be9..35de5213ff 100755 --- a/benchmark/runall.sh +++ b/benchmark/runall.sh @@ -14,6 +14,9 @@ export DDTRACE_PROFILING_FEATURES=trigger_time_sample # The benchmark platform runs a real agent: keep remote configuration it could # deliver from changing the behaviour being measured. export DD_REMOTE_CONFIG_ENABLED=false +# benchmarks-tracer runs one part per matrix job; unset runs every part. +part="${TRACER_PART:-}" +case "$part" in ''|phpbench|phpbench-opcache|tea) ;; *) echo "unknown TRACER_PART=$part" >&2; exit 1 ;; esac cd .. COMBINED_SO=tmp/build_combined/modules/ddtrace.so if [ -z "${DD_TRACE_ASSUME_COMPILED:-}" ]; then @@ -44,8 +47,6 @@ elif [ "$SCENARIO" = "tracer" ]; then make composer_tests_update make_combined benchmarks_run_dependencies - part="${TRACER_PART:-}" - ## Non-OPCache Benchmarks if [ -z "$part" ] || [ "$part" = phpbench ]; then make_combined call_benchmarks From 7319fbbbc0a486bfc361d4149a2be4685e7d8237 Mon Sep 17 00:00:00 2001 From: datadog-bits <263423550+datadog-bits@users.noreply.github.com> Date: Tue, 24 Nov 2026 14:15:23 +0000 Subject: [PATCH 11/18] ci: install mimalloc in the Alpine compile image Ship mimalloc2-insecure in the alpine_compile_extension base image, next to bindgen-cli, instead of fetching it unpinned from Alpine community in every musl compile job. The jobs still LD_PRELOAD it, and fail with a clear message if the image predates this change. Co-Authored-By: Claude Opus 5.5 (1M context) Co-authored-by: bm1549 <12128670+bm1549@users.noreply.github.com> --- .claude/ci/compile-artifacts.md | 5 +++-- .gitlab/generate-package.php | 3 ++- dockerfiles/ci/alpine_compile_extension/base.Dockerfile | 4 ++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.claude/ci/compile-artifacts.md b/.claude/ci/compile-artifacts.md index ebfe94451c..fc320f0ec1 100644 --- a/.claude/ci/compile-artifacts.md +++ b/.claude/ci/compile-artifacts.md @@ -184,8 +184,9 @@ See `.gitlab/generate-package.php` for the exact per-platform `needs:` lists. LTO and SSI jobs have no explicit `cache:` block, but they do build Rust. - The musl compile jobs (combined, SSI combined, sidecar and the PHP 7.0 jobs) - `apk add mimalloc2-insecure` and `LD_PRELOAD` it: Alpine's rustc links scudo and - clang/lld use musl's malloc, which spend much of a parallel build in the kernel. + `LD_PRELOAD` the `mimalloc2-insecure` the Alpine image installs and fail if it + is missing: Alpine's rustc links scudo and clang/lld use musl's malloc, which + spend much of a parallel build in the kernel. - Windows compile jobs use Docker on the Windows runner (not DinD): the script starts a long-lived container with `docker run -d`, then drives it via `docker exec`. The diff --git a/.gitlab/generate-package.php b/.gitlab/generate-package.php index 92b7dc2f7c..6384e27d30 100644 --- a/.gitlab/generate-package.php +++ b/.gitlab/generate-package.php @@ -163,7 +163,8 @@ function alpine_mimalloc(array $platform): void return; } ?> - - apk add -q --no-cache mimalloc2-insecure || exit 75 + # Installed by dockerfiles/ci/alpine_compile_extension/base.Dockerfile. + - test -f /usr/lib/libmimalloc-insecure.so.2 || { echo "mimalloc is missing from $CI_JOB_IMAGE, rebuild the Alpine CI images" >&2; exit 1; } - export LD_PRELOAD=/usr/lib/libmimalloc-insecure.so.2 Date: Tue, 24 Nov 2026 14:15:23 +0000 Subject: [PATCH 12/18] ci: drop unused PHP 7.0 standalone artifacts package loader reads only standalone_*/ddtrace-20151012*.so, which come from the PHP 7.0 SSI job, so it no longer needs the static PHP 7.0 job. That job's remaining standalone_* file was the GNU non-LTO -debug.so, which nothing reads (the shipped debug DSO is linked in the link job), so stop deleting its other DSOs and stop uploading standalone_* from it. Co-Authored-By: Claude Opus 5.5 (1M context) Co-authored-by: bm1549 <12128670+bm1549@users.noreply.github.com> --- .claude/ci/compile-artifacts.md | 2 +- .gitlab/generate-package.php | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.claude/ci/compile-artifacts.md b/.claude/ci/compile-artifacts.md index fc320f0ec1..4168c863e8 100644 --- a/.claude/ci/compile-artifacts.md +++ b/.claude/ci/compile-artifacts.md @@ -71,7 +71,7 @@ stage. `make generate` produces three files via `classpreloader`: |--------|-------|--------------| | `prepare code` | `composer:2.10.3` | `.gitlab/append-build-id.sh` (bumps VERSION first) + `composer update` + `make generate`; produces VERSION + generated bridge files | | `cache cargo deps: [{arch}, {triplet}]` | `dd-trace-ci:php-8.1_{platform}` (alpine uses `php-compile-extension-alpine-8.1`) | `cargo fetch` to warm the Cargo cache for the given target triplet | -| `compile tracing extension: [7.0, {arch}, {triplet}]` | `dd-trace-ci:php-7.0_{platform}` | Tracer-only static path: `build-tracing.sh` produces legacy C archives (and the GNU-only non-LTO debug DSO) plus legacy link metadata. Needs only `prepare code`. | +| `compile tracing extension: [7.0, {arch}, {triplet}]` | `dd-trace-ci:php-7.0_{platform}` | Tracer-only static path: `build-tracing.sh` produces legacy C archives (including the GNU-only non-LTO debug archive) plus legacy link metadata. The DSOs it writes to `standalone_{arch}/` are not kept. Needs only `prepare code`. | | `compile tracing extension LTO: [7.0, {arch}, {triplet}, {nts,zts}]` | `dd-trace-ci:php-7.0_{platform}` | `make xlang-lto` for one flavour; outputs the self-contained NTS or ZTS DSO in `extensions_{arch}/`. Needs only `prepare code`. | | `compile tracing extension SSI: [7.0, {arch}, {triplet}]` | `dd-trace-ci:php-7.0_{platform}` | `make build-ssi-ddtrace` for NTS then ZTS; rebuilds common without a PHP-ABI archive and checks it against the sidecar job’s canonical DSO. Outputs `standalone_{arch}/`. | | `compile tracing sidecar: [{arch}, {triplet}]` | `dd-trace-ci:php-8.1_{platform}` | `build-sidecar.sh` uses `build-xlang-lto ssi-common` to build `libdatadog_php_{arch}[-alpine].so` (common runtime plus embedded AppSec helper), once per platform. Also retains a Rust archive solely for the legacy debug link; it is not shipped. | diff --git a/.gitlab/generate-package.php b/.gitlab/generate-package.php index 6384e27d30..b8b6f8ea61 100644 --- a/.gitlab/generate-package.php +++ b/.gitlab/generate-package.php @@ -468,11 +468,9 @@ function alpine_mimalloc(array $platform): void # Fix for $BASH_ENV not having a newline at the end of the file - echo "" >> "$BASH_ENV" - ./.gitlab/build-tracing.sh "" - - rm -f "standalone_/ddtrace-${ABI_NO}.so" "standalone_/ddtrace-${ABI_NO}-zts.so" artifacts: paths: - "extensions_*" - - "standalone_*" - "ddtrace_*-fat.ldflags" - "ddtrace_*-fat.sym" @@ -1030,8 +1028,6 @@ function alpine_mimalloc(array $platform): void if ($platform["arch"] == $arch): ?> # PHP 7.0 still uses the split SSI extension (tracer and AppSec only). - - job: "compile tracing extension: [7.0, , ]" - artifacts: true - job: "compile tracing extension SSI: [7.0, , ]" artifacts: true - job: "compile tracing sidecar: [, ]" From 75f765b2b9812c86b9170ef6dc5f720ba96889ac Mon Sep 17 00:00:00 2001 From: datadog-bits <263423550+datadog-bits@users.noreply.github.com> Date: Tue, 24 Nov 2026 16:02:58 +0000 Subject: [PATCH 13/18] ci: keep one codegen unit on master, release branches and tags Only PR branches build tracer-release Rust with 16 codegen units. Master, ddtrace-* and release-* branches and tag pipelines keep the profile's single unit, so the shipped artifacts keep the smaller size #2696 chose. Co-Authored-By: Claude Opus 5.5 (1M context) Co-authored-by: bm1549 <12128670+bm1549@users.noreply.github.com> --- .claude/ci/compile-artifacts.md | 5 +++++ .gitlab/generate-package.php | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/.claude/ci/compile-artifacts.md b/.claude/ci/compile-artifacts.md index 4168c863e8..7e6c346b1e 100644 --- a/.claude/ci/compile-artifacts.md +++ b/.claude/ci/compile-artifacts.md @@ -188,6 +188,11 @@ See `.gitlab/generate-package.php` for the exact per-platform `needs:` lists. is missing: Alpine's rustc links scudo and clang/lld use musl's malloc, which spend much of a parallel build in the kernel. +- PR branch pipelines set `CARGO_PROFILE_TRACER_RELEASE_CODEGEN_UNITS=16`, which + roughly halves the Rust build. Master, `ddtrace-*`, `release-*` branches and + tags keep the profile's single codegen unit, so PR binaries are ~16-19% larger + than the shipped ones (relevant when a size check differs between the two). + - Windows compile jobs use Docker on the Windows runner (not DinD): the script starts a long-lived container with `docker run -d`, then drives it via `docker exec`. The `GIT_STRATEGY: none` variable means the runner does not clone the repo -- instead the diff --git a/.gitlab/generate-package.php b/.gitlab/generate-package.php index b8b6f8ea61..85dd59cc6e 100644 --- a/.gitlab/generate-package.php +++ b/.gitlab/generate-package.php @@ -93,6 +93,10 @@ function system_tests_run_scenarios(string $scenarios): void // No list (master, releases, tags, schedules, web/api runs, or a git failure) means every job runs. $branch_changed_files = array_filter(explode("\n", (string)@file_get_contents(__DIR__ . "/changed-files.txt"))); +// Shipping builds keep tracer-release's single codegen unit (#2696). +$pr_branch_build = (string)getenv('CI_COMMIT_TAG') === '' + && !preg_match('(^(master|ddtrace-.*|release-.*)$)', (string)getenv('CI_COMMIT_BRANCH')); + // A PR branch runs these job families only when it changes one of their paths; master and the rest run them always. // Generic build inputs (sources, config.m4, shared build scripts) stay out: the always-on compile and test jobs cover them. $generator_paths = [".gitlab/generate-package.php", ".gitlab/generate-common.php"]; @@ -199,7 +203,9 @@ function alpine_mimalloc(array $platform): void RELIABILITY_ENV_BRANCH: "master" SYSTEM_TESTS_LIBRARY: php CARGO_HOME: "${CI_PROJECT_DIR}/.cache/cargo" + CARGO_PROFILE_TRACER_RELEASE_CODEGEN_UNITS: "16" + # One pipeline injection package size ratchet. # LIB_INJECTION_IMAGE_MAX_SIZE_BYTES was set to 210M in April as a tightening From c9232d432d07ff435b7615616880b9c3942a423c Mon Sep 17 00:00:00 2001 From: Brian Marks Date: Tue, 24 Nov 2026 11:34:11 -0500 Subject: [PATCH 14/18] ci: drop the benchmarking-platform step patcher benchmarking-platform's dd-trace-php steps now save, convert and compare only the TRACER_PART a job sets (DataDog/benchmarking-platform#346), so the runtime patch of /platform is no longer needed. #346 must merge before this does. Co-Authored-By: Claude Opus 5.5 (1M context) --- .claude/ci/benchmarks.md | 2 +- .gitlab/BENCHMARKS.md | 4 ++-- .gitlab/benchmarks.yml | 1 - benchmark/ci-patch-bp-steps.sh | 26 -------------------------- 4 files changed, 3 insertions(+), 30 deletions(-) delete mode 100755 benchmark/ci-patch-bp-steps.sh diff --git a/.claude/ci/benchmarks.md b/.claude/ci/benchmarks.md index 7e9c5263a4..aafa68e978 100644 --- a/.claude/ci/benchmarks.md +++ b/.claude/ci/benchmarks.md @@ -8,7 +8,7 @@ | CI Job | Image | What it does | |--------|-------|--------------| -| `benchmarks-tracer` | `486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/benchmarking-platform:dd-trace-php-82-dev` | Runs PHP tracer microbenchmarks via the `benchmarking-platform` framework, one `TRACER_PART` (phpbench, phpbench-opcache, tea) per matrix job; skips automatically if no tracer-relevant files changed | +| `benchmarks-tracer` | `486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/benchmarking-platform:dd-trace-php-82-dev` | Runs PHP tracer microbenchmarks via the `benchmarking-platform` framework, one `TRACER_PART` (phpbench, phpbench-opcache, tea) per matrix job, which the platform steps handle natively (DataDog/benchmarking-platform#346); 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 | | `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 | diff --git a/.gitlab/BENCHMARKS.md b/.gitlab/BENCHMARKS.md index 296d9e7bf7..b6fd526514 100644 --- a/.gitlab/BENCHMARKS.md +++ b/.gitlab/BENCHMARKS.md @@ -12,8 +12,8 @@ All benchmark jobs are defined in `benchmarks.yml`. - Run on a dedicated bare-metal runner, then convert, upload and comment on the PR. - Steps live in the `dd-trace-php` branch of [benchmarking-platform](https://github.com/DataDog/benchmarking-platform). - - `benchmarks-tracer` runs one `TRACER_PART` (phpbench, phpbench-opcache, tea) per matrix job; - `benchmark/ci-patch-bp-steps.sh` patches the platform steps at runtime for that. + - `benchmarks-tracer` runs one `TRACER_PART` (phpbench, phpbench-opcache, tea) per matrix job. + The platform steps handle `TRACER_PART` themselves (DataDog/benchmarking-platform#346). - `check-big-regressions` gates `benchmarks-tracer` on regressions above the threshold defined on `bp-runner.fail-on-regression.yml`. - `macrobenchmarks`: k6 load test against a sample Laravel app, extends `.macrobenchmarks`. diff --git a/.gitlab/benchmarks.yml b/.gitlab/benchmarks.yml index f06ee8e7ea..3afd7a0273 100644 --- a/.gitlab/benchmarks.yml +++ b/.gitlab/benchmarks.yml @@ -220,7 +220,6 @@ workflow: echo "Tracer-related file changes detected - proceeding with benchmarks" fi - git clone --branch dd-trace-php https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ddbuild.io/DataDog/benchmarking-platform /platform && cd /platform - - if [ -n "${TRACER_PART:-}" ]; then "$CI_PROJECT_DIR/benchmark/ci-patch-bp-steps.sh" /platform; fi - ./steps/capture-hardware-software-info.sh # Keep submodules at the selected candidate and baseline revisions. - >- diff --git a/benchmark/ci-patch-bp-steps.sh b/benchmark/ci-patch-bp-steps.sh deleted file mode 100755 index 91192cca1d..0000000000 --- a/benchmark/ci-patch-bp-steps.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash -# Usage: ci-patch-bp-steps.sh -set -euo pipefail - -steps="$1/steps" - -patch_file() { - local file="$1" expr="$2" - PATCH_EXPR="$expr" perl -0pi -e ' - my $n = eval $ENV{PATCH_EXPR}; - die "pattern did not match in $ARGV\n" unless $n; - ' "$file" -} - -run="$steps/run-benchmarks.sh" -patch_file "$run" 's{^( # Run benchmarks for baseline release\n)}{ cp "\$CANDIDATE_SRC/benchmark/runall.sh" "\$BASELINE_SRC/benchmark/runall.sh"\n$1}m' -patch_file "$run" 's{^( awk [^\n]*tracer-bench-results-opcache\.csv > [^\n]*\n mv [^\n]*tracer-bench-results-opcache\.csv) && \\\n}{ if [ -f \$ARTIFACTS_DIR/tracer-bench-results-opcache.csv ]; then\n$1\n fi\n}m' -patch_file "$run" 's{^([ \t]*)cp (\$ARTIFACTS_DIR/tracer-[a-z-]+\.(?:csv|json)) "\$OUTPUT_DIR"$}{$1if [ -f $2 ]; then cp $2 "\$OUTPUT_DIR"; fi}mg' - -comment="$steps/post-pr-comment.sh" -patch_file "$comment" 's{--header="Benchmarks \[ \$SCENARIO \]"}{--header="Benchmarks [ \$SCENARIO \$TRACER_PART ]"}' - -analyze="$steps/analyze-results.sh" -patch_file "$analyze" 's{^([ \t]*)BASELINE_BRANCH=\$\(github-find-merge-into-branch ([^\n]*) \|\| :\)$}{$1BASELINE_BRANCH=\$(cat "\$ARTIFACTS_DIR/baseline_branch.txt" 2>/dev/null || github-find-merge-into-branch $2 || :)}m' -patch_file "$analyze" 's{^([ \t]*)(benchmark_analyzer convert \\\n(?:[^\n]*\\\n)*?\s*("\$ARTIFACTS_DIR/(?:candidate|baseline)/\$\{SCENARIO\}-(?:bench-results(?:-opcache)?\.csv|tea-bench-results\.json)")\n)}{$1if [ -f $3 ]; then\n$1$2$1fi\n}mg' -patch_file "$analyze" 's{^([ \t]*)(benchmark_analyzer compare pairwise \\\n(?:[^\n]*\\\n)*?)\s*"\$ARTIFACTS_DIR/baseline_\$\{SCENARIO\}_bench\.converted\.json"[^\n]*\\\n[^\n]*bench_opcache[^\n]*\\\n[^\n]*tea_bench[^\n]*\n}{$1pairs=()\n$1for p in bench bench_opcache tea_bench; do\n$1 b="\$ARTIFACTS_DIR/baseline_\${SCENARIO}_\$p.converted.json"; c="\$ARTIFACTS_DIR/candidate_\${SCENARIO}_\$p.converted.json"\n$1 if [ -f "\$b" ] && [ -f "\$c" ]; then pairs+=("\$b" "\$c"); fi\n$1done\n$1$2$1 "\${pairs[\@]}"\n}m' From db3ca52d0bc14a4fde2c14e8ebdf52ec969b6e01 Mon Sep 17 00:00:00 2001 From: Brian Marks Date: Tue, 24 Nov 2026 14:26:56 -0500 Subject: [PATCH 15/18] ci: give installer tests a 50G DinD loopback Running test_installer with -j 8 overlaps several full-bundle installs and image pulls on the DinD daemon's loopback disk, which defaults to 20G. Every -j 8 run filled it, and one failed with ENOSPC. Serial runs used about 11.5G. A run with DOCKER_LOOPBACK_SIZE=50G passed in the same time and wrote about 31G. system-tests jobs already use 50G. --- .claude/ci/package-dind-verification.md | 5 +++++ .gitlab/generate-package.php | 2 ++ 2 files changed, 7 insertions(+) diff --git a/.claude/ci/package-dind-verification.md b/.claude/ci/package-dind-verification.md index 61cf3b2e7c..98fcc6670a 100644 --- a/.claude/ci/package-dind-verification.md +++ b/.claude/ci/package-dind-verification.md @@ -391,6 +391,11 @@ kill %1 # stop HTTP server even on an amd64 runner, because `datadog-setup.php` is tested for its ability to select the correct package. +- **`installer tests` sets `DOCKER_LOOPBACK_SIZE: 50G`.** Images and test + containers live on the DinD loopback, which defaults to 20G. With `-j 8`, + overlapping full-bundle extractions fill 20G (a 50G run wrote ~31G); serial + runs used ~11.5G. + - **`installer tests` VERSION mismatch.** The installer compares the installed extension version against `VERSION`. CI runs `append-build-id.sh` which bumps it (e.g. `1.17.0` -> `1.18.0+`). Without this step, tests fail with diff --git a/.gitlab/generate-package.php b/.gitlab/generate-package.php index 85dd59cc6e..770e686246 100644 --- a/.gitlab/generate-package.php +++ b/.gitlab/generate-package.php @@ -1371,6 +1371,8 @@ function alpine_mimalloc(array $platform): void INSTALLER_ARTIFACT_SERVER: installer-artifacts INSTALLER_DOCKER_NETWORK: installer-tests INSTALLER_REPOSITORY_URL: http://installer-artifacts + # Expand the DinD loopback volume to avoid running out of disk space. + DOCKER_LOOPBACK_SIZE: 50G KUBERNETES_CPU_REQUEST: 8 KUBERNETES_MEMORY_REQUEST: 8Gi KUBERNETES_MEMORY_LIMIT: 16Gi From 669c4763266d08ca09bc8d6976a581f924265912 Mon Sep 17 00:00:00 2001 From: Brian Marks Date: Tue, 24 Nov 2026 14:59:07 -0500 Subject: [PATCH 16/18] ci: shard benchmarks-tracer on the in-repo bp-runner config master now runs the microbenchmarks from .gitlab/benchmarks/bp-runner.yml instead of the benchmarking-platform dd-trace-php branch, so the TRACER_PART handling moves there: - the run script renames only the selected part's results; - a baseline whose runall.sh predates TRACER_PART runs the candidate's copy, so it doesn't run every part; - the unprefixed OPCache CSV is removed after renaming, so a baseline that writes nothing fails instead of reusing the candidate's file; - check-big-regressions requires each part's candidate converted file, and the baseline one when there is a baseline branch, under the names bp-runner's analyze steps produce. benchmarks-pr-comment and check-big-regressions already need benchmarks-tracer, so they merge all three shards' reports and post one comment. --- .claude/ci/benchmarks.md | 4 ++-- .gitlab/benchmarks.yml | 10 ++++++---- .gitlab/benchmarks/README.md | 12 +++++++++--- .gitlab/benchmarks/bp-runner.yml | 23 +++++++++++++++++------ 4 files changed, 34 insertions(+), 15 deletions(-) diff --git a/.claude/ci/benchmarks.md b/.claude/ci/benchmarks.md index 52c20a010d..d7e5328ed6 100644 --- a/.claude/ci/benchmarks.md +++ b/.claude/ci/benchmarks.md @@ -10,7 +10,7 @@ | CI Job | Image | What it does | |--------|-------|--------------| -| `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; skips automatically if no tracer-relevant files changed | +| `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) 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 | @@ -18,7 +18,7 @@ | `benchmarks-pr-comment-profiler` | same | Same flow for the profiler, with its own comment header; needs `benchmarks-profiler` | | `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 | | `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 | +| `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-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 | diff --git a/.gitlab/benchmarks.yml b/.gitlab/benchmarks.yml index bde9f7cd65..79bacd1fb6 100644 --- a/.gitlab/benchmarks.yml +++ b/.gitlab/benchmarks.yml @@ -419,10 +419,12 @@ check-big-regressions: exit 1 else echo "Reports directory found with content - running regression check" - for part in bench bench_opcache tea_bench; do - for side in baseline candidate; do - if [ ! -f "reports/${side}_tracer_${part}.converted.json" ]; then - echo "ERROR: reports/${side}_tracer_${part}.converted.json is missing - a benchmarks-tracer shard had issues" + sides=candidate + if [ -s reports/baseline_branch.txt ]; then sides="baseline candidate"; fi + for result in tracer-bench-results tracer-bench-results-opcache tracer-tea-bench-results; do + for side in $sides; do + if [ ! -f "reports/${side}-${result}.converted.json" ]; then + echo "ERROR: reports/${side}-${result}.converted.json is missing - a benchmarks-tracer shard had issues" exit 1 fi done diff --git a/.gitlab/benchmarks/README.md b/.gitlab/benchmarks/README.md index 7bf8f0c256..0026930d42 100644 --- a/.gitlab/benchmarks/README.md +++ b/.gitlab/benchmarks/README.md @@ -43,7 +43,10 @@ Execution flow on each PR: runs `bp-runner .gitlab/benchmarks/bp-runner.yml`: hardware/software info capture, Datadog agent, one-time setup, then the candidate and baseline runs (the baseline is the PR's merge-target branch, at the merge base, - resolved by bp-runner's auto lookup). + resolved by bp-runner's auto lookup). `benchmarks-tracer` is a matrix of + three jobs, one per `TRACER_PART` (`phpbench`, `phpbench-opcache`, `tea`), + and `runall.sh` runs only that part. A baseline whose `runall.sh` predates + `TRACER_PART` runs the candidate's copy instead. 2. Each run's `benchmark/` suite results are saved as `reports/$BASELINE_OR_CANDIDATE-.` artifacts; only the AppSec job also uploads the logs, tarred as `candidate.tar.gz`/`baseline.tar.gz`. @@ -52,8 +55,11 @@ Execution flow on each PR: `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` gates the pipeline on regressions above the - threshold of 10% in `bp-runner.fail-on-regression.yml`, and +4. `check-big-regressions` and `benchmarks-pr-comment` merge the three + 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. ## How to add a new microbenchmark diff --git a/.gitlab/benchmarks/bp-runner.yml b/.gitlab/benchmarks/bp-runner.yml index 16f0e25ad1..e1f9659777 100644 --- a/.gitlab/benchmarks/bp-runner.yml +++ b/.gitlab/benchmarks/bp-runner.yml @@ -84,19 +84,30 @@ experiments: cd "$CODE_SRC/benchmark/" rm -rf /tmp/logs/ mkdir -p /tmp/logs + # A baseline from before TRACER_PART existed would run every part. + if [ -n "${TRACER_PART:-}" ] && ! grep -q TRACER_PART runall.sh; then + cp "$CI_PROJECT_DIR/benchmark/runall.sh" runall.sh + fi taskset -c 34-47 ./runall.sh if [ "$SCENARIO" = "profiler" ]; then mv "$ARTIFACTS_DIR/sirun_timeline.ndjson" "$ARTIFACTS_DIR/$BASELINE_OR_CANDIDATE-sirun_timeline.ndjson" mv "$ARTIFACTS_DIR/sirun_exceptions.ndjson" "$ARTIFACTS_DIR/$BASELINE_OR_CANDIDATE-sirun_exceptions.ndjson" elif [ "$SCENARIO" = "tracer" ]; then - # Give the OPCache subjects an "-opcache" suffix so they don't - # collide with the non-OPCache subjects (third column is the subject). - awk -F ',' -v OFS=',' 'NR == 1 { print } NR > 1 { $3 = $3 "-opcache"; print }' \ - "$ARTIFACTS_DIR/tracer-bench-results-opcache.csv" > "$ARTIFACTS_DIR/tracer-bench-results-opcache.tmp" && \ + if [ -z "${TRACER_PART:-}" ] || [ "$TRACER_PART" = phpbench-opcache ]; then + # Give the OPCache subjects an "-opcache" suffix so they don't + # collide with the non-OPCache subjects (third column is the subject). + awk -F ',' -v OFS=',' 'NR == 1 { print } NR > 1 { $3 = $3 "-opcache"; print }' \ + "$ARTIFACTS_DIR/tracer-bench-results-opcache.csv" > "$ARTIFACTS_DIR/tracer-bench-results-opcache.tmp" mv "$ARTIFACTS_DIR/tracer-bench-results-opcache.tmp" "$ARTIFACTS_DIR/$BASELINE_OR_CANDIDATE-tracer-bench-results-opcache.csv" - mv "$ARTIFACTS_DIR/tracer-bench-results.csv" "$ARTIFACTS_DIR/$BASELINE_OR_CANDIDATE-tracer-bench-results.csv" - mv "$ARTIFACTS_DIR/tracer-tea-bench-results.json" "$ARTIFACTS_DIR/$BASELINE_OR_CANDIDATE-tracer-tea-bench-results.json" + rm "$ARTIFACTS_DIR/tracer-bench-results-opcache.csv" + fi + if [ -z "${TRACER_PART:-}" ] || [ "$TRACER_PART" = phpbench ]; then + mv "$ARTIFACTS_DIR/tracer-bench-results.csv" "$ARTIFACTS_DIR/$BASELINE_OR_CANDIDATE-tracer-bench-results.csv" + fi + if [ -z "${TRACER_PART:-}" ] || [ "$TRACER_PART" = tea ]; then + mv "$ARTIFACTS_DIR/tracer-tea-bench-results.json" "$ARTIFACTS_DIR/$BASELINE_OR_CANDIDATE-tracer-tea-bench-results.json" + fi elif [ "$SCENARIO" = "appsec" ]; then # Give the AppSec subjects an "-appsec" suffix so they don't collide # with the tracer subjects (third column is the subject). From 019178e319856d4831991efd86a40ddc529e1010 Mon Sep 17 00:00:00 2001 From: Brian Marks Date: Tue, 24 Nov 2026 19:11:59 -0500 Subject: [PATCH 17/18] ci: address automated review findings - Pass LIBDATADOG_OVERRIDE_SHA to the PHP 7.0 SSI jobs. They build with make build-ssi-ddtrace, which the override matcher didn't list, so scheduled compatibility runs built SSI against the pinned libdatadog while the sidecar used the override. - check-big-regressions only skips when no benchmarks-tracer shard produced results. One shard that failed to fetch master could write skip-reason.txt and silence the regression check for the others. - Fail the system-tests weblog build when resolving base images fails, instead of letting build.sh fall back to Docker Hub. - Fall back to apk add when the Alpine image lacks mimalloc. Runners pull with if-not-present, so nodes keep stale cached images after a rebuild, and the hard failure blocked those jobs. --- .claude/ci/compile-artifacts.md | 7 ++++--- .gitlab/benchmarks.yml | 2 +- .gitlab/generate-common.php | 1 + .gitlab/generate-package.php | 7 ++++--- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.claude/ci/compile-artifacts.md b/.claude/ci/compile-artifacts.md index 7e6c346b1e..0d3c526213 100644 --- a/.claude/ci/compile-artifacts.md +++ b/.claude/ci/compile-artifacts.md @@ -184,9 +184,10 @@ See `.gitlab/generate-package.php` for the exact per-platform `needs:` lists. LTO and SSI jobs have no explicit `cache:` block, but they do build Rust. - The musl compile jobs (combined, SSI combined, sidecar and the PHP 7.0 jobs) - `LD_PRELOAD` the `mimalloc2-insecure` the Alpine image installs and fail if it - is missing: Alpine's rustc links scudo and clang/lld use musl's malloc, which - spend much of a parallel build in the kernel. + `LD_PRELOAD` the `mimalloc2-insecure` the Alpine image installs: Alpine's + rustc links scudo and clang/lld use musl's malloc, which spend much of a + parallel build in the kernel. Runners pull with `if-not-present`, so a node + can keep an older cached image after a rebuild; the jobs then `apk add` it. - PR branch pipelines set `CARGO_PROFILE_TRACER_RELEASE_CODEGEN_UNITS=16`, which roughly halves the Rust build. Master, `ddtrace-*`, `release-*` branches and diff --git a/.gitlab/benchmarks.yml b/.gitlab/benchmarks.yml index 79bacd1fb6..c31423f512 100644 --- a/.gitlab/benchmarks.yml +++ b/.gitlab/benchmarks.yml @@ -411,7 +411,7 @@ check-big-regressions: tags: [ "arch:amd64" ] image: registry.ddbuild.io/images/benchmarking-platform-tools-ubuntu@sha256:b682acae509fa391ac559705b66df07cac876e4c46641d2457077972a1c0bbb8 script: | - if [ -f "reports/skip-reason.txt" ]; then + 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" exit 0 elif [ -z "$(ls -A reports/ 2>/dev/null)" ]; then diff --git a/.gitlab/generate-common.php b/.gitlab/generate-common.php index bd3d8bc912..66c5e40266 100644 --- a/.gitlab/generate-common.php +++ b/.gitlab/generate-common.php @@ -140,6 +140,7 @@ function windows_git_setup_with_packages() { 'build-profiler.sh', 'xlang-lto', // `make -s xlang-lto` and tooling/bin/build-xlang-lto (ThinLTO and SSI combined builds) 'build-ssi-combined-alpine.sh', + 'build-ssi-ddtrace', ]; // Split into top-level YAML blocks (each starts at column 0). diff --git a/.gitlab/generate-package.php b/.gitlab/generate-package.php index f9eac1ce1f..87eadf052b 100644 --- a/.gitlab/generate-package.php +++ b/.gitlab/generate-package.php @@ -167,8 +167,8 @@ function alpine_mimalloc(array $platform): void return; } ?> - # Installed by dockerfiles/ci/alpine_compile_extension/base.Dockerfile. - - test -f /usr/lib/libmimalloc-insecure.so.2 || { echo "mimalloc is missing from $CI_JOB_IMAGE, rebuild the Alpine CI images" >&2; exit 1; } + # Installed by dockerfiles/ci/alpine_compile_extension/base.Dockerfile; nodes with a stale cached image fall back to apk. + - test -f /usr/lib/libmimalloc-insecure.so.2 || apk add -q --no-cache mimalloc2-insecure || exit 75 - export LD_PRELOAD=/usr/lib/libmimalloc-insecure.so.2 Date: Tue, 24 Nov 2026 19:15:02 -0500 Subject: [PATCH 18/18] ci: run tracer benchmarks when the diff against master fails The file-change check treated a failed fetch or diff as an empty change list, so a shard that couldn't reach master skipped its benchmarks. If every shard hit that, check-big-regressions saw only skip markers and passed without a regression check. --- .gitlab/benchmarks.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitlab/benchmarks.yml b/.gitlab/benchmarks.yml index c31423f512..bf8a07ab35 100644 --- a/.gitlab/benchmarks.yml +++ b/.gitlab/benchmarks.yml @@ -226,7 +226,10 @@ workflow: if [ "${CHECK_TRACER_FILE_CHANGES:-false}" = "true" ] && [ "${CI_PARENT_PIPELINE_SOURCE}" != "pipeline" ]; then echo "Checking if tracer-related files changed..." git fetch origin master:master 2>/dev/null || true - CHANGED_FILES=$(git diff --name-only HEAD master 2>/dev/null || echo "") + if ! CHANGED_FILES=$(git diff --name-only HEAD master); then + echo "Could not diff against master - running benchmarks" + CHANGED_FILES=benchmark/ + fi if ! echo "$CHANGED_FILES" | grep -q -E "^(ext/|src/|components/|components-rs/|zend_abstract_interface/|tests/Benchmarks/|benchmark/|tea/|\.gitlab/benchmarks\.yml|\.gitlab/benchmarks/)"; then echo "No tracer-related file changes detected - skipping benchmark execution" echo "Reports directory created but empty (no benchmarks needed)" > "${ARTIFACTS_DIR}/skip-reason.txt"