How to enable the PHP opcache JIT compiler on Debian Bookworm

PHP 8.0 introduced a new JIT compiler, which theoretically decreases the processing time for PHP-generated content. According to the official instructions, it’s very easy to enable, but it is disabled by default in Debian and requires some slightly different configuration changes to re-enable. Be aware that the Debian maintainer decided to disable it due to reports of segfaults from some users. If you’d like to re-enable the JIT compiler anyway, here’s how:

nano /etc/php/8.2/mods-available/opcache.ini

Change opcache.jit=off to opcache.jit=function (you could also try opcache.jit=tracing, but that is the option that’s most commonly reported to cause segfaults). Also add a line opcache.jit_buffer_size=XM, where X is the maximum number of megabytes of memory you would like the JIT to use for caching. PHP.Watch recommends a value of 50% - 100% of opcache.memory_consumption, but they don’t give much justification. You will need to experiment to find a setting that works for you. (It’s also good to be aware that JIT will make no difference to I/O speeds, which takes up most of the running time of many common PHP scripts.)

Once you’ve made those changes and saved the ini file, reload FPM with systemctl reload php8.2-fpm.service. You can use a helper script such as opcache-gui to check on the status of the JIT cache.

Add new comment

CAPTCHA