PHP 8.3 Performance Tweaks
PHP 8.3 brings several performance improvements out of the box, but with a few configuration tweaks you can squeeze even more out of your application. Here are the adjustments we’ve applied on our production servers at Web Prague.
1. JIT Compiler Tuning
The JIT compiler in PHP 8.3 is more stable. Enable it in your php.ini:
opcache.jit = tracing
opcache.jit_buffer_size = 256M
opcache.jit_max_trace_length = 256
For heavy CPU‑bound tasks, try function‑specific profiling.
2. OPCache File Cache
Use the file cache to pre‑warm opcache after deployment:
opcache.file_cache = /tmp/opcache
opcache.file_cache_only = 0
Remember to clear it when you update code.
3. Lazy Objects and Weak Maps
PHP 8.3’s LazyObject and WeakMap reduce memory overhead for heavy ORMs. Example:
$mapper = new WeakMap();
$mapper[$entity] = $data;
4. Fiber Stack Size
If you use Fibers (e.g., with Revolt or Amp), adjust the default stack:
Fiber::DEFAULT_STACK_SIZE = 2 * 1024 * 1024;
We’ve seen up to 15% lower latency after applying these. Your mileage may vary.
— The Web Prague team