Skip to content

fix(profiling): use exponential allocation sampling - #4160

Closed
realFlowControl wants to merge 2 commits into
masterfrom
florian/fix-allocation-sampling
Closed

fix(profiling): use exponential allocation sampling#4160
realFlowControl wants to merge 2 commits into
masterfrom
florian/fix-allocation-sampling

Conversation

@realFlowControl

@realFlowControl realFlowControl commented Sep 4, 2026

Copy link
Copy Markdown
Member

Description

Apply the sampling fix from #4159 to allocation profiling. The sampler used Poisson-distributed distances, but upscaling assumes exponential distances with inclusion probability p = 1 - exp(-size / interval). Allocations near the 4 MiB interval can be overestimated by about 50%. Both PHP allocator implementations share this sampler.

Use exponential distances, retain the existing NTS/ZTS RNGs, and add a seeded regression test. Change the allocation correctness workload to 512 fixed iterations and check its actual totals: 18,874,368,000 payload bytes and 2,048 allocations. Use 6% total margins and 3-percentage-point share margins. The combined allocation/time test runs at least 128 iterations with 6-point allocation-share margins. Test notes document the binomial sampling-noise estimates and integer percentage truncation.

The old percentage-only tests passed on master despite inflated totals. With the strengthened allocation test, master reports about 13.78% excess bytes and 17.62% excess allocations and fails 100/100 runs.

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

Match allocation sampling to the upscaler's inclusion probability. Add a seeded regression test and workload-derived correctness totals and margins.
@realFlowControl realFlowControl added 🐛 bug Something isn't working profiling Relates to the Continuous Profiler labels Sep 4, 2026
@datadog-prod-us1-3

datadog-prod-us1-3 Bot commented Sep 4, 2026

Copy link
Copy Markdown

Pipelines  Tests

Unblock PR with BitsAI

⚠️ Warnings

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 10 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-php | test_extension_ci: [7.3, valgrind] — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

DataDog/apm-reliability/dd-trace-php | test_extension_ci: [8.3] — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

DataDog/apm-reliability/dd-trace-php | test_extension_ci: [7.1, valgrind] — 🔄 Retry may pass, looks flaky

View more details · View in GitLab

View all 10 failed jobs.

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 54.99% (+0.00%)

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 38359f8 | Docs | View more details | Give us feedback!

@pr-commenter

pr-commenter Bot commented Sep 4, 2026

Copy link
Copy Markdown

Benchmarks [ profiler ]

Benchmark execution time: 2026-09-04 14:34:31

Comparing candidate commit 38359f8 in PR branch florian/fix-allocation-sampling with baseline commit 3b1267d in branch master.

Found 0 performance improvements and 2 performance regressions! Performance is the same for 26 metrics, 8 unstable metrics.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

scenario:php-profiler-timeline-memory-control

  • 🟥 cpu_user_time [+36.144ms; +43.917ms] or [+5.573%; +6.772%]
  • 🟥 execution_time [+33.571ms; +39.674ms] or [+4.897%; +5.788%]

@realFlowControl

Copy link
Copy Markdown
Member Author

Merged into #4159.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working profiling Relates to the Continuous Profiler tracing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant