Enable PHP JIT

Enable PHP JIT

Marcus

Well-known member
Marcus submitted a new resource:

Enable PHP JIT - Enabling JIT makes PHP 8.x run faster

Enabling JIT makes PHP run faster

1 Check whether JIT is running​

Bash:
#php -i | grep -q 'opcache.jit_buffer_size => [^0]' && echo "JIT is enabled" || echo "JIT is disabled"

2 In etc/config.php

PHP:
ini_set('opcache.enable', '1');
ini_set('opcache.jit_buffer_size', '100M');
ini_set('opcache.jit', '1254');

Read more about this resource...
 
Marcus said:

Find your php.ini
Bash:
#php -i | grep 'Loaded Configuration File' | awk '{print $NF}'

Be aware that this may not lead you to your webserver php configuration file. Eg. you use fpm for your webserver php connection, the above/quoted will return the cli/console/terminal php config file, and not the fpm config file.

It would be better if admin's visited /admin.php?tools/phpinfo and used the 'Loaded Configuration File' reference for the config file location.
 
Thanks ! I have updated the resource with your description on how to find the correct php.ini!
 
Tracing is the default. I also set 200 MB but that's more of a personal decision as I have more RAM than I need. My idea was to have the easiest setup possible to enable JIT. Which is two lines in php.ini and restarting both PHP(-fpm) and the webserver.

From the provided graph Wordpress gains 5% now XenForo could gain more or less. So it is not the huge thing where a forum is lightning fast after just a simple configuration change. But still, a bit here and there might make a difference.

Here today (https://xenforo.com/community/threa...ode-bases-like-wordpress.221631/#post-1681951) from what I get out of that is that the newer PHP releases without JIT are always as good as the older with JIT enabled.

As for easy setup, this week I also took a look into a really easy redis setup (because the Filesystem cache messed up my latest beta update) and it's actually this, one line to install php-redis and the server is installed, too. Then in config.php you just have to change the name of the cache to "Redis" and put the 127.0.0.1 as the host. Done. Most things sound very difficult as for sure you can make so much out of it. But like in the case with JIT and the 5% speed gain, I would just take it as easy as it gets.
 
Last edited:
To be ahead of the game be aware there are 2 default ini changes regarding JIT coming in PHP 8.4. JIT continues to be turned off by default in PHP 8.4.

In PHP 8.0 ≤ 8.3.x default ini values are:
INI:
opcache.jit=tracing
opcache.jit_buffer_size=0

In PHP 8.0 ≤ 8.3.x the minimum change required to turn on JIT is to raise the default opcache.jit_buffer_size above the default "0". A minimum of "64M", up to a maximum of "512M" is the recommended range. Do this by changing the opcache.jit_buffer_size:
INI:
opcache.jit_buffer_size=64M

-------------------------------------------

In PHP ≥ 8.4.x default ini values are:
INI:
opcache.jit=disable
opcache.jit_buffer_size=64M

In PHP ≥ 8.4.x the minimum change required to turn on JIT is to set opcache.jit to "tracing". You can also raise the opcache.jit_buffer_size above the default minimum set to "64M", up to a maximum recommended "512M".
INI:
opcache.jit=tracing
 
Last edited:
If you enable JIT and your php-fpm keeps dying, and you're on a RHEL type system (Centos, Rocky Linux, etc) - and have selinux enabled - run this command to give php-fpm permission.

[root@pc-web1 html]# setsebool -P httpd_execmem on
[root@pc-web1 html]#

And you can check the permission via this command:

[root@pc-web1 html]# getsebool -a | grep httpd_execmem
httpd_execmem --> on
[root@pc-web1 html]#

And just for reference - here's the documentation:

Redhat SELinux Booleans

Dont forget to restart php-fpm after the change.

[root@pc-web1 html]# systemctl restart php-fpm
[root@pc-web1 html]#
 
Top Bottom