Skip to main content

PHP JIT (Just-In-Time Compilation)

PHP JIT compiles frequently executed code paths into machine code at runtime. It is implemented through OPcache and can speed up CPU-bound workloads. Most WordPress performance problems are not CPU-bound (they're blocked on I/O, database work, network calls, and plugin/theme behavior), so JIT is usually not the first lever to pull.

Quick Summary
  • JIT can help CPU-heavy tasks.
  • Typical WordPress requests are often I/O-bound, so JIT usually provides small or no gains.
  • JIT consumes memory (JIT buffer) and can increase complexity; tune OPcache first.

Why JIT Usually Doesn't Help WordPress

For typical WordPress requests, the slow parts are often:

  • Database queries and serialization work
  • External network calls (APIs, payment gateways, analytics)
  • File I/O and template rendering
  • JavaScript and front-end work (for INP)

OPcache already removes most of the "PHP compilation" overhead. If you still have slow dynamic requests after OPcache is tuned, the next bottleneck is usually application/database behavior rather than the interpreter.

When JIT Can Help

JIT can be useful when PHP spends a lot of time in tight loops doing computation, for example:

  • CLI-heavy tooling (static analysis, code generation)
  • Large imports/exports and data processing tasks
  • Custom scripts doing heavy computation

If You Want to Test JIT

Start with a small buffer and measure. Do not allocate large amounts of RAM to JIT on small servers.

Example configuration:

php.ini
[opcache]
opcache.enable=1
opcache.enable_cli=1

; Start small and measure
opcache.jit_buffer_size=64M

; Common choice for JIT mode
opcache.jit=tracing
caution

JIT settings can differ between CLI and PHP-FPM/LSAPI. A configuration that helps a CLI import script may do nothing for your web requests.

Validating Tracing Triggers

Force the server terminal dynamically to expose exactly if the JIT routines actively ingested safely locally.

validate-jit-triggers.sh
php -i | grep -i "jit"

Expected Safe Output Array:

terminal-output.txt
JIT => On
JIT triggers => ZEND_JIT_PROFILE_REQUEST
JIT buffer size => 50M

Common Mistakes & Troubleshooting

Configuration FailureOperational SymptomRemediation Protocol
Debugging/profiling issuesBreakpoints behave oddly when Xdebug is enabled.Disable JIT when debugging or profiling if you see instability.
Memory pressureRedis/DB/PHP compete for RAM and the server becomes unstable.Reduce jit_buffer_size (or disable JIT) and prioritize OPcache + caching layers.

What's Next