feat(prof): optimise allocation profiling for PHP >= 8.4#3550
feat(prof): optimise allocation profiling for PHP >= 8.4#3550morrisonlevi merged 15 commits intomasterfrom
Conversation
86c67e3 to
2c2f87d
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3550 +/- ##
==========================================
- Coverage 62.01% 61.92% -0.10%
==========================================
Files 140 140
Lines 13309 13309
Branches 1762 1762
==========================================
- Hits 8253 8241 -12
- Misses 4268 4278 +10
- Partials 788 790 +2 see 2 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Benchmarks [ profiler ]Benchmark execution time: 2026-01-16 23:23:05 Comparing candidate commit 3ca8f0e in PR branch Found 0 performance improvements and 1 performance regressions! Performance is the same for 29 metrics, 6 unstable metrics. scenario:php-profiler-timeline-memory-with-profiler-and-timeline
|
4e8b1eb to
b061348
Compare
|
c24208c to
1653fa2
Compare
1653fa2 to
4cee785
Compare
morrisonlevi
left a comment
There was a problem hiding this comment.
I merged in master to fix the merge conflict. Looks good. Hopefully no other weird edges pop up on 8.4+ and the API works as intended.
Description
Since #3360 and with #3361 we've disabled the code path for PHP 8.4's
zend_mm_set_custom_handlers_ex(). This PR re-enables that code path again bringing down overhead for allocation profiling.This uses the same approach as PHP <= 8.3 allocation profiling with the difference that for
alloc(),realloc()andfree()calls we do not "prepare" the ZendMM heap by manipulating theheap->use_custom_heapflag anymore. This was necessary for when the allocation fails, ZendMM might callzend_mm_gc()to try and free memory for a new chunk which would justreturn 0;in case a custom allocator is installed.With us being able to hook into
zend_mm_gc()we can stop manipulating theheap->use_custom_heapflag in the allocator hot path and only do so in case azend_mm_gc()was triggered.Additionally this adds a prof correctness test with a custom allocator being used by setting
USE_ZEND_ALLOC=0but validating against the JSON that we use for allocation profiling correctness -> even with a custom allocator we should emit the same profile as without.Reviewer checklist