diff --git a/.claude/ci/benchmarks.md b/.claude/ci/benchmarks.md index 97248ca0f1..24d3b74abc 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, one `TRACER_PART` (phpbench, phpbench-opcache, tea) per matrix job; 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) and, for the phpbench parts, one `PHPBENCH_SHARD` (1, 2) per matrix job; skips automatically if no tracer-relevant files changed | | `benchmarks-appsec` | same | Runs appsec microbenchmarks; produces `candidate.tar.gz` and `baseline.tar.gz` artifacts | | `benchmarks-profiler` | same | Runs profiler microbenchmarks | | `benchmarks-pr-comment` | `$MICROBENCHMARKS_CI_IMAGE` (see `.gitlab/benchmarks.yml`; built in-repo from `.gitlab/benchmarks/container/`) | Runs `.gitlab/benchmarks/bp-runner.pr-comment.yml`: posts the tracer comparison as a PR comment and uploads the results to the Benchmarking Platform API; needs `benchmarks-tracer`; allow_failure | diff --git a/.gitlab/benchmarks.yml b/.gitlab/benchmarks.yml index 39617fcb70..d717a1bf7d 100644 --- a/.gitlab/benchmarks.yml +++ b/.gitlab/benchmarks.yml @@ -291,7 +291,9 @@ benchmarks-tracer: rules: *benchmarks-tracer-rules parallel: matrix: - - TRACER_PART: [ phpbench, phpbench-opcache, tea ] + - TRACER_PART: [ phpbench, phpbench-opcache ] + PHPBENCH_SHARD: [ "1", "2" ] + - TRACER_PART: tea artifacts: name: "reports" when: always @@ -442,7 +444,8 @@ check-big-regressions: sides=candidate # bp-runner writes a bare newline here when the branch has no PR. if grep -q '[^[:space:]]' reports/baseline_branch.txt 2>/dev/null; then sides="baseline candidate"; fi - for result in tracer-bench-results tracer-bench-results-opcache tracer-tea-bench-results; do + for result in tracer-bench-results-1 tracer-bench-results-2 \ + tracer-bench-results-opcache-1 tracer-bench-results-opcache-2 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" diff --git a/.gitlab/benchmarks/README.md b/.gitlab/benchmarks/README.md index 8064ec454d..a756185006 100644 --- a/.gitlab/benchmarks/README.md +++ b/.gitlab/benchmarks/README.md @@ -50,10 +50,12 @@ Execution flow on each PR: takes its merge base with the exact candidate commit. Unless `BOLT_MODE=off`, both revisions are compiled and BOLT-processed (aligned as a pair by default) before either is measured. - `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. + `benchmarks-tracer` is a matrix of five jobs: `TRACER_PART` `phpbench` and + `phpbench-opcache`, each split into `PHPBENCH_SHARD` `1` (WordPress and + Laravel) and `2` (every other subject), and `tea`. `runall.sh` runs only + that part and shard, and suffixes the shard's result files with `-1` or + `-2`. A baseline whose `runall.sh` predates `TRACER_PART` or + `PHPBENCH_SHARD` 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`. @@ -62,7 +64,7 @@ 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` and `benchmarks-pr-comment` merge the three +4. `check-big-regressions` and `benchmarks-pr-comment` merge the five tracer jobs' `reports/`. The gate fails if any part's candidate (or, when there is a baseline branch, baseline) `.converted.json` is missing, or on regressions above the threshold of 10% in diff --git a/.gitlab/benchmarks/steps/run-revision.sh b/.gitlab/benchmarks/steps/run-revision.sh index 4e43c2d902..e9b1637e80 100755 --- a/.gitlab/benchmarks/steps/run-revision.sh +++ b/.gitlab/benchmarks/steps/run-revision.sh @@ -18,8 +18,9 @@ fi 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 +# A baseline predating TRACER_PART or PHPBENCH_SHARD runs the candidate's copy. +if { [ -n "${TRACER_PART:-}" ] && ! grep -q TRACER_PART runall.sh; } || + { [ -n "${PHPBENCH_SHARD:-}" ] && ! grep -q PHPBENCH_SHARD runall.sh; }; then cp "$CI_PROJECT_DIR/benchmark/runall.sh" runall.sh fi taskset -c 34-47 ./runall.sh @@ -34,15 +35,17 @@ 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 + suffix="${PHPBENCH_SHARD:+-$PHPBENCH_SHARD}" if [ -z "${TRACER_PART:-}" ] || [ "$TRACER_PART" = phpbench-opcache ]; then # The third CSV column is the subject; distinguish OPcache subjects. + name="tracer-bench-results-opcache$suffix" 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" - rm "$ARTIFACTS_DIR/tracer-bench-results-opcache.csv" + "$ARTIFACTS_DIR/$name.csv" > "$ARTIFACTS_DIR/tracer-bench-results-opcache.tmp" + mv "$ARTIFACTS_DIR/tracer-bench-results-opcache.tmp" "$ARTIFACTS_DIR/$BASELINE_OR_CANDIDATE-$name.csv" + rm "$ARTIFACTS_DIR/$name.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" + mv "$ARTIFACTS_DIR/tracer-bench-results$suffix.csv" "$ARTIFACTS_DIR/$BASELINE_OR_CANDIDATE-tracer-bench-results$suffix.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" diff --git a/benchmark/runall.sh b/benchmark/runall.sh index 35de5213ff..0d23fa484c 100755 --- a/benchmark/runall.sh +++ b/benchmark/runall.sh @@ -17,6 +17,16 @@ 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 +# The phpbench parts run as two shards; unset runs every subject. +shard="${PHPBENCH_SHARD:-}" +filter=() +case "$shard" in + '') ;; + 1) filter=(FILTER='(WordPress|Laravel)Bench::') ;; + 2) filter=(FILTER='^(?!.*(WordPress|Laravel)Bench::)') ;; + *) echo "unknown PHPBENCH_SHARD=$shard" >&2; exit 1 ;; +esac +suffix="${shard:+-$shard}" cd .. COMBINED_SO=tmp/build_combined/modules/ddtrace.so if [ -z "${DD_TRACE_ASSUME_COMPILED:-}" ]; then @@ -49,16 +59,16 @@ elif [ "$SCENARIO" = "tracer" ]; then ## Non-OPCache Benchmarks if [ -z "$part" ] || [ "$part" = phpbench ]; then - make_combined call_benchmarks - cp tests/Benchmarks/reports/tracer-bench-results.csv "$ARTIFACTS_DIR/tracer-bench-results.csv" + make_combined call_benchmarks ${filter[@]+"${filter[@]}"} + cp tests/Benchmarks/reports/tracer-bench-results.csv "$ARTIFACTS_DIR/tracer-bench-results$suffix.csv" fi ## OPCache Benchmarks 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" + make_combined call_benchmarks_opcache ${filter[@]+"${filter[@]}"} + cp tests/Benchmarks/reports/tracer-bench-results-opcache.csv "$ARTIFACTS_DIR/tracer-bench-results-opcache$suffix.csv" fi ## Request Startup/Shutdown Benchmarks