PHP Classes

How to Get PHP Performance Optimization Using the New PHP JIT-ir Proposed for Future PHP Versions

Recommend this page to a friend!
  Blog PHP Classes blog   RSS 1.0 feed RSS 2.0 feed   Blog How to Get PHP Perfor...   Post a comment Post a comment   See comments See comments (0)   Trackbacks (0)  

Author:

Categories: PHP Tutorials, PHP User Groups, News

PHP is continuing to improve version after version. A recent proposal to improve the PHP performance further was just accepted by the PHP core developers group.

This proposal, called JIT-ir, aims to implement a new JIT engine (Just in Time compilation engine) that will replace the current PHP 8.x JIT engine.

Read this article to learn more about what is this new JIT engine and how your PHP code will benefit from this improvement when it is made available in future PHP versions.




Loaded Article

In this article you can learn about:

1. What is the PHP JIT Engine

2. What is the PHP JIT-ir Proposal

3. How PHP Developers Can Benefit from the PHP JIT-ir Engine

4. When the PHP JIT-ir Engine Will Be Available


1. What is the PHP JIT Engine

JIT means Just In Time. A JIT compilation engine is a part of a language runtime engine that compiles the language code into code in a lower-level language code. This lower-level language code will be executed faster than if the machine interprets the language code.

A PHP JIT engine will compile PHP Opcodes into native code that can be executed faster by the CPU that is in the computer that you use to run PHP.

PHP Opcodes results from the compilation of PHP source code into a set of instructions that represent that PHP code in a lower-level language.

Before PHP 8, the PHP runtime engine would compile PHP source code into PHP (Zend) opcodes. Then, the opcodes would be interpreted and executed to run the PHP code.

PHP 8 introduced a JIT engine that can compile PHP opcodes into native code. It uses DynAsm (developed for the LuaJIT project) to do the opcode-to-native code compilation. PHP core developers approved its proposal in March 2019. PHP 8.0, with the first built-in JIT engine, was released in November 2020.

2. What is the PHP JIT-ir Proposal

JIT-ir is the name of a new proposal that PHP core developers accepted in October 2023 to provide a new JIT implementation for a future PHP version.

Dmitry Stogov developed this new JIT engine, and he already provided a patch to the core PHP code to start testing this new JIT engine.

Dmitry expects that it provides between 5% and 10% of performance improvement to PHP code. It will also produce compiled code that will take less memory.

Dmitry provided a nice presentation about the PHP IR JIT framework that you can view to understand better how this improvement to PHP JIT will work.

3. How PHP Developers Can Benefit from the PHP JIT-ir Engine

Currently, this improvement was submitted as a patch to improve the opcache extension. If you are capable of building PHP from source code, you can try this patch now.

Otherwise you may need to wait for the next stable PHP release to benefit from this new PHP JIT engine.

4. When the PHP JIT-ir Engine Will Be Available

Right now there is no specific PHP stable version or release date that will include this PHP JIT improvement will be available.

What I can do is to make an educated guess that this improvement will be made available in the next stable PHP release that is open to improvements.

PHP 8.3 feature list is frozen. So this improvement can be made available in PHP 8.4 or PHP 9.0.

If the PHP core developers continue to follow the same release pattern of launching one stable PHP release every year, PHP 8.4 can be launched around November and December of 2024. Still, this is guess that may be right or wrong as it depends on decisions of the PHP core developers.




You need to be a registered user or login to post a comment

Login Immediately with your account on:



Comments:

No comments were submitted yet.



  Blog PHP Classes blog   RSS 1.0 feed RSS 2.0 feed   Blog How to Get PHP Perfor...   Post a comment Post a comment   See comments See comments (0)   Trackbacks (0)