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

perf(profiling): use faster, persistent caching strategy

Open morrisonlevi opened this issue 2 years ago • 1 comments

Description

This adds DD_PROFILING_WALLTIME_ENABLED which doesn't currently disable wall-time profiles completely, it only cancels the timer. You can still trigger them manually, which is partly the purpose: we want to disable automatic collection so we can benchmark in a controlled way.

It then uses a new caching strategy which will speed up stack walking in two ways:

  1. The strings don't need to be copied during the stack walking. The reads from the string table can be done from the thread doing the aggregation.
  2. The run-time cache is reset every request, but for things in opcache we can do better as those live in immutable shared memory.

Readiness checklist

  • [x] Changelog has been added to the release document.
  • [x] Tests added for this feature/bug.

Reviewer checklist

  • [x] Appropriate labels assigned.
  • [x] Milestone is set.

morrisonlevi avatar Oct 16 '23 09:10 morrisonlevi

Benchmarks

Benchmark execution time: 2023-11-01 20:43:26

Comparing candidate commit 508fc7269cafde16619422f80d1dd32b8bb78f71 in PR branch levi/overhead-bench with baseline commit f99eb9c2e77d87d2977a53cb407171bb4613b7c3 in branch master.

Found 6 performance improvements and 0 performance regressions! Performance is the same for 12 metrics, 3 unstable metrics.

scenario:walk_stack/1

  • 🟩 wall_time [-4.416µs; -4.412µs] or [-36.308%; -36.279%]

scenario:walk_stack/50

  • 🟩 wall_time [-6.804µs; -6.801µs] or [-44.097%; -44.082%]

scenario:walk_stack/99

  • 🟩 wall_time [-6.799µs; -6.795µs] or [-44.097%; -44.070%]

scenario:walk_stack_instructions/1

  • 🟩 instructions [-61.2K instructions; -61.2K instructions] or [-60.922%; -60.907%]

scenario:walk_stack_instructions/50

  • 🟩 instructions [-62.2K instructions; -62.2K instructions] or [-60.842%; -60.833%]

scenario:walk_stack_instructions/99

  • 🟩 instructions [-62.4K instructions; -62.4K instructions] or [-60.904%; -60.903%]

pr-commenter[bot] avatar Oct 16 '23 09:10 pr-commenter[bot]