| ab | Yes | 2015-01-09 09:19 |
| aharvey | Yes | 2015-01-07 19:37 |
| ajf | Yes | 2015-01-07 19:34 |
| bwoebi | Yes | 2015-01-16 00:49 |
| derick | Yes | 2015-01-08 11:50 |
| dragoonis | Yes | 2015-01-17 20:40 |
| guilhermeblanco | Yes | 2015-01-08 22:52 |
| irker | Yes | 2015-01-08 12:06 |
| jedibc | Yes | 2015-01-12 11:17 |
| kalle | Yes | 2015-01-20 13:28 |
| krakjoe | Yes | 2015-01-08 07:10 |
| leigh | Yes | 2015-01-07 19:33 |
| lstrojny | Yes | 2015-01-19 12:43 |
| rdlowrey | Yes | 2015-01-21 16:05 |
| rdohms | Yes | 2015-01-14 11:25 |
| reeze | Yes | 2015-01-08 10:34 |
| salathe | Yes | 2015-01-14 20:21 |
| treffynnon | Yes | 2015-01-21 09:16 |
Copied from wiki.php.net, last synchronized Oct 13, 2026 11:51 UTC
This RFC proposes to change gc_collect_cycles into a hookable function pointer. The goal is to allow extensions to hook into garbage collection for profiling.
PHP Profilers usually hook into zend_execute and zend_execute_internal to measure execution time before and after the call. Because Garbage Collection is triggered during ALLOC_ZVAL and FREE_ZVAL (5.*) and during variable/object release this can happen “undeterministically” in a random function call from the perspective of the developer. This skews reporting actual execution times.
Turning garbage collection into a function pointer would allow to measure the time spent in garbage collection and substract that from the actual function calls. This would allow Profilers to correct time spent in execution for accidentally triggered GC. It would also allow to give hints about inefficient garbage collection runs that should prompt a developer to consider calling gc_disable() in userland.
A default implementation zend_gc_collect_cycles will implement the current behavior.
Adam tested the performance of this change and there was no measurable overhead:
https://github.com/LawnGnome/php-gc-benchmark
On the mailinglist a discussion began weather this change should be part of a grand refactoring of hooks and extension API.
Making this change part of a grand refactoring will never lead to the inclusion since as of now, we know of nobody planning on working on the extension API for 7.0.
The RFC proposes to include the change AS-IS and then be part of a refactoring in the future, should one happen.
No changes to userland.
This changes the signature of gc_collect_cycles in Zend/zend_gc.h file and should therefore target only 7.0
- PHP 7.0
None
None
None
This does not actually add profiling to garbage collection, it only allows extensions to build this on top.
Adam Harvey has a patch for this feature here: https://github.com/LawnGnome/php-src/compare/gc-fn-pointer
Initial discussion on hooking into Garbage Collection: https://github.com/php/php-src/pull/930
Vote: Turn gc_collect_cycles into function pointer? — Yes: 18 · No: 0 (closed)
Voting started: 2015-01-07 19:31 UTC Voting ended: 2015-01-21 19:31 UTC (14 days)