php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70613 PHP7 degraded performance
Submitted: 2015-10-01 14:53 UTC Modified: 2015-10-19 18:31 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: daniel at theenginuity dot com Assigned:
Status: Not a bug Package: Performance problem
PHP Version: 7.0.0RC4 OS: Ubuntu 14.04 x86_64
Private report: No CVE-ID: None
 [2015-10-01 14:53 UTC] daniel at theenginuity dot com
Description:
------------
I am observing degraded performance when comparing, PHP 5.6.13 vs 7.0 RC3 in a test environment.

The only variable changed between tests was the version of PHP, all other OS and server configs kept constant including FPM pool. Both KVMs on the same private subnet running on an idle dedicated hardware host.

Test Server: 

KVM 1vCPU 1GB RAM 10GB SSD Ubuntu 14.04 x64 
Apache 2.4 + PHP-FPM

Test Client: 

KVM 1vCPU 1GB RAM 10GB SSD Ubuntu 14.04 x64

Test: ab -n 20000 -c 20 http://example.com (executed test 3 times)

** Notes **
PHP 5.6.13 OPCACHE Settings

opcache.revalidate_freq=60
opcache.validate_timestamps=0
opcache.max_accelerated_files=500
opcache.memory_consumption=64
opcache.interned_strings_buffer=16
opcache.fast_shutdown=1

PHP-FPM Settings

listen = 127.0.0.1:9000
pm = static
pm.max_children = 20

Apache 2.4 MPM Prefork Settings

KeepAlive Off
StartServers            20
MinSpareServers         20
MaxSpareServers         20
MaxRequestWorkers       20
MaxConnectionsPerChild  1000


Test script:
---------------
<?php

function HelloWorld() {
        return 'Hello World!';
}

?>
<html>
 <head>
  <title>PHP Test</title>
 </head>
 <body>
 <?php echo HelloWorld(); ?>
 </body>
</html>


Expected result:
----------------
PHP 7.0 RC3 Requests per second >= PHP 5.6.13

PHP 7.0 RC3 Memory Usage <= PHP 5.6.13



Actual result:
--------------
PHP 5.6.13 Average Memory Usage (Start of Test) = 35.3 MB
PHP 5.6.13 Average Memory Usage (End of Test) = 38 MB
PHP 5.6.13 Request Per Second (3 Test Runs) = 1314, 1316, 1315

PHP 7.0 RC3 Average Memory Usage (Start of Test) = 9.6 MB
PHP 7.0 RC3 Average Memory Usage (End of Test) = 17.4 MB
PHP 7.0 RC3 Request Per Second (3 Test Runs) = 1065, 1151, 1102

--------------------------------------------------------------------------

PHP 7.0 RC3 appears to use significantly less memory usage but is slower at requests per seconds compared to PHP 5.6.13







Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-10-01 18:00 UTC] rasmus@php.net
Initial guess would be that your opcache is not working/enabled in your PHP 7 setup. Check your phpinfo() page.
 [2015-10-02 04:49 UTC] daniel at theenginuity dot com
Re-verified Opcache settings in PHP 7.0 RC3, fixed missing opcache.revalidate_freq, all other settings set to same values as posted.

Request per second for PHP 7.0 = 1245, 1204, 1211
 [2015-10-02 11:37 UTC] kalle@php.net
Have you tried out RC4? (PHP version says RC4 in the bug report, but comments state RC3, so just wondering)
 [2015-10-02 13:51 UTC] daniel at theenginuity dot com
-PHP Version: 7.0.0RC4 +PHP Version: 7.0.0RC3
 [2015-10-02 13:51 UTC] daniel at theenginuity dot com
Updated bug to RC3, will compile RC4 and will verify if any changes are observed in performance. I can help debug this further if anyone would like more detailed information?
 [2015-10-13 15:40 UTC] daniel at theenginuity dot com
-PHP Version: 7.0.0RC3 +PHP Version: 7.0.0RC4
 [2015-10-13 15:40 UTC] daniel at theenginuity dot com
Executed new performance tests with latest versions of PHP and observed the following results:

PHP 5.6.14 Average Memory Usage (Start of Test) = 33.9 MB
PHP 5.6.14 Average Memory Usage (End of Test) = 36.3 MB
PHP 5.6.14 Request Per Second (3 Test Runs) = 1043, 1039, 1034

PHP 7.0 RC3 Average Memory Usage (Start of Test) = 9.6 MB
PHP 7.0 RC3 Average Memory Usage (End of Test) = 17.1 MB
PHP 7.0 RC3 Request Per Second (3 Test Runs) = 959, 904, 939

PHP 7.0 RC4 Average Memory Usage (Start of Test) = 9.4 MB
PHP 7.0 RC4 Average Memory Usage (End of Test) = 17.0 MB
PHP 7.0 RC4 Request Per Second (3 Test Runs) = 971, 974, 974
 [2015-10-13 16:10 UTC] rasmus@php.net
I am not sure why you care about the performance of a trivial script like that. Install a real app and test. If you still see a performance problem with something real, let us know.
 [2015-10-15 16:29 UTC] daniel at theenginuity dot com
I started with a real-world application but wanted to isolate it down to a simple script that would help with reproducing the results.

I have conducted more performance tests, this time using a standard install of Wordpress 4.3.1

Results:

PHP 5.6.14 Average Memory Usage (Start of Test) = 33.9 MB
PHP 5.6.14 Average Memory Usage (End of Test) = 152.3 MB
PHP 5.6.14 Request Per Second (3 Test Runs) = 13.93, 13.87, 13.84

PHP 7.0 RC4 Average Memory Usage (Start of Test) = 9.4 MB
PHP 7.0 RC4 Average Memory Usage (End of Test) = 321.0 MB
PHP 7.0 RC4 Request Per Second (3 Test Runs) = 7.06, 7.22, 7.21
 [2015-10-15 20:21 UTC] rasmus@php.net
Ok, so there is something whacky about your environment since dozens of other people have tested Wordpress and are not seeing this slowdown at all. Quite the opposite in fact.

You will need to dig in and figure out where the slowdown is happening. Try using perf. It is described here: https://perf.wiki.kernel.org/index.php/Main_Page
 [2015-10-19 16:46 UTC] daniel at theenginuity dot com
-Status: Open +Status: Closed
 [2015-10-19 16:46 UTC] daniel at theenginuity dot com
I discovered my error in the opcache as suggested by rasmus and have executed a new set of performance tests with the standard install of Wordpress 4.3.1

Closing this ticket since PHP7 RC4 is significantly faster. Thank you.

Results:

PHP 5.6.14 Average Memory Usage (Start of Test) = 33.9 MB
PHP 5.6.14 Average Memory Usage (End of Test) = 152.3 MB
PHP 5.6.14 Request Per Second (3 Test Runs) = 13.93, 13.87, 13.84

PHP 7.0 RC4 Average Memory Usage (Start of Test) = 9.4 MB
PHP 7.0 RC4 Average Memory Usage (End of Test) = 108.0 MB
PHP 7.0 RC4 Request Per Second (3 Test Runs) = 28.72, 30.22, 30.01
 [2015-10-19 18:31 UTC] rasmus@php.net
-Status: Closed +Status: Not a bug
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 15:01:29 2024 UTC