Forum Moderators: coopster

Message Too Old, No Replies

Is PHP 8.1 faster than 7.4?

         

AlanCC

3:46 am on Jul 3, 2023 (gmt 0)

10+ Year Member Top Contributors Of The Month



Hi,

I am using WordPress.

Based on many online posts, such as [wp-rocket.me...] and [kinsta.com...] benchmarks-2023, PHP 8.1 is much faster than 7.4

So I just swtich from PHP 7.4 to 8.1.

However, based on my test with following command:

ab -n 1000 -c 15 https://www.example.com/

Actuall PHP 8.1 is a bit slower. It takes 1.273 seconds to complete the test. While with 7.4, it only takes 1.146 seconds.

Also in WordPress, I install Query Monitor, and it repeatedly report "deprecated function" error, which may also slower the operation.

Why? Do I miss something or do something wrong?

Peter_S

9:18 pm on Jul 28, 2023 (gmt 0)

5+ Year Member Top Contributors Of The Month



it repeatedly report "deprecated function" error, which may also slower the operation.

You have your answer. Your PHP code includes lot of functions which are now depreciated, so each logging of these warning messages, is wasting time.

Are you using the latest version of Wordpress? (and its plugins/extensions).

AlanCC

1:40 am on Jul 29, 2023 (gmt 0)

10+ Year Member Top Contributors Of The Month



Yes, I am using the latest version of WordPress and plugins. However, some plugins are still use deprecated functions. Is it possible to prevent deprecated functions being logged?

tangor

3:27 am on Jul 29, 2023 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Turning off any of a log's functions kind of defeats the purpose of having a log in the first place. Time is better spent replacing outdated plugins.

Peter_S

1:11 pm on Jul 29, 2023 (gmt 0)

5+ Year Member Top Contributors Of The Month



Is it possible to prevent deprecated functions being logged?

Yes, but you don't want to do that. @tangor already explained.

"Deprecated", means the function still work NOW, but, in a near future will no long work AT ALL. So you do not want to have deprecated functions in the source code, tomorrow, next month, or next year, these functions will be removed, and instead of warnings, you will have error messages, breaking your site.

If some plugins are still using functions marked as deprecated, I would worry that such plugins are discontinued, or the dev very bad. In both case, I would stay away from such extensions.

AlanCC

3:09 pm on Jul 29, 2023 (gmt 0)

10+ Year Member Top Contributors Of The Month



OK. Thank you very much.

Senator94

5:58 pm on Aug 31, 2023 (gmt 0)



For my use case, PHP 8.1 is much faster on WordPress with all plugins updated to the latest release.

My dedicated server which is a beast AMD EPYC 128 GB RAM with LiteSpeed Enterprise Web Server and CyberPanel web manage, I use PHP 8.1 except for sites that use The Events Calendar plugin.

I also tried out PHP 8.1 with JIT enabled and I had a noticeable speed bump. Although, it came with a price of a lot of errors and eventually had to turn off JIT.

PHP needs to be tuned to with MariaDB to maximize performance. I use mySQL Tuner to optimize my performance. Also, I turn off Transparent HugePage to add a bit more speed.

AlanCC

3:15 am on Sep 1, 2023 (gmt 0)

10+ Year Member Top Contributors Of The Month



@Senator94 +

Thank you so much. I will check that.

TessCompton

9:54 am on Sep 14, 2023 (gmt 0)



Hey, I made a similar switch and noticed a small slowdown too. It might be due to specific plugins or configurations. Double-check your plugins for PHP 8.1 compatibility and consider profiling for more insights. 🤔