php-spx icon indicating copy to clipboard operation
php-spx copied to clipboard

Do not enable SPX when JIT is enabled

Open NoiseByNorthwest opened this issue 1 year ago • 3 comments

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

NoiseByNorthwest avatar May 09 '23 10:05 NoiseByNorthwest

The SPX enabling must be discarded in this case with a notice log. This incompatibility should also be mentionned in the README.

NoiseByNorthwest avatar May 09 '23 10:05 NoiseByNorthwest

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

ilnytskyi avatar May 13 '23 09:05 ilnytskyi

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.

NoiseByNorthwest avatar May 15 '23 08:05 NoiseByNorthwest