JIT Compilation — PHP Has a JIT Compiler
Yes, really. PHP 8.0 ships a tracing JIT compiler. For numeric and CPU-bound code, it delivers 3–10× speedups over interpreted execution. This is the feature PHP critics never mention.
; php.ini — enable tracing JIT (the most aggressive mode)
opcache.enable=1
opcache.jit_buffer_size=100M
opcache.jit=tracing
; Alternatively, function-level JIT for a lighter touch
opcache.jit=function
The JIT works in two modes. Function JIT compiles entire functions ahead-of-time. Tracing JIT profiles hot paths at runtime and compiles only the loops and branches that actually run — the same strategy used by V8 and LuaJIT. For web request workloads, OPcache alone gives most of the gains. Where JIT shines is pure computation: image processing, machine learning inference, mathematical simulations, and game servers written in PHP.
// Benchmark: sum of squares, 10 million iterations
// Without JIT: ~1.8 seconds
// With JIT: ~0.22 seconds (~8× faster)
$sum = 0.0;
for ($i = 0; $i < 10_000_000; $i++) {
$sum += $i * $i;
}
echo $sum; // 3.3333333283267E+20
The JIT is built on top of OPcache and shares its infrastructure. It doesn't change the semantics of PHP at all — code that runs correctly without JIT runs identically with it.