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/.claude/ci/compile-artifacts.md b/.claude/ci/compile-artifacts.md index 34fcf2b028..0d3c526213 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 (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. | | `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 @@ -172,14 +175,24 @@ 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 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. + +- The musl compile jobs (combined, SSI combined, sidecar and the PHP 7.0 jobs) + `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 + 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 diff --git a/.claude/ci/package-dind-verification.md b/.claude/ci/package-dind-verification.md index 82e38ccea5..98fcc6670a 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`. @@ -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/.claude/ci/system-tests.md b/.claude/ci/system-tests.md index c324393a41..49c78196d5 100644 --- a/.claude/ci/system-tests.md +++ b/.claude/ci/system-tests.md @@ -5,7 +5,11 @@ **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. 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/benchmarks.yml b/.gitlab/benchmarks.yml index 64ada4461e..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" @@ -269,6 +272,9 @@ benchmarks-profiler: benchmarks-tracer: extends: .microbenchmarks rules: *benchmarks-tracer-rules + parallel: + matrix: + - TRACER_PART: [ phpbench, phpbench-opcache, tea ] artifacts: name: "reports" when: always @@ -408,7 +414,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 @@ -416,6 +422,16 @@ check-big-regressions: exit 1 else echo "Reports directory found with content - running regression check" + 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 + done export ARTIFACTS_DIR="$(pwd)/reports/" bp-runner "${CI_PROJECT_DIR}/.gitlab/benchmarks/bp-runner.fail-on-regression.yml" --debug fi 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). 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 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 a9fc872ff0..e7d43b38ef 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"]; @@ -156,6 +160,19 @@ function manual_unless_changed(array $globs, array $never_if = []): string ?> + + # 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 + stages: - prepare - combined @@ -187,6 +204,9 @@ function manual_unless_changed(array $globs, array $never_if = []): string 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 @@ -312,6 +332,11 @@ function manual_unless_changed(array $globs, array $never_if = []): string 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 @@ -339,6 +364,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. @@ -425,6 +451,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 @@ -433,8 +460,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: "" @@ -446,38 +471,97 @@ 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 "" + artifacts: + paths: + - "extensions_*" + - "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" + - echo "" >> "$BASH_ENV" - ./.gitlab/build-sidecar.sh "" artifacts: @@ -577,6 +662,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" @@ -641,6 +727,10 @@ function manual_unless_changed(array $globs, array $never_if = []): string artifacts: true - job: "compile tracing extension: [7.0, , ]" artifacts: true + - job: "compile tracing extension LTO: [7.0, , , nts]" + artifacts: true + - job: "compile tracing extension LTO: [7.0, , , zts]" + artifacts: true @@ -945,7 +1035,7 @@ function manual_unless_changed(array $globs, array $never_if = []): string if ($platform["arch"] == $arch): ?> # PHP 7.0 still uses the split SSI extension (tracer and AppSec only). - - job: "compile tracing extension: [7.0, , ]" + - job: "compile tracing extension SSI: [7.0, , ]" artifacts: true - job: "compile tracing sidecar: [, ]" artifacts: true @@ -1297,9 +1387,11 @@ function manual_unless_changed(array $globs, array $never_if = []): string 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 + # 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 RUST_BACKTRACE: 1 before_script: @@ -1347,7 +1439,7 @@ function manual_unless_changed(array $globs, array $never_if = []): string 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 @@ -1781,6 +1873,7 @@ function manual_unless_changed(array $globs, array $never_if = []): string 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 @@ -1821,11 +1914,19 @@ function manual_unless_changed(array $globs, array $never_if = []): string - 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') + contexts=$(python3 utils/scripts/resolve-base-images-contexts.py --build-contexts "utils/build/docker/php/${weblog:-apache-mod-8.0}.Dockerfile") || exit 1 + for image in $(printf '%s\n' "$contexts" | 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 @@ -1907,7 +2008,7 @@ function manual_unless_changed(array $globs, array $never_if = []): string // 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, []); @@ -1929,8 +2030,8 @@ function manual_unless_changed(array $globs, array $never_if = []): string "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. diff --git a/benchmark/runall.sh b/benchmark/runall.sh index 4b6f1a37e1..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 @@ -45,18 +48,24 @@ elif [ "$SCENARIO" = "tracer" ]; then make_combined benchmarks_run_dependencies ## 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 diff --git a/dockerfiles/ci/alpine_compile_extension/base.Dockerfile b/dockerfiles/ci/alpine_compile_extension/base.Dockerfile index 7c4e062ed1..8c5b0d49f6 100644 --- a/dockerfiles/ci/alpine_compile_extension/base.Dockerfile +++ b/dockerfiles/ci/alpine_compile_extension/base.Dockerfile @@ -45,6 +45,10 @@ RUN apk add --no-cache llvm21-libs clang21-dev lld llvm21 rust-stdlib rust-src c RUN cargo install --force --locked bindgen-cli && mv /root/.cargo/bin/bindgen /usr/local/bin/ && rm -rf /root/.cargo +# The musl compile jobs LD_PRELOAD mimalloc: Alpine's rustc links scudo and +# clang/lld use musl's malloc, which spend much of a parallel build in the kernel. +RUN apk add --no-cache mimalloc2-insecure + RUN set -eux; \ mkdir -p /var/crash && chmod 1777 /var/crash; \ GDB_VERSION="17.2"; \