Skip to content

Conversation

@realFlowControl
Copy link
Member

@realFlowControl realFlowControl commented Dec 27, 2025

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() and free() calls we do not "prepare" the ZendMM heap by manipulating the heap->use_custom_heap flag anymore. This was necessary for when the allocation fails, ZendMM might call zend_mm_gc() to try and free memory for a new chunk which would just return 0; in case a custom allocator is installed.

With us being able to hook into zend_mm_gc() we can stop manipulating the heap->use_custom_heap flag in the allocator hot path and only do so in case a zend_mm_gc() was triggered.

Additionally this adds a prof correctness test with a custom allocator being used by setting USE_ZEND_ALLOC=0 but 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

  • Test coverage seems ok.
  • Appropriate labels assigned.

@codecov-commenter
Copy link

codecov-commenter commented Dec 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.92%. Comparing base (7ae15a5) to head (3ca8f0e).

Additional details and impacted files

Impacted file tree graph

@@            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.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pr-commenter
Copy link

pr-commenter bot commented Dec 27, 2025

Benchmarks [ profiler ]

Benchmark execution time: 2026-01-16 23:23:05

Comparing candidate commit 3ca8f0e in PR branch florian/alloc-php-84 with baseline commit 7ae15a5 in branch master.

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

  • 🟥 execution_time [+27.176ms; +50.093ms] or [+2.211%; +4.075%]

@realFlowControl realFlowControl force-pushed the florian/alloc-php-84 branch 2 times, most recently from 4e8b1eb to b061348 Compare January 13, 2026 12:54
@datadog-official
Copy link

datadog-official bot commented Jan 13, 2026

⚠️ Tests

Fix all issues with Cursor

⚠️ Warnings

🧪 1022 Tests failed

    testSearchPhpBinaries from integration.DDTrace\Tests\Integration\PHPInstallerTest (Fix with Cursor)

    testSimplePushAndProcess from laravel-58-test.DDTrace\Tests\Integrations\Laravel\V5_8\QueueTest (Fix with Cursor)

testSimplePushAndProcess from laravel-8x-test.DDTrace\Tests\Integrations\Laravel\V8_x\QueueTest (Datadog) (Fix with Cursor)
DDTrace\Tests\Integrations\Laravel\V8_x\QueueTest::testSimplePushAndProcess
Test code or tested code printed unexpected output: spanLinksTraceId: 696ac637000000000fcd4089ba98eb42
tid: 696ac63700000000
hexProcessTraceId: 0fcd4089ba98eb42
hexProcessSpanId: 6c180d766aae3125
processTraceId: 1138637241079884610
processSpanId: 7788990357784375589

phpvfscomposer://tests/vendor/phpunit/phpunit/phpunit:106
View all

ℹ️ Info

❄️ No new flaky tests detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 3ca8f0e | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@realFlowControl realFlowControl force-pushed the florian/alloc-php-84 branch 2 times, most recently from c24208c to 1653fa2 Compare January 13, 2026 14:01
@realFlowControl realFlowControl marked this pull request as ready for review January 14, 2026 10:28
@realFlowControl realFlowControl requested review from a team as code owners January 14, 2026 10:28
@realFlowControl realFlowControl changed the title fix(prof): allocation profiling for PHP 8.4 feat(prof): allocation profiling for PHP 8.4 Jan 16, 2026
@realFlowControl realFlowControl changed the title feat(prof): allocation profiling for PHP 8.4 feat(prof): optimise allocation profiling for PHP >= 8.4 Jan 16, 2026
Copy link
Collaborator

@morrisonlevi morrisonlevi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@morrisonlevi morrisonlevi merged commit 1316514 into master Jan 16, 2026
1998 of 2009 checks passed
@morrisonlevi morrisonlevi deleted the florian/alloc-php-84 branch January 16, 2026 23:48
@github-actions github-actions bot added this to the 1.16.0 milestone Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants