Enabling the JIT Compiler
Learn about the configurations needed to enable the JIT compiler in PHP 8.
Because the primary function of the JIT compiler is to cache machine code, it operates as an independent part of the OPcache extension. OPcache serves as a gateway to both enable JIT functionality as well as to allocate memory to the JIT compiler from its own allotment. Therefore, in order to enable the JIT compiler, we must first enable OPcache.
In order to enable the JIT compiler, we must first confirm that PHP has been compiled with the --enable-opcache-jit
configuration option. We are then in a position to enable or disable the JIT compiler by simply assigning a nonzero value to the php.ini
file’s opcache.jit_buffer_size
directive.
Values are specified either as an integer—in which case, the value represents the number of bytes (a value of zero, the default, which disables the JIT compiler), or we can assign a number followed by any of the following letters:
K
: KilobytesM
: MegabytesG
: Gigabytes
The value we specify for the JIT compiler buffer size must be less than the memory allocation we assigned to OPcache because the JIT buffer is taken out of the OPcache buffer.
Here is an example that sets the OPcache memory consumption to 256 M and the JIT buffer to 64 M. These values can be placed anywhere in the php.ini
file:
Get hands-on with 1200+ tech skills courses.