fix(profiling): correct mixed-size allocation upscaling - #4210
realFlowControl wants to merge 3 commits into
Conversation
❌ ErrorsYour PR has failed checks. Please review the issues below and take necessary action before merging. 🚦 249 Pipeline jobs failed
ℹ️ InfoNo other issues found (see more)🧪 All tests passed 🎯 Code Coverage (details) Useful? React with 👍 / 👎 This comment will be updated automatically if new data arrives.🔗 Commit SHA: d0350a1 | Docs | View more details | Give us feedback! |
Benchmarks [ profiler ]Benchmark execution time: 2026-09-21 15:55:34 Comparing candidate commit d0350a1 in PR branch Found 0 performance improvements and 3 performance regressions! Performance is the same for 26 metrics, 7 unstable metrics.
|
Add a correctness workload using the default 4 MiB sampling distance and run it in GitHub CI. It exposes merge-before-upscale errors in allocation count and bytes; the new check intentionally fails until upscaling is fixed.
Use the GitHub libdatadog branch and commit from DataDog/libdatadog#2543. Keep this pin temporary until the upstream fix is merged and released.
e7f6c13 to
dab33b4
Compare
Use the updated libdatadog upscaling fix without changing sampling intervals or correctness tolerances.
Description
Warning
Do not merge until DataDog/libdatadog#2543 is merged and libdatadog has tagged a new release containing the fix. Before merging, update the submodule pin to that release and restore the tracking branch to
main.Add a mixed-size allocation regression to the existing profiler correctness CI. One call site makes 523264 allocations of 64 KiB and 1024 allocations of 32 MiB, with expected totals of 524288 allocations and 68652367872 payload bytes. The JSON documents the weighting math and uses 6% tolerances.
Temporarily pin libdatadog to GitHub branch
florian/fix-poisson-upscaling, commit0b40b2f46e779bdf5284ba52b2957533308b478d, from DataDog/libdatadog#2543. The lockfile remains compatible with the updated pin. There are no local-path overrides or PHP profiler implementation changes.The upstream fix now accumulates weighted
f64totals directly in the existing eight-byte slots for global and matching ordinary-label Poisson rules, rather than retaining separate correction maps. Other values remain integers; stack and label aggregation is preserved. Endpoint-dependent and overlapping rules retain a deferred path. PHP already registers its rules before samples, as required by the updated API.Before the fix, this workload reports about 97.1% too few allocations and 15% too few bytes. The rebuilt PHP 8.5 NTS profiler passes the unchanged mixed-size regression 5/5 times at the 4 MiB interval: count errors are 0.1–2.3% and byte errors are 0.0–1.2%, using rounded analyzer percentages. The existing allocation correctness test also passes, including the one-byte interval with and without ZendMM.
Memory validation upstream: 32 ordinary-label rules and 3,300 aggregate keys previously retained 105,600 separate correction entries; the compact implementation retains zero. This is a storage regression check, not an RSS or CPU benchmark. The earlier performance numbers measured the superseded implementation; CPU/RSS measurements for the compact implementation are still pending.
Local validation on macOS arm64 with PHP 8.5 NTS: libdatadog tests, doctests, profiling FFI examples, Clippy, and formatting passed. The final pin was checked with locked Cargo dependency resolution and the profiler was rebuilt: PHP Rust tests passed 35/35; PHPT had 36 passes, 11 platform/version/environment skips, and no failures; all 13 correctness cases and all 11 profiler-disabled scenarios passed.
An initial timeline failure also reproduced on the unchanged branch point
05e721689: the recorded[eval]event was below the test's 1% minimum share. Both versions then passed four consecutive reruns. No test tolerances were changed. Linux, ZTS, and the full PHP-version matrix were not run locally; full GitHub CI is pending.Reviewer checklist