Repository navigation
ci(benchmarks): align combined modules in the in-repo runner - #4537
cataphract wants to merge 7 commits into
Conversation
❌ ErrorsYour PR has failed checks. Please review the issues below and take necessary action before merging. 🚦 26 Pipeline jobs failed
ℹ️ InfoNo other issues found (see more)❄️ No new flaky tests detected 🎯 Code Coverage (details) Useful? React with 👍 / 👎 This comment will be updated automatically if new data arrives.🔗 Commit SHA: afe95cb | Docs | View more details | Give us feedback! |
472509a to
a8304c9
Compare
Incidental binary layout can obscure the performance effect of a source change. Build both combined extensions before measuring either one and align their common functions with the pinned static LLVM 23.1.6 tool. The shared runner handles analysis and per-scenario publication, while PHP scripts coordinate the paired builds its sequential template cannot. Keep source checkouts available for revision metadata, verify that the harness preserves rewritten modules, and retain diagnostic logs without extra binary artifacts. Comparisons align by default; plain BOLT and unprocessed runs provide controls, with plain BOLT for candidate-only runs. Retain the upstream reporting, CPU partition and retry settings.
a8304c9 to
4760098
Compare
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4760098c13
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Default benchmark comparisons require BOLT, but the pinned CI image predates its addition, so comparisons stop before producing results. The image rebuild and repin identified in the description remain prerequisites.
🤖 Bits Code Review · Commit 4760098
The comparison jobs now align the candidate and baseline extensions with llvm-bolt-align before timing them, but MICROBENCHMARKS_CI_IMAGE still pointed at dd-trace-php-152770667, which predates the Dockerfile change that copies the tool in. Every default comparison run would therefore have failed before producing results. Rebuild the image from the current container/Dockerfile with the manual build-benchmark-ci-images job and pin the resulting per-pipeline tag, as the README prescribes. The Dockerfile runs `llvm-bolt-align --version` while building, so a successful build confirms the tool is present. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
4760098 to
f501780
Compare
There was a problem hiding this comment.
More details
Available validation supports the scripted build, rewrite, and execution workflow. A full benchmark comparison in the pinned CI image remains unvalidated.
🤖 Bits Code Review · Commit f501780
Benchmarks [ tracer ]Benchmark execution time: 2026-11-25 03:37:32 Comparing candidate commit c205c6b in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 217 metrics, 1 unstable metrics.
|
llvm-bolt-align pairs functions by symbol name, but it only pinned 60% of them (17,600 of ~29,300) in the benchmark job even though the candidate and baseline sources are nearly identical. The unpinned 40% are exactly the Rust functions. The build runs Cargo in tmp/build_combined, whose Cargo.toml reaches libdatadog as ../../libdatadog/...; those crates lie outside the workspace root, so Cargo hashes their absolute path into -C metadata (47 crates differ between /app/candidate and /app/baseline), and rustc derives the Rust symbol hashes from it. Every Rust function therefore has a different name in each binary. --remap-path-prefix and -C symbol-mangling-version=v0 do not change that metadata, so they cannot fix it. Instead, build each revision in the same scratch directory, keep the natural module, align the pair, and install the aligned modules into the checkouts that the analyzer and the run steps still use. Aligning two builds of the same source in different directories pinned 60%; the same source at one path pinned 100%, and the full job now pins 29,316 of 29,316 functions. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The test drove run-benchmarks.sh against mocked git, make and llvm-bolt commands. It only checked the ordering of the steps, never a real build or alignment, so it could not catch what mattered here: the real job is the authority on whether both revisions align. Drop it and the README paragraph that told readers to run it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
igoragoli
left a comment
There was a problem hiding this comment.
Thank you for working on this! I commented on the biggest point that caught my eye.
A question: on PRs, the BOLT mode will be align. I assume the per team should evaluate the PHP's benchmark flakiness with align, right?
Pros:
- The flakiness metrics would measure the benchmark design itself, not layout noise, which is what we intend to evaluate and optimize.
- The consequence of flakiness we most want to cut on dd-trace-php is flaky PR comments, and these metrics would reflect exactly that.
Cons:
- Master runs use
plain, so benchmarks on master might be flakier than on PRs.
Here is an AI-generated review. Feel free to ignore, as they are rather minor issues:
AI-generated reviews
Medium
- README omits the fidelity consequence: the measured module is BOLT-rewritten with
-fno-reorder-blocks-and-partitionand--emit-relocs, so absolute numbers and the trend series do not reflect the production build; only in-job candidate-vs-baseline comparisons are meaningful.- Add a caveat to the BOLT section. prepare-bolt.sh#L33-L34, README.md#L61-L107
- Documented local-reproduction command cannot run: the scripts dereference
CI_PROJECT_DIR,CI_COMMIT_REF_NAME,CI_COMMIT_SHA,CI_PROJECT_NAMEunderset -u, but the reproduce block exports none of them and bp-runner injects none outside--local.- Extend the export line; note
BOLT_MODE=plainskips the GitHub lookup. README.md#L223-L234
- Extend the export line; note
- Zero tests ship while the body advertises eleven:
c205c6b5cdeleted the only test (test_bolt_workflow.py, 249 lines) with a fair rationale, but the Validation section still claims those tests passed; mode selection, the log gate, and the module check are now unpinned.- Rewrite the Validation bullet; consider a fixture test for the gate. prepare-bolt.sh#L61-L70
Minor
- Latent footgun: setting
BENCHMARK_SOURCE_ROOTto anything but/appmakes the bp-runner analyzer (hardcoded/apppaths,[ -d ]guard) silently skip all analysis while printing success. Nothing sets it today.- Delete the override. run-benchmarks.sh#L34
- Trap not failure-resilient: a failing
mkdir/cpin the EXIT trap (ENOSPC) aborts it beforerm -rf "$WORK_DIR", leaking the multi-GB scratch tree.- Make the diagnostics lines best-effort with
|| :. run-benchmarks.sh#L14-L22
- Make the diagnostics lines best-effort with
- Merge-base failure leaves no step context: exit 1 prints nothing, exit 128 prints only git's
fatal:line.- Wrap the call and echo a message naming the script. run-benchmarks.sh#L46-L47
- Script-name collision: same name as the macrobenchmarks'
steps/run-benchmarks.shfrom the cloned benchmarking-platform repo; a grep for a macro job log line lands on the wrong script.- Rename the new script or comment the macro job. benchmarks.yml#L445
- Stale
tmp/carryover: a checkout carrying a fulltmp/build_combinedtree plus a BOLT-installed module makes the scratch build a no-op and feeds BOLT output back into BOLT (manual runs only).rm -rf "$BUILD_ROOT/tmp"after the copy. prepare-bolt.sh#L47
- Wasted copy:
cp -aduplicates.gitof 5 repos twice per job; nothing in the build reads it.- Copy with
--exclude=.git. prepare-bolt.sh#L47
- Copy with
- Undocumented log-gate invariants: the gate hardcodes
missed offsetandcount != 2with no comment and no test; it fails closed, so worst case is a blocked job.- Add a 3-line invariant comment. prepare-bolt.sh#L61-L70
- Undocumented knobs:
BOLT_BIN/BOLT_ALIGN_BINhave no other references andBOLT_BINapplies only inplainmode.- Document or drop them. prepare-bolt.sh#L22-L23
- Standalone leak: no trap, so a failed direct run leaves a multi-GB
BUILD_ROOT.trap 'rm -rf "$BUILD_ROOT"' EXIT. prepare-bolt.sh#L43
- Divergent
extension_dirresolution:php -nvs the Makefile's ini-loadedphp; anextension_dir=ini setting would make the pre-install and firstcmpguard a directory nothing loads.- Resolve it the Makefile's way (
php -d ddtrace.disable=1). run-revision.sh#L9
- Resolve it the Makefile's way (
- Stale CI doc: the PR adds
tracer/to the early-exit regex; the pre-PR regex matched the doc exactly, so the drift is new.- Add
tracer/to the list. .claude/ci/benchmarks.md#L30-L31
- Add
- Unqualified README claim: "Both revisions are compiled and aligned before either is measured" is false under
BOLT_MODE=off.- Scope the sentence to non-off modes. README.md#L48
- Stale PR body: says stacked on #4506 targeting
augusto/php-microbenchmarks-bp-runner(base ismaster, #4506 merged), says "a single commit" (4 commits), and never mentions thetracer/regex orartifacts: when: always.- Body edits only. PR #4537
| # The shared analyzer reads Git metadata from these fixed checkout locations. | ||
| # Keep the checkouts until analysis finishes; only BOLT's scratch files are | ||
| # removed by this script's exit trap. | ||
| SOURCE_ROOT=${BENCHMARK_SOURCE_ROOT:-/app} |
There was a problem hiding this comment.
The default is fine, but if BENCHMARK_SOURCE_ROOT is set, results will be saved outside the "fixed checkout locations" (/app/candidate/ and /app/baseline/, by default).
There was a problem hiding this comment.
Removed in afe95cb. The override only existed for the unit test, which is gone, and the checkouts are now fixed at /app/candidate and /app/baseline.
|
@igoragoli Yes, flakiness should be evaluated with |
The CI image copies llvm-bolt and llvm-bolt-align from a tool image whose Dockerfile, patch and build job lived on a branch of another repository, outside the review of this PR, even though the tool is only used here. Move the image's sources (Dockerfile, bolt-align.patch, smoke test and README) under .gitlab/benchmarks/container/llvm-bolt-align/ and add a manual build-llvm-bolt-align-image job next to build-benchmark-ci-images, built by the same template. Like the main image it is published under the benchmark registry name, with a tag of its own (llvm-bolt-align-<pipeline id>) that is unique per pipeline, so a rebuild cannot shift what older pipelines pulled. Repin the FROM in container/Dockerfile to the image this job built, so the tool the benchmarks use is the one defined and reviewed here. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…tool The CI image now builds from the llvm-bolt-align image defined in this repository, not from the one built on a branch of another repository. Rebuild it with build-benchmark-ci-images and pin the resulting tag, as the README prescribes. The build log shows the new tool image in use (`llvm-bolt-align --version`: LLVM 23.1.6). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- Fix the BOLT section of the README: scope the "compiled and aligned" sentence to the modes that do it, say that master runs use plain processing and are not comparable to the aligned PR comparisons, and complete the local-reproduction environment (CI_PROJECT_DIR, CI_PROJECT_NAME, CI_COMMIT_REF_NAME, CI_COMMIT_SHA). - Drop the BENCHMARK_SOURCE_ROOT override. Only the removed unit test used it, and the shared analyzer reads /app/candidate and /app/baseline, so any other location silently skips the analysis. - Never build from a leftover tmp/ in the scratch copy, document what the alignment log gate checks, and drop the unused BOLT_BIN/BOLT_ALIGN_BIN overrides. - Bring .claude/ci/benchmarks.md up to date: the trigger paths, the new image job, the description of the local flow and its Approach 1 (default tracer-only extension, not the combined one CI measures), and the services section (the dd-trace-ci images have no MySQL/Redis, which composer_tests_update also needs). Document how to run the full CI flow with BOLT alignment locally. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
@igoragoli Addressed in afe95cb: the master caveat in the README (M1, shortened), the local-reproduction environment (M2), the Not changed: the exit trap (m2) and standalone-run trap (m9) only affect a throwaway container or a manual run; the merge-base message (m3) can't realistically fail, since the candidate is a full clone and the base always exists on origin; the |
Binary layout changes can obscure the performance effect of a source change. Build both combined PHP extensions before timing either one, then align their common functions with llvm-bolt-align. The shared bp-runner continues to handle result conversion, comparison and publication.
This is stacked on #4506 and targets
augusto/php-microbenchmarks-bp-runner. A single commit adds alignment to the migrated benchmark setup.The PHP image copies the static LLVM 23.1.6 BOLT executable from the published, digest-pinned tool image. Comparisons default to pairwise alignment, with
plainandoffmodes available as controls. Candidate-only runs currently default to plain BOLT; selecting a historical reference for those runs is deferred.The runner rejects incomplete alignment and checks that benchmark setup has not replaced the rewritten module. Checkouts remain available for the shared analyzer to read revision metadata. Artifacts retain diagnostic logs without extra copies of the extension binaries.
Validation:
Related: APMSP-4182.