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

perf: reduce memory usage in profiling

Open morrisonlevi opened this issue 11 months ago • 2 comments

Description

Utilizes ThinString in the ZendFrame to shrink memory. This shrinks each frame from 7 words to 3 words.

It also moves some label values from Owned to Borrowed, which will save on allocations in the runtime. I played with moving these to ThinString but it doesn't shrink the size of LabelValue (it's so close, I think 1 unused bit away from shrinking down...)

Reviewer checklist

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

morrisonlevi avatar Dec 15 '24 22:12 morrisonlevi

Benchmarks [ profiler ]

Benchmark execution time: 2025-01-13 20:26:25

Comparing candidate commit e49f49a7eb1ad5299a77a52729e06949eea89048 in PR branch levi/thin-zend-frame with baseline commit b0171fa4728307f0949e9d8f4df2840133086d7f in branch levi/thin-str.

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

scenario:walk_stack/1

  • 🟥 wall_time [+4.009µs; +4.015µs] or [+32.911%; +32.960%]

scenario:walk_stack/50

  • 🟥 wall_time [+3.709µs; +3.720µs] or [+24.354%; +24.431%]

scenario:walk_stack/99

  • 🟥 wall_time [+3.866µs; +3.872µs] or [+25.462%; +25.502%]

scenario:walk_stack_instructions/1

  • 🟥 instructions [+33.8K instructions; +33.8K instructions] or [+33.379%; +33.382%]

scenario:walk_stack_instructions/50

  • 🟥 instructions [+36.8K instructions; +36.8K instructions] or [+35.896%; +35.902%]

scenario:walk_stack_instructions/99

  • 🟥 instructions [+37.0K instructions; +37.0K instructions] or [+36.046%; +36.049%]

pr-commenter[bot] avatar Dec 15 '24 23:12 pr-commenter[bot]

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 74.80%. Comparing base (b0171fa) to head (e49f49a).

Additional details and impacted files

Impacted file tree graph

@@                 Coverage Diff                 @@
##             levi/thin-str    #2995      +/-   ##
===================================================
+ Coverage            74.78%   74.80%   +0.01%     
  Complexity            2781     2781              
===================================================
  Files                  112      112              
  Lines                11017    11017              
===================================================
+ Hits                  8239     8241       +2     
+ Misses                2778     2776       -2     
Flag Coverage Δ
tracer-php 74.80% <ø> (+0.01%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

see 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update b0171fa...e49f49a. Read the comment docs.

codecov-commenter avatar Dec 15 '24 23:12 codecov-commenter