#40261 [NEW]: Extremely slow data handling in specific situation
From: thuejk at gmail dot com
Operating system: Linux
PHP version: 5.2.0
PHP Bug Type: Performance problem
Bug description: Extremely slow data handling in specific situation
Description:
------------
I have some code which produces unacceptible performance in a specific
situation. Making a completely trivial change improves performance a
hundred-fold or more.
The problem is 100% reproducible.
The code looks something like:
/* pseudocode*/
function get_data_from_pgsql(){
...
$map = Array();
foreach ($rows as $row) {
$map = row[index];
}
return $map;
}
$data1 = get_data_from_pgsql
$data2 = get_data_from_pgsql
One run with 10000 rows of result took 8.77 seconds, which is clearly
silly. Making the extremely trivial change of moving the code block
foreach ($rows as $row) {
$map = row[index];
}
out of the function get_data_from_pgsql(), the code suddently only takes
0.1 seconds to run (factor 90)! Having more rows in the result makes the
factor difference larger; it seems to increase quadratically.
Not saving the return values in $data1 and $data2 also improves
performance immensely.
PHP 5.1.5 did not have this problem (or at least it was much smaller).
Reproduce code:
---------------
http://thuejk.dk/test.php.txt
You need a running postgresql database with one table, which has at least
10000 entries.
change the line
$translate_outside_function = false;
at the top of the file to see the difference mentioned above.
--
Edit bug report at http://bugs.php.net/?id=40261&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40261&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40261&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40261&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=40261&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=40261&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=40261&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=40261&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=40261&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=40261&r=support
Expected behavior: http://bugs.php.net/fix.php?id=40261&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=40261&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=40261&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=40261&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40261&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=40261&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=40261&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=40261&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=40261&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=40261&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=40261&r=mysqlcfg
Thread (18 messages)
- thuejk at gmail dot com
- tony2001@php.net#40261 [Opn->Fbk]: Extremely slow data handling in specific situation
- thuejk at gmail dot com#40261 [Fbk->Opn]: Extremely slow data handling in specific situation
- tony2001@php.net#40261 [Opn->Fbk]: Extremely slow data handling in specific situation
- thuejk at gmail dot com#40261 [Fbk->Opn]: Extremely slow data handling in specific situation
- thuejk at gmail dot com#40261 [Opn]: Extremely slow data handling in specific situation
- thuejk at gmail dot com#40261 [Opn]: Extremely slow data handling due to memory fragmentation
- thuejk at gmail dot com#40261 [Opn]: Extremely slow data handling due to memory fragmentation
- tony2001@php.net#40261 [Opn->Asn]: Extremely slow data handling due to memory fragmentation
- dmitry@php.net#40261 [Asn->Fbk]: Extremely slow data handling due to memory fragmentation
- thuejk at gmail dot com#40261 [Fbk->Opn]: Extremely slow data handling due to memory fragmentation
- tony2001@php.net#40261 [Opn->Asn]: Extremely slow data handling due to memory fragmentation
- thuejk at gmail dot com#40261 [Asn]: Extremely slow data handling due to memory fragmentation
- bloire at citytoo dot com#40261 [Com]: Extremely slow data handling due to memory fragmentation
- bloire at citytoo dot com#40261 [Com]: Extremely slow data handling due to memory fragmentation
- bloire at citytoo dot com#40261 [Com]: Extremely slow data handling due to memory fragmentation
- dmitry@php.net#40261 [Asn->Csd]: Extremely slow data handling due to memory fragmentation
- thuejk at gmail dot com#40261 [Csd]: Extremely slow data handling due to memory fragmentation