Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Drop zend_mm_set_custom_debug_handlers() #13457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

Copy link
Contributor

@realFlowControl realFlowControl commented Feb 21, 2024
edited
Loading

Hey folks,

while working on #13432, I was about to add gc and shutdown hooks for ZEND_DEBUG builds and the zend_mm_set_custom_debug_handlers() function. It looked to me that this function serves no specific purpose anymore and we could just remove it in favour of adding ZEND_DEBUG support to the zend_mm_set_custom_handlers() function. This also saves a function call per every malloc/realloc/free call when a custom handler is around (and an additional compare operation in case a custom handler is installed in the ZEND_DEBUG case) and removes some code from ZendMM.

A quick GitHub search did not show anyone using this function (it could only be found in forks or other copies from php-src)

This brings one breaking change: extensions that are using the zend_mm_set_custom_handlers() would require a signature change in case they would still like to be compatible with debug builds (which they currently are). If we are talking about extensions that forward calls back to ZendMM (like the Datadog Profiler or https://github.com/arnaud-lb/php-memory-profiler), those would need to explicitly support debug builds using the ZEND_FILE_LINE_* macros already anyway (meaning they are not debug compatible currently and thus not a bc for them).

Copy link
Member

bwoebi commented Feb 21, 2024

I think that's reasonable. It makes implementations of custom handlers a bit simpler, especially if they forward the call to another handler.

@realFlowControl realFlowControl changed the title (削除) [WIP] Drop zend_mm_set_custom_debug_handlers() (削除ここまで) (追記) Drop zend_mm_set_custom_debug_handlers() (追記ここまで) Feb 22, 2024
@realFlowControl realFlowControl marked this pull request as ready for review February 22, 2024 06:50
@realFlowControl realFlowControl force-pushed the zendmm-remove-debug-custom-handlers branch from 86ead8a to eeb4e7e Compare February 22, 2024 08:31
Copy link
Contributor

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

Generally looks good to me, although I have never used the .debug API so that's an important caveat ^_^

Copy link
Member

dstogov commented Feb 26, 2024

This makes calls to user memory handlers more expensive and may require additional redirector to system malloc(). Also, this will probably "break" a few third party PHP extensions.

This change is not critical, but I wouldn't support it.

Copy link
Contributor Author

Thanks for having a look at the PR.

This makes calls to user memory handlers more expensive

In case of ndebug, those ZEND_FILE_LINE_* macros are empty. To my understanding we would save a function call (to _malloc_custom/__free_custom/__realloc_custom) on every single allocation/free/realloc. Only in case of a debug build it would add four arguments to every of those calls, but still save a function call. Am I missing something else?

Also, this will probably "break" a few third party PHP extensions.

You are right, extensions that are using the zend_mm_set_custom_handlers() would require a signature change in case they would still like to be compatible with debug builds (which they currently are). If we are talking about extensions that forward calls back to ZendMM (like the Datadog Profiler or https://github.com/arnaud-lb/php-memory-profiler), those would need top explicitly support debug builds using the ZEND_FILE_LINE_* macros already anyway.

Copy link
Member

dstogov commented Feb 26, 2024

Thanks for having a look at the PR.

This makes calls to user memory handlers more expensive

In case of ndebug, those ZEND_FILE_LINE_* macros are empty. To my understanding we would save a function call (to _malloc_custom/__free_custom/__realloc_custom) on every single allocation/free/realloc. Only in case of a debug build it would add four arguments to every of those calls, but still save a function call. Am I missing something else?

You are right. My argument was wrong and now I support this.

realFlowControl reacted with hooray emoji

@realFlowControl realFlowControl force-pushed the zendmm-remove-debug-custom-handlers branch from 0f5c255 to 63fe29f Compare February 26, 2024 11:30
@bwoebi bwoebi merged commit 14873dd into php:master Feb 26, 2024
@realFlowControl realFlowControl deleted the zendmm-remove-debug-custom-handlers branch February 26, 2024 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@morrisonlevi morrisonlevi morrisonlevi approved these changes

@dstogov dstogov Awaiting requested review from dstogov dstogov is a code owner

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /