Bytecode VMs
debt(d5/e3/b3/t7)
Closest to 'specialist tool catches it' (d5). The detection_hints list opcache-gui and phpinfo — these are specialist diagnostic tools rather than default linters or compilers. Misconfigurations like OPcache disabled on production are not caught by syntax checking or standard linters; they require deliberate use of these specialist tools to identify.
Closest to 'simple parameterised fix' (e3). The quick_fix notes that enabling OPcache is the primary corrective action — a configuration-level change rather than a one-line code patch, but still contained within a single configuration file or php.ini setting. Understanding the VM model may require adjusting benchmark methodology or workload assumptions, which is slightly more than a single-line swap but well within one component.
Closest to 'localised tax' (b3). The concept applies to web and CLI contexts broadly, but its practical burden is mostly felt in performance tuning and benchmarking decisions rather than permeating every future maintainer's work. OPcache configuration is a one-time infrastructure concern; misunderstanding JIT expectations is a localised cognitive cost, not a structural weight across the entire codebase.
Closest to 'serious trap' (t7). The misconception field explicitly states that developers expect PHP's Zend Engine JIT to match JVM HotSpot performance, which contradicts reality due to 20+ years of JVM maturity and fundamentally different workload targets (long-running vs short-lived requests). This is a cross-ecosystem comparison trap — competent developers familiar with JVM or CLR will import wrong mental models into PHP, making it a serious trap that contradicts behaviour observed in similar concepts elsewhere.
Also Known As
TL;DR
Explanation
Bytecode VMs provide: portability (compile once, run on any OS with the VM), sandboxing (VM controls what bytecode can do), JIT optimisation opportunity (compile hot paths to native code based on runtime profiling). Zend Engine (PHP): stack-based VM, OPcache adds caching and optional JIT. JVM (Java, Kotlin, Scala): .class bytecode, HotSpot JIT with 20+ years of maturity, longer warm-up time. CLR (.NET): CIL bytecode, JIT via RyuJIT. Key difference: JVM and CLR were designed for JIT-heavy long-running servers; Zend Engine serves short-lived request processes where JIT warm-up is often not amortised.
Watch Out
Common Misconception
Why It Matters
Common Mistakes
- Expecting PHP JIT to match JVM HotSpot performance — different maturity levels and workload targets
- Not understanding that Zend opcodes are stack-based — variable accesses involve push/pop operations
- Thinking the VM prevents all malicious code — open_basedir and disable_functions restrict PHP capabilities
- Comparing benchmarks without controlling for workload type — I/O-bound vs CPU-bound gives completely different JIT results
Code Examples
// Expecting JVM-level JIT speedup from PHP JIT:
// PHP web app benchmark with JIT enabled:
// Without JIT: 1000 req/s
// With JIT: 1020 req/s (2% improvement — I/O bound app)
// Expected based on JVM knowledge: 2-5x improvement
// Reality: minimal for typical PHP web apps
// PHP JIT meaningful for CPU-bound long-running workers:
// Image resizing benchmark (CPU-intensive, long-running worker):
// Without JIT: 10 images/s
// With JIT (tracing mode): 14 images/s — 40% improvement
// Configure for long-running PHP workers where JIT warms up:
// php.ini:
// opcache.jit = tracing ; Best for loops
// opcache.jit_buffer_size = 128M ; JIT compiled code cache