Skip to content

opcache.jit explained: tuning OpCache JIT on cPanel PHP 8

opcache.jit sets how PHP 8 compiles code to machine code, and does nothing until jit_buffer_size is above zero. Set and verify it on a cPanel server.

opcache.jit controls PHP 8’s JIT (just-in-time) compiler, which turns frequently run PHP code into machine code. It accepts either a four-digit number in the form CRTO or one of the words disable, off, tracing (also spelled on) and function. The two named presets map to numbers: tracing is 1254 and function is 1205. Nothing you put in opcache.jit has any effect unless opcache.jit_buffer_size is greater than zero. That is the most common reason people report that enabling JIT changed nothing: before PHP 8.4 the buffer defaulted to 0, so the default tracing setting never ran. On a cPanel host, the settings that actually move your numbers are the plain OpCache ones: opcache.memory_consumption, opcache.max_accelerated_files, opcache.interned_strings_buffer and opcache.validate_timestamps. They live in /opt/cpanel/ea-php8X/root/etc/php.ini or a file in the php.d directory beside it. In WHM you reach them through MultiPHP INI Editor in Editor Mode, because Basic Mode does not show any opcache.* directive.

What you’ll accomplish

  • Read and write opcache.jit digit by digit, using the values the PHP manual documents rather than the ones copied around forums.
  • Find the ini file your cPanel PHP version actually loads, back it up, and change OpCache settings that survive a pool reload.
  • Size OpCache so it stops thrashing: no oom_restarts, no hash_restarts, hit rate in the high nineties.
  • Decide from measurement whether JIT is worth enabling for a workload — and revert it cleanly when it is not.
  • Prove the result from inside the PHP-FPM pool, not from a CLI process with its own separate cache.

Prerequisites

  • A cPanel or WHM server with EasyApache 4 PHP packages installed (ea-php80 through ea-php84) and root access for system-level ini edits.
  • PHP 8.0 or newer. The CRTO format is identical across 8.0 to 8.4; only the defaults changed. Before PHP 8.4: opcache.jit=tracing with opcache.jit_buffer_size=0. As of PHP 8.4: opcache.jit=disable with opcache.jit_buffer_size=64M. Either way the shipped configuration leaves JIT inert until you set both.
  • The ea-php8X-php-opcache package installed for the version you are tuning. If no opcache.* directive appears in php -i, the extension is not loaded and ini editing will not change that.
  • On CloudLinux, know whether the account runs an EasyApache ea-php or a PHP Selector alt-php build. They read different ini trees and the paths below do not apply to alt-php.
  • A way to generate representative load — ab, wrk or a recorded traffic replay. One URL hit ten times tells you nothing.

How it works

OpCache and JIT are separate things that ship in the same extension and get conflated constantly.

OpCache is a bytecode cache. Without it every request re-reads your PHP source, tokenises it, parses it and compiles it into Zend opcodes before executing a line. OpCache does that once, keeps the opcodes in shared memory, and later requests skip straight to execution. It is on by default and it is the part worth tuning.

JIT compiles some of those opcodes further, down to native machine code, bypassing the Zend VM dispatch loop for hot paths. It makes opcode execution faster. It does not make database queries, filesystem calls, or outbound HTTP faster, because those are not opcode execution.

That distinction is the whole article, and a real request makes it concrete:

Request path through page cache, PHP-FPM, OpCache and JIT, with a bar showing that database round-trips dominate wall time while JIT only shortens the opcode slice

On a typical WordPress, WooCommerce, Drupal or Laravel request the wall clock is dominated by database round-trips and I/O. JIT accelerates the thin band left over: doubling the speed of a slice worth 20% of the request buys 10% at best, and real measurements usually land in single digits, inside the noise of a shared host. That is not a criticism of JIT, it is a statement about what web request time is made of. Workloads where JIT does earn its place look different — numeric loops, statistics work, image manipulation written in pure PHP rather than delegated to GD or ImageMagick, long-running CLI compute, userland parsers chewing through large inputs.

Reading the CRTO digits

opcache.jit is a four-digit flag, one digit per position:

PositionMeaningValues
CCPU-specific optimisation flags0 disable CPU-specific optimisation · 1 enable use of AVX if the CPU supports it
RRegister allocation0 none · 1 block-local · 2 global
TTrigger0 compile all functions on script load · 1 compile functions on first execution · 2 profile functions on first request, compile the hottest afterwards · 3 profile on the fly and compile hot functions · 4 currently unused · 5 tracing JIT: profile on the fly and compile traces for hot code segments
OOptimisation level0 no JIT · 1 minimal, call standard VM handlers · 2 inline VM handlers · 3 type inference · 4 call graph · 5 optimise whole script

So tracing = 1254 is AVX on, global register allocation, tracing trigger, call-graph optimisation; function = 1205 is AVX on, global register allocation, compile everything at script load, whole-script optimisation. Any value ending in 0 sets the optimisation level to “no JIT”, so 1250 is a disabled JIT written the long way.

The two word forms that are not presets matter too. off disables JIT but leaves it re-enablable at runtime, because opcache.jit is INI_ALL. disable turns it off completely and it cannot be switched back on at runtime. Use off while testing; reach for disable only when you want the door bolted.

Where the values can be set

This trips people up on shared hosting. The sizing directives — opcache.memory_consumption, opcache.interned_strings_buffer, opcache.max_accelerated_files, opcache.jit_buffer_size — are INI_SYSTEM: settable only in the system php.ini for that PHP version, applied when the process starts, and untouchable from an account’s .user.ini. opcache.jit, opcache.validate_timestamps and opcache.revalidate_freq are INI_ALL and can be set per account. So an account cannot enable JIT for itself, because the buffer it needs is system-level.

OpCache memory is also per PHP process pool, not per server. With one FPM pool per account, every account gets its own arena of opcache.memory_consumption megabytes. Setting 512M on a server with 200 accounts asks for 100 GB of shared memory, not 512 MB.

Step-by-step

  1. Find the ini files your PHP version actually loads. Do not guess the path; ask PHP.

    /opt/cpanel/ea-php83/root/usr/bin/php --ini

    Expected output names the loaded file and the scan directory:

    Configuration File (php.ini) Path: /opt/cpanel/ea-php83/root/etc
    Loaded Configuration File:         /opt/cpanel/ea-php83/root/etc/php.ini
    Scan for additional .ini files in: /opt/cpanel/ea-php83/root/etc/php.d
    Additional .ini files parsed:      /opt/cpanel/ea-php83/root/etc/php.d/10-opcache.ini, ...

    Whatever appears on that last line is where the OpCache defaults come from. php.ini is parsed first and the scan directory can override it, so if a directive refuses to change, check whether a php.d file is setting it after you.

  2. Record the current values first.

    /opt/cpanel/ea-php83/root/usr/bin/php -i | grep -E '^opcache\.(enable|memory_consumption|interned_strings_buffer|max_accelerated_files|validate_timestamps|revalidate_freq|jit|jit_buffer_size)'

    On a stock PHP 8.3 EasyApache install, close to:

    opcache.enable => On => On
    opcache.interned_strings_buffer => 8 => 8
    opcache.jit => tracing => tracing
    opcache.jit_buffer_size => 0 => 0
    opcache.max_accelerated_files => 10000 => 10000
    opcache.memory_consumption => 128 => 128
    opcache.revalidate_freq => 2 => 2
    opcache.validate_timestamps => On => On

    opcache.jit => tracing with jit_buffer_size => 0 is the configuration that makes people believe JIT is running when it is not.

  3. Back up the file you are about to edit. This is the rollback path for everything below, so do it first.

    cp -a /opt/cpanel/ea-php83/root/etc/php.ini /root/php.ini.ea-php83.bak-$(date +%F)
    ls -l /root/php.ini.ea-php83.bak-$(date +%F)
  4. Size plain OpCache for the workload. These are the changes that pay. In WHM, open Software → MultiPHP INI Editor, select the PHP version, and switch to Editor Mode — Basic Mode exposes about two dozen common directives and none are opcache.*. Editor Mode writes to /opt/cpanel/<php_package>/root/etc/php.ini. Starting values for a busy site with a large plugin or vendor tree:

    opcache.memory_consumption=192
    opcache.interned_strings_buffer=16
    opcache.max_accelerated_files=20000
    opcache.validate_timestamps=1
    opcache.revalidate_freq=2

    PHP rounds max_accelerated_files up internally, so a reported figure slightly above 20000 is normal. Count your files before choosing it:

    find /home/USER/public_html -name '*.php' -type f | wc -l

    If that returns 14,800, the default 10000 is too small and the cache is evicting constantly.

  5. Decide about JIT deliberately. Work the tree rather than the forum post:

    Decision tree: measure first, then either tune plain OpCache and stop, or set jit_buffer_size, pick tracing or function, benchmark, and keep or revert

    On the right-hand branch, both lines are required:

    opcache.jit_buffer_size=64M
    opcache.jit=tracing

    Setting only the second is the mistake this article opens with.

  6. Apply the change to the running pool. PHP-FPM parses its ini once at master start; an edited file changes nothing until the master re-reads it. A reload is gentler than a restart but not free — workers are cycled and in-flight requests can be cut. Do it in a low-traffic window; if anything looks wrong, restore the backup from step 3 and reload again.

    systemctl reload ea-php83-php-fpm
    systemctl status ea-php83-php-fpm --no-pager

    Expect active (running) and a recent timestamp. cPanel’s wrapper /usr/local/cpanel/scripts/restartsrv_apache_php_fpm does a full restart and reports the new PID; use it when systemctl is uncooperative.

    Handler matters here. Under PHP-FPM and LSAPI the process persists between requests, so OpCache is shared and useful and ini changes need the reload above. Under CGI/FastCGI or suPHP the process is created and destroyed per request: it re-reads the ini every time, no restart needed, but it also starts with an empty OpCache every time, which makes tuning close to pointless. If accounts are still on suPHP, switching handler is the bigger win — the PHP version and handler strategy guide covers picking one.

  7. On CloudLinux, repeat in the right tree. PHP Selector’s alt-php builds are separate from EasyApache, live under /opt/alt/php8X/, and are controlled per user through selectorctl, each user’s settings held in their own alt_php.ini inside CageFS. Check which build an account is on before editing anything:

    selectorctl --user-current --user=USER
    selectorctl --list

    Because CageFS gives each user their own filesystem view and their own PHP processes, OpCache sizing on a Selector host is unambiguously per account. Multiply before you raise it.

Validate it works

Configuration state is readable from the CLI. Live statistics are not — opcache_get_status() run from the command line reports the CLI process’s own cache, which is empty and usually disabled (opcache.enable_cli defaults to 0). To see the FPM pool you have to ask from inside it. Confirm the ini took first:

/opt/cpanel/ea-php83/root/usr/bin/php -i | grep -E '^opcache\.(memory_consumption|max_accelerated_files|jit|jit_buffer_size)'
opcache.jit => tracing => tracing
opcache.jit_buffer_size => 64M => 64M
opcache.max_accelerated_files => 20000 => 20000
opcache.memory_consumption => 192 => 192

Then read the running pool with a short-lived script. Give it an unguessable name, read it once, delete it in the same sitting — an OpCache status endpoint left in a document root leaks your file paths, PHP version and entire cached script list to anyone who finds it.

cd /home/USER/public_html
NAME="oc-$(openssl rand -hex 12).php"
cat > "$NAME" <<'PHP'
<?php
header('Content-Type: text/plain');
$s = opcache_get_status(false);
if ($s === false) { exit("OpCache is not active in this SAPI\n"); }
$st = $s['opcache_statistics'];
printf("hit_rate      %.2f%%\n", $st['opcache_hit_rate']);
printf("keys          %d of %d\n", $st['num_cached_keys'], $st['max_cached_keys']);
printf("oom_restarts  %d\n", $st['oom_restarts']);
printf("hash_restarts %d\n", $st['hash_restarts']);
printf("free_memory   %d\n", $s['memory_usage']['free_memory']);
print_r($s['jit'] ?? 'no jit data');
PHP
chown USER:USER "$NAME"
echo "https://example.com/$NAME"

Fetch it, then remove it immediately:

curl -s "https://example.com/$NAME"
rm -f "/home/USER/public_html/$NAME"

A healthy pool that has served traffic for an hour or two looks like this:

hit_rate      98.71%
keys          15842 of 32531
oom_restarts  0
hash_restarts 0
free_memory   41238016
Array
(
    [enabled] => 1
    [on] => 1
    [kind] => 1
    [opt_level] => 4
    [buffer_size] => 67108848
    [buffer_free] => 66584112
)

hit_rate below roughly 95% on a settled pool means scripts are being evicted. oom_restarts above 0 means opcache.memory_consumption is too small; hash_restarts above 0, or keys approaching max_cached_keys, means opcache.max_accelerated_files is too small. For JIT, enabled and on must both be 1, and buffer_free below buffer_size proves code is genuinely being compiled rather than the flag merely being set.

Finally, benchmark what you care about — same URL, warm cache, at least a thousand requests per side, medians compared:

ab -n 1000 -c 10 https://example.com/product/example-item/ | grep -E '50%|Requests per second'

If the two medians differ by less than the run-to-run spread of either side, JIT did nothing for you. That is a result, not a failure; revert.

Troubleshooting

JIT is “on” but nothing changed. Check jit_buffer_size first. A value of 0 disables JIT no matter what opcache.jit says, and that was the shipped default for every PHP release before 8.4. The jit block in opcache_get_status() settles it: if buffer_size is 0, nothing was ever enabled.

The ini was edited but nothing changed. Either the PHP-FPM master was never reloaded and is still running the ini it parsed at boot — re-read step 6 — or a php.d file is parsed after php.ini and overrides you. The --ini output from step 1 lists the parse order; edit the later file.

Code changes stop appearing on the site. Someone set opcache.validate_timestamps=0. That is correct for an immutable deployment that reloads the pool on every release, and harmful on a site edited in place — cached opcodes are served forever and file edits are invisible. Where clients edit theme files through File Manager, leave it at 1. If you want 0, the release process must reload the FPM pool; there is no middle ground.

Intermittent slowness with no obvious cause. Watch oom_restarts over a day. When OpCache runs out of memory it discards the whole cache and starts over, so every script recompiles at once — a latency spike that looks random and correlates with nothing in the slow query log. Raise opcache.memory_consumption, remembering the per-pool multiplication, and confirm the counter stays at 0.

PHP segfaults after enabling JIT. JIT has historically interacted badly with tracing and profiling extensions. Back it out rather than debugging under load: set opcache.jit=off, reload the pool, confirm the crashes stop. If you still want JIT, re-enable it with the profiling extension disabled and test on a staging account. Check /opt/cpanel/ea-php83/root/usr/var/log/php-fpm/error.log and the account’s error log for the signal raised.

When this is the wrong approach

If the site is slow because of unindexed queries, an oversized wp_options autoload set, a plugin making synchronous outbound API calls on every page load, or the plain absence of a page cache, then OpCache and JIT are noise. The request path diagram shows why: a page cache hit returns HTML without PHP running at all, removing the entire PHP segment — categorically more than JIT can offer on a fraction of it. Get an LSCache baseline in place before spending an evening on ini digits.

It is also wrong when you cannot measure: without a before-and-after on a representative endpoint you will not know whether the numbers moved. And when a site is CPU-bound because of an algorithm doing work it does not need to do, JIT makes the wrong thing 20% faster instead of removing it.

For the directives themselves, the PHP manual’s OpCache configuration page is the source worth trusting on digit semantics and defaults; cPanel’s documentation covers MultiPHP INI Editor and the EasyApache 4 layout.

If this is the kind of work you’d rather never own again, it’s the daily job of Managed Cloud Ops — book an infrastructure review.