ID:               50351
 Comment by:       rlillack at yasni dot de
 Reported By:      rlillack at yasni dot de
 Status:           Verified
 Bug Type:         Scripting Engine problem
 Operating System: 64/32bit linux
 PHP Version:      5.3.1
 New Comment:

This seems to be related to the new cyclic garbage collector trying to

free memory after each allocation?!

A rather simple workaround is to insert gc_disable() before and
gc_enable() after entering the loop.


Previous Comments:
------------------------------------------------------------------------

[2009-12-01 13:38:56] j...@php.net

My results were done with i686..

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

[2009-12-01 13:37:27] j...@php.net

[j...@localhost ~]$ src/build/php_5_2/sapi/cli/php -n -d
memory_limit=2G t.php
time: 4.10 secs, memory usage 371.39 MiB.
[j...@localhost ~]$ src/build/php_5_3/sapi/cli/php -n -d
memory_limit=2G t.php
time: 25.97 secs, memory usage 383.46 MiB.


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

[2009-12-01 12:53:42] rlillack at yasni dot de

Description:
------------
PHP 5.3 did indeed introduce many performance improvements, but we 
spotted a rather hard regression with handling a large amount of 
objects that are allocated at the same time.

Running the following test case on one of our web servers yield this 
result with a vanilla build of 5.2.11:

time: 1.28 secs, memory usage 376.48 MiB.

and this with 5.3.1:

time: 13.44 secs, memory usage 400.62 MiB.

(command line in both cases: PREFIX/bin/php -d memory_limit=2G 
testcase.php)

The regression at least since the PHP 5.3 release candidates.

Both were fresh build straight from the tarball, No extensions, etc. 
Opcode caches do not help. --with-zend-vm does not help.


Reproduce code:
---------------
<?php
$start = microtime(TRUE);

$a = array();
foreach (range(1, 1000000) as $i) {
    $a []= new StdClass;
}

printf("time: %s secs, memory usage %s MiB.\n",
       number_format(microtime(TRUE) - $start, 2),
       number_format(memory_get_usage() / 1024 / 1024, 2));


Expected result:
----------------
PHP 5.3.1 should not be any slower than 5.2.11 is. :)

Actual result:
--------------
PHP 5.3.1 is ten times slower in this test case.

One of our apps does only handle 1/4th queries/s with 5.3 on a 
production server.


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


-- 
Edit this bug report at http://bugs.php.net/?id=50351&edit=1

Reply via email to