[php-src] Issue #19027: PHP CLI performance question: 8.1 vs 8.4

From: Date: Thu, 03 Jul 2025 18:07:17 +0000
Subject: [php-src] Issue #19027: PHP CLI performance question: 8.1 vs 8.4
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-250376@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/19027 Author: fcharrier ### Description Hello I have heard about performance issues when running PHP into containers. I wanted to check with a simple performance test. I use this code (from url) ```php <?php $startTime = time(); $runSeconds = 5; $rounds = 5; $count = 0; for ($i=0; $i<$rounds; $i++) { while ((time()-$startTime) <= $runSeconds) { serialize(['bar'=>'foo']); $count ++; } $round = $i+1; $startTime += $runSeconds; $count = number_format($count); echo "Round {$round}: {$count} /per {$runSeconds} second\n"; $count = 0; } ``` With this native version on my Ubuntu laptop I get this result: ``` PHP 8.1.32 (cli) (built: Mar 13 2025 18:27:13) (NTS) Copyright (c) The PHP Group Zend Engine v4.1.32, Copyright (c) Zend Technologies with Zend OPcache v8.1.32, Copyright (c), by Zend Technologies Round 1: 67,536,708 /per 5 second Round 2: 64,172,310 /per 5 second Round 3: 66,127,986 /per 5 second Round 4: 66,720,826 /per 5 second Round 5: 66,609,499 /per 5 second ``` When running the same code into docker images, I get different results... But finally I can see it doesn't come from docker, but from PHP version. If I switch to 8.4, I get less performance: ``` PHP 8.4.10 (cli) (built: Jul 3 2025 12:41:53) (NTS) Copyright (c) The PHP Group Built by Debian Zend Engine v4.4.10, Copyright (c) Zend Technologies with Zend OPcache v8.4.10, Copyright (c), by Zend Technologies Round 1: 45,043,192 /per 5 second Round 2: 51,002,689 /per 5 second Round 3: 51,224,938 /per 5 second Round 4: 51,226,778 /per 5 second Round 5: 51,235,970 /per 5 second ``` Is it something already known? I read some papers about PHP performance, and results are not the same: 8.4 version should be equals or better than the 8.1 one. Thanks ### PHP Version ```plain PHP 8.4.10 (cli) (built: Jul 3 2025 12:41:53) (NTS) Copyright (c) The PHP Group Built by Debian Zend Engine v4.4.10, Copyright (c) Zend Technologies with Zend OPcache v8.4.10, Copyright (c), by Zend Technologies ``` ### Operating System _No response_

« previous php.bugs (#250376) next »