Introducing

PHP 8.1 - Performance


We can't have a proper changelog without looking at performance and how it compares to previous versions. Right now though, there haven't been any proper benchmarks, I like Kinsta's benchmarks, they are in-depth and accurate, but we'll have to wait a little longer to see official results for PHP 8.1.

However, there are already quite a few things to mention.

Dmitry added inheritance cache, here's Dmitry explaining what it's about:

PHP classes are compiled and cached (by opcache) separately, however their "linking" was done at run-time - on each request. The process of "linking" may involve a number of compatibility checks and borrowing methods/properties/constants form parent and traits. This takes significant time, but the result is the same on each request.

Inheritance Cache performs "linking" for unique set of all the depending classes once and stores result in opcache shared memory.

I realise it's quite a technical explanation, but the results are very much measurable: Dmitry said he saw an 8% performance improvement on Symfony's "Hello World" app, I'd call that significant enough to mention!

On top of that, there's a change to how $GLOBALS is used, which also results in better performance for all array operations. Here's the RFC explaining this in detail.

Finally, there have also been some optimisations in PHP's timelib, resulting in another few percentage points being won on Symfony's demo app.

All in all, I'm looking forward to seeing official benchmarks being released for PHP 8.1, it seems like we can expect a noticeable performance difference for many projects!

While we're on the topic of performance, there's a new feature in PHP 8.1 that helps taking performance to the next level. That's for tomorrow. Until then!

Categories:
Tags:
PHP 8.1
PHP 8.1 Performance