PHP 8.0 introduced the JIT (Just‑In‑Time) compilation engine, a feature that promised to push PHP performance closer to compiled languages. With PHP 8.5 now the latest stable branch, JIT has matured and is enabled by default in many hosting environments. But the question remains: how much real‑world speedup does JIT actually deliver?
In our previous benchmark, we compared PHP 8.3, 8.4, and 8.5 with JIT disabled to isolate core engine improvements. This time, we take the best performer – PHP 8.5.2 – and run it head‑to‑head: JIT enabled vs. JIT disabled.
We use the exact same CPU‑intensive script (Fibonacci + 1M loop iterations) to see how much of a difference JIT makes. All tests are reproducible, and you’ll find the full scripts at the end.
| Component | Specification |
|---|---|
| CPU | Intel(R) Xeon(R) Platinum 4-core (vCPU) |
| RAM | 8GB ECC |
| OS | Ubuntu 24.04.3 LTS |
| Web Server | Nginx 1.24 |
| PHP Versions | 8.5.2 (latest patch) |
| PHP-FPM | Static processes, pm.max_children = 100 |
| OPcache | Enabled (required for JIT) |
| JIT Mode | Tracing (opcache.jit = tracing) |
| JIT Buffer Size | 128 MB (opcache.jit_buffer_size = 128M) |
| Concurrency | 1 (single request at a time) |
| Total Requests | 1,000 per test run |
| Warm‑up | 100 requests before each run (results discarded) |
note:The server was restarted between the two test series (JIT off / JIT on) to clear any caches.
Methodology
- Test script – The same CPU‑heavy script was used for both JIT off and JIT on runs:
- Recursive Fibonacci up to
fibonacci(35)(≈ 18 million function calls). - 1,000,000 iterations of mathematical operations (
sqrt()andsin()). - The script outputs only a fixed string
"OK"to guarantee identical response lengths forab.
- Memory measurement – Peak memory usage was captured with
memory_get_peak_usage(true)and written to a log file after each request. - Each JIT setting was tested with five independent runs of 1000 requests each.
- For every metric, the highest and lowest values were discarded, and the remaining three were averaged.
- Concurrency was kept at 1 to measure pure CPU performance without process‑pool contention.
Results
Below are the raw numbers from five consecutive runs for each JIT configuration. The final averages (after removing min and max) are used for comparison.
Table 1: JIT Disabled vs Enabled – Raw Data
| Test Run | JIT Disabled (req/s) | JIT Disabled (time, ms) | JIT Disabled (memory, MB) | JIT Enabled (req/s) | JIT Enabled (time, ms) | JIT Enabled (memory, MB) |
|---|---|---|---|---|---|---|
| Run 1 | 1.76 | 567.303 | 2 | 3.71 | 269.798 | 2 |
| Run 2 | 1.77 | 565.092 | 2 | 3.71 | 269.703 | 2 |
| Run 3 | 1.76 | 566.666 | 2 | 3.75 | 266.786 | 2 |
| Run 4 | 1.76 | 569.745 | 2 | 3.70 | 270.013 | 2 |
| Run 5 | 1.75 | 571.253 | 2 | 3.69 | 270.922 | 2 |
| Average (filtered) | 1.76 | 567.90 | 2 | 3.71 | 269.84 | 2 |
*Each cell shows Requests per second followed by average response time in ms (higher req/s and lower response time are better).*
Table 2: Key Metrics Comparison
| Metric | JIT Disabled | JIT Enabled | Improvement |
|---|---|---|---|
| Avg Requests/sec | 1.76 | 3.71 | +110.8% |
| Avg Time per Request (ms) | 567.90 | 269.84 | -52.5% |
| Memory Peak (MB) | 2.0 | 2.0 | 0% |
| Error Rate | 0% | 0% | – |
*Memory values are approximate and may vary slightly between runs.*
Analysis
The data speaks clearly:
- Throughput jump: Enabling JIT (tracing mode) increased requests per second by over 110% (from 1.76 to 3.71). For CPU‑bound workloads, this is a massive boost.
- Latency drop: Average response time fell by more than 52% (from 568 ms to 270 ms), meaning each request finishes in less than half the time.
- Memory unchanged: Peak memory usage stayed at 2 MB, showing that JIT introduces no measurable memory overhead in this test – an excellent trade‑off.
- Stability: The low standard deviation across runs (especially for JIT enabled) confirms the consistency of the test environment and the maturity of the JIT compiler.
These improvements far exceed typical expectations: our script, with its deep recursion and heavy loops, is the perfect candidate for JIT optimisation. In fact, enabling JIT more than doubled the throughput – a result that will surprise many developers accustomed to modest 5‑10% gains.
Should You Enable JIT in Production?
The answer depends on your application profile – and our benchmark provides a clear reference point.
JIT is a massive win if your application is CPU‑bound
Examples include image processing, PDF generation, complex calculations, data analysis, and long‑running background jobs.
Our test shows a 110% throughput increase and 52% lower latency with JIT enabled. If your code does serious number‑crunching, you can expect gains in this ballpark – potentially doubling performance with zero extra memory cost.
For typical web applications (WordPress, Laravel, etc.)
Most web requests are I/O‑bound – waiting for databases, files, or external APIs. Here, CPU is rarely the bottleneck, so JIT’s impact is usually smaller (often 1‑5%).
However, JIT rarely hurts performance, and it can still help with background tasks (e.g., cron jobs, queue workers). Our recommendation: enable it, but don’t expect miracles – and always measure.
Things to watch out for
- Memory: JIT reserves a buffer (
jit_buffer_size). The default 128M is fine for most sites, but on memory‑constrained hosts you may want to lower it. - Compatibility: JIT works with all standard PHP code, but some very old extensions might not be aware of it. Test in a staging environment first.
- Real‑world variance: Your mileage will vary. Our 110% gain came from an ideal CPU‑heavy script – real applications mix I/O and CPU, so results will differ. Always benchmark your own workload.
Conclusion
- PHP 8.5 with JIT enabled delivers a game‑changing performance boost for CPU‑heavy workloads – in our tests, throughput more than doubled and response time was cut in half.
- Memory overhead is zero, making this optimisation essentially free.
- For any application with significant CPU‑bound tasks, enabling JIT is no longer just “nice to have” – it’s a must.
Frequently Asked Questions
A: Tracing mode (tracing or 1255) is generally recommended for most applications because it can optimise larger code regions. Function mode (function or 1205) only compiles whole functions and often yields smaller gains.
A: Ensure OPcache is enabled, then add the following to your php.ini:
opcache.jit = tracing
opcache.jit_buffer_size = 128M
After saving the file, restart PHP‑FPM and verify that JIT is active by checking phpinfo() (look for opcache.jit and opcache.jit_buffer_size).
A: Yes, WordPress runs fine with JIT enabled. However, because WordPress is mostly I/O‑bound (waiting for database queries, file reads, etc.), the performance improvement is usually modest. We’ll cover WordPress‑specific benchmarks in a future article.
A: Your code may not have long‑running “hot” loops that JIT can optimise. JIT shines on repetitive CPU‑intensive work, not on one‑off scripts or I/O‑wait operations. If your application is I/O‑bound, the bottleneck isn’t CPU, so JIT won’t help much.
Test Scripts (for Reproducibility)
Important: Run these commands only on your own isolated test server. Never load‑test a production site.
PHP Benchmark Script (test.php)
<?php
set_time_limit(0);
function fibonacci($n) {
if ($n <= 1) return $n;
return fibonacci($n-1) + fibonacci($n-2);
}
function loopTest($iterations) {
$result = 0;
for ($i = 0; $i < $iterations; $i++) {
$result += sqrt($i) * sin($i);
}
return $result;
}
fibonacci(35);
loopTest(1000000);
// Optional: log memory peak
$memoryPeak = memory_get_peak_usage(true);
file_put_contents('/tmp/php85_jit_memory.log', date('Y-m-d H:i:s') . " - Memory peak: " . round($memoryPeak / 1024 / 1024, 2) . " MB\n", FILE_APPEND);
echo "OK";
?>Apache Bench Commands
# Test JIT disabled (after configuring JIT=disable)
ab -n 1000 -c 1 https://phpbenchlab.com:8083/test.php
# Test JIT enabled (after configuring JIT=tracing)
ab -n 1000 -c 1 https://phpbenchlab.com:8083/test.phpThis test focused on pure CPU workloads. We later extended this JIT analysis to test its impact under heavy I/O latency. The PHP 8.5 JIT I/O latency benchmark reveals that JIT provides zero benefit—and sometimes a penalty—for slow database queries across all four application servers.
All raw data and scripts are provided. Feel free to reproduce this benchmark on your own hardware.