Activate PHP 8 JIT compiler in Plesk

In this article we explain how to enable and configure the PHP 8 JIT compiler in Plesk Obsidian.

Prerequisites

The following prerequisites must be met in order to activate the JIT compiler:

  • Plesk Obsidian 18.0.33 or higher
  • Enabled OPcache in the Plesk PHP settings (opcache.enable)
  • PHP 8.0, PHP 8.1, PHP 8.2 or PHP 8.3 installation (e.g. via the Plesk graphical user interface)
  • SSH root access


If PHP 8.0, PHP 8.1, PHP 8.2 or PHP 8.3 has not yet been installed on your creoline server, please refer to the article PHP 8 Installation for step-by-step instructions on how to install PHP 8 via the Plesk graphical user interface.



Activation of the JIT compiler

For the activation it is necessary that an additional PHP configuration file for the PHP 8 FPM handler is stored on the server.


Important:
The runtime configuration cannot be activated via the PHP settings in the Plesk graphical user interface.


Execute the following shell command via SSH on your creoline server:

# PHP 8.0
echo -e 'opcache.jit_buffer_size=100M\nopcache.jit=1255' > /opt/plesk/php/8.0/etc/php.d/opcache_jit.ini

# PHP 8.1
echo -e 'opcache.jit_buffer_size=100M\nopcache.jit=1255' > /opt/plesk/php/8.1/etc/php.d/opcache_jit.ini

# PHP 8.2
echo -e 'opcache.jit_buffer_size=100M\nopcache.jit=1255' > /opt/plesk/php/8.2/etc/php.d/opcache_jit.ini

# PHP 8.3
echo -e 'opcache.jit_buffer_size=100M\nopcache.jit=1255' > /opt/plesk/php/8.3/etc/php.d/opcache_jit.ini


After the configuration file has been saved, PHP 8 must be reloaded so that the configuration is activated:

# PHP 8.0
systemctl reload plesk-php80-fpm

# PHP 8.1
systemctl reload plesk-php81-fpm

# PHP 8.2
systemctl reload plesk-php82-fpm

# PHP 8.3
systemctl reload plesk-php83-fpm


The following PHP script can be used to check whether the JIT compiler has been activated correctly:

<?php

echo '<pre>';
print_r(opcache_get_status()['jit']);


Example output:

array
(
    [enabled] => 1
    [on] => 1
    [kind] => 5
    [opt_level] => 5
    [opt_flags] => 6
    [buffer_size] => 104857584
    [buffer_free] => 104855104
)



Attention:
In order to test whether the JIT compiler is active, the opcache_get_status function must be explicitly activated in Plesk. In the standard Plesk installation, the function is deactivated in the PHP settings under "disable_functions" for security reasons.





Configuration of the JIT compiler

The configuration of the JIT compiler is defined via the opcache.jit variable. E.G: opcache.jit=1255

Each individual digit represents a configuration parameter setting. A detailed explanation can be found in the official RFC (wiki.php.net).


CPU specific optimization flags (C)

Parameter 1

0 - none
1 - enable AVX instruction generation

Register Allocation (R)

Parameter 2

0 - dont perform register allocation
1 - use local liner-scan register allocator
2 - use global liner-scan register allocator

JIT trigger (T)

Parameter 3

0 - JIT all functions on first script load
1 - JIT function on first execution
2 - Profile on first request and compile hot functions on second request
3 - Profile on the fly and compile hot functions
4 - Compile functions with @jit tag in doc-comments
5 - Tracing JIT

Optimization level (O)

Parameter 4

0 - dont JIT
1 - minimal JIT (call standard VM handlers)
2 - selective VM handler inlining
3 - optimized JIT based on static type inference of individual function
4 - optimized JIT based on static type inference and call tree
5 - optimized JIT based on static type inference and inner procedure analyses



Example configuration

In our example configuration, we use the following settings:

opcache.jit=1255


Parameter Value Description
CPU specific optimization flags 1 enable AVX instruction generation
Register Allocation 2 use global liner-scan register allocator
JIT trigger 5 Tracing JIT
Optimization level 5 optimized JIT based on static type inference and inner procedure analyses