dd-trace-php icon indicating copy to clipboard operation
dd-trace-php copied to clipboard

feat(prof): move allocation profiler stack collection to safe point

Open realFlowControl opened this issue 7 months ago • 2 comments

[!CAUTION] This is a PoC to move allocation stack trace collection to a vm interrupt, DO NOT MERGE and do not judge me on the code 😜 If it breaks you keep all pieces!

Description

Reviewer checklist

  • [ ] Test coverage seems ok.
  • [ ] Appropriate labels assigned.

realFlowControl avatar Jun 23 '25 10:06 realFlowControl

Benchmarks [ profiler ]

Benchmark execution time: 2025-06-25 16:00:22

Comparing candidate commit 657058fe1a61842a3623be966ea3bfd62667b7e5 in PR branch florian/safe-point with baseline commit 0db0b0e4f98a5516db43d3f3888236a715d1077d in branch master.

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

pr-commenter[bot] avatar Jun 23 '25 10:06 pr-commenter[bot]

This is fine for a proof of concept; it let's us see how the accuracy of the allocation profiler is impacted.

That's the sole reason I opened a draft PR, that way I can see prof-correctness tests (as well as all other tests) and have a binary that I can ship.

However, it will walk the stacks twice, which is wasteful. If you are trying to compare overhead, you'll want to fix that first, or disable wall time sampling when testing.

Exactly, it is collecting two stack traces. This does not affect the outcome, but the overhead 😉

We should think carefully about this, but I think it may make sense to gather time any time we walk the stack.

I thought about that as well, as we have the stack trace already, we can easily add wall-/cpu-time to it. Let's measure once we are there.

realFlowControl avatar Jun 23 '25 16:06 realFlowControl

Although it is working, we decided to opt for the opline out-of-bounds check in #3319

realFlowControl avatar Jul 15 '25 10:07 realFlowControl