GitOps
Android 10 Features
Merge Data into a Single Table using Azure Data Factory
Healthcare Data Mining
Azure Communication Services
Cloud Cost Optimization
FHIR API using Azure
dynamics ax support
AI advances in healthcare
1 2 22

In 1995 programmer Rasmus Lerdorf announced the birth of PHP Tools. Since then, the PHP system has evolved into the one that drives nearly 80 percent of websites using server-side programming.

We, at WinWire, would like to take this opportunity to applaud and appreciate the PHP community that has been built over all these years. In 2015, a big step was taken when the community shifted from PHP 5.6 to PHP 7, which brought about many new features that resulted in improved performance, low memory consumption, improved exception hierarchy, and consistent 64-bit hierarchy name a few.

PHP 7 was a major release of PHP programming language and is touted to be a revolution in how web applications are developed and delivered for mobile to enterprises and the cloud. This release is the most significant change for PHP after the version of PHP 5 in 2004.

On its 25th birthday, the language will have an update later this year around November 2020, which we are all waiting for.

Features of PHP 8

The PHP 8 is expected to bring about the following new features:

  1. PHP JIT (Just in Time Compiler)
  2. PHP 8 Improvements and New Features

In the build up to the much-anticipated release of PHP 8 the JIT is getting a lot of attention. As JIT continues to be in the limelight let’s explore how it can be a game changer for PHP.

PHP JIT

JIT is already available in other languages like C#, Java etc. RFC Proposal on JIT states:

“PHP JIT is implemented as an almost independent part of OPcache. It may be enabled/disabled at PHP compile time and at run-time. When enabled, native code of PHP files is stored in an additional region of the OPcache shared memory and op_array→opcodes []. handler(s) keep pointers to the entry points of JIT-ed code.”

Before we understand the JIT PHP, let us talk about the how current PHP executes from source code to the result.

The PHP execution takes place in 4 stages:

  • Lexing/Tokenizing: The interpreter, reads the PHP code and builds a ser of tokens.
  • Parsing: The Interpreter checks if the script has followed all the syntax rules and uses the tokens to build an AST (Abstract Syntax Tree).
  • Compilation: The interpreter traverses the tree and translates AST nodes into low-level Zend opcodes, which are numeric identifiers determining the type of
  • Interpretation: Opcodes are interpreted and run on the Zend VM.

Basic PHP Execution Process

Php 8

OPCACHE

The OPCACHE was introduced, was available as a default from PHP5.5.  So, how does OPCACHE helps in improving PHP execution?

PHP is an interpreted language, means the interpreter parses, complies, and executes the PHP code over and over on each request which may results in wasting of CPU resources and is time consuming. To solve the above problem OPCACHE came in place.

“OPCACHE improves PHP performance by storing precompiled script bytecode in shared memory, thereby removing the need for PHP to load and parse scripts on each request.”

PHP Execution process with OPCACHE enabled is shown below.

PhP 8

 

How JIT can outperform OPCACHE?

Now let us see how JIT is expected to outperform than the OPCACHE.

When we are using OPCACHE, it still needs to be complied for machine code. Whereas JIT would not require any additional IR (Intermediate Representation) form. It would generate native code directly from the PHP byte code and information collected by SSA static analyses framework (a part of OPCACHE optimizer).

Conclusion

As based on earlier tests, JIT would make CPU-intensive workloads run significantly faster. Does it improve web applications? There might be slight improvements in web application performance, but it is also based on different factors like TTFB, database optimizations, HTTP requests, bandwidth, etc. We must wait for the release of PHP 8 to see how it performs in the live application. Over and above everything, PHP JIT looks promising and is expected to optimize the performance parameters for many metrics, wait for my next blog on PHP 8, in that I will be highlighting more on the improvements and new features.

Seshendra
Seshendra
SSDE