Magento 2 Adobe Commerce PHP 8.2 JIT performance. How faster is Magento 2 with JIT?

Yegor Shytikov
3 min readJun 28, 2024

--

Let’s check M2 Adobe Commerce performance with PHP 8.2 JIt compilation.

Your php.ini file should contain the following directives:

zend_extension=opcache.so
opcache.enable=1
opcache.enable_cli=1
opcache.jit_buffer_size=500000000
opcache.jit=1235

Your opcache.ini should contain the following:

[opcache]
opcache.enable=1
; 0 means it will check on every request
; 0 is irrelevant if opcache.validate_timestamps=0 which is desirable in production
opcache.revalidate_freq=0
opcache.validate_timestamps=1
opcache.max_accelerated_files=10000
opcache.memory_consumption=192
opcache.max_wasted_percentage=10
opcache.interned_strings_buffer=16
opcache.fast_shutdown=1

This is a basic configuration that will work with any project.

Running the same magento heavy code with JIT and without

With JIT enabled

JIT Function

With JIT without

As we can see, there have been no changes. MAgento doesn't have any benefits from JIT compilation and the same fast.

For a little more than oneyear a few people reported segfaults in PHP when JIT is enabled. Until now the only clear solution to avoid those is to either entirely disable JIT, or at least configure it with the flag 1205 (or equivalent function).

The JIT author himself said that the current JIT version is buggy, hard to debug, and “often almost useless for real-life apps”. He also happens to be working on a new JIT version, so it seems unlikely he would have time to investigate complex bugs in the coming months.

So the current situation is that the default configuration of PHP is subject to segfault that are unlikely to be fixed quickly. The workaround around that is to simply configure PHP to not use JIT. There doesn’t seem to be any downside “for real-life apps”.

Laravel (8.4.4) and Symfony (demo 1.6.3, using 5.1.8 components) with their skeleton applications were tested on the same hardware in same scenarios as the previous benchmarks. Both applications were served by the built-in PHP web server, and benchmarked using Apache Bench (ab), with concurrency of 5, and 100 requests. Average of 5 tests.

Both applications did not receive a noticeable benefit, and in Laravel, the performance was ~2% worse with JIT, likely due to the compiling overhead that did not outweigh the efforts.

--

--

Yegor Shytikov
Yegor Shytikov

Written by Yegor Shytikov

True Stories about Magento 2. Melting down metal server infrastructure into cloud solutions.

Responses (1)