php-spx
php-spx copied to clipboard
Do not enable SPX when JIT is enabled
I've observed that when SPX is enabled, even if not active (i.e. auto_start=0), with JIT enabled (opcache.jit=tracing), it makes the execution flow somewhat corrupted (in my case an error is triggered with an inconsistent stack trace).
The SPX enabling must be discarded in this case with a notice log. This incompatibility should also be mentionned in the README.
Maybe native API for observation zend_observer_fcall_handlers
and zend_observer_fcall_register
can be added for PHP > 8 instead of overriding zend_execute_ex
. The only disadvantage it does not capture internal functions calls, but only user defined, that is still covering most of the cases considering the fact profiling of builtins is disabled by default.
However I am not sure how this approach can affect metrics and other spx features compatibility.
xhprof doing something like this:
#if PHP_VERSION_ID >= 80000
#include "zend_observer.h"
https://github.com/tideways/php-xhprof-extension/blob/8b1571c76b8a1b68ac06cfce2861e44e2f6930fb/tideways_xhprof.c#L30
Indeed, here is the corresponding patch thread https://github.com/tideways/php-xhprof-extension/pull/96
I'm however wondering how it hurts performances and if the SPX hooking abstraction should in the end choose between a zend_execute_ex or a zend_observer based backend whether JIT is enabled or not. It would also allow to keep the internal function profiling feature.