php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26800 terrible performance doing array-index-access
Submitted: 2004-01-05 16:52 UTC Modified: 2004-01-11 17:48 UTC
From: eagle at shattered-reality dot de Assigned:
Status: Not a bug Package: Performance problem
PHP Version: 4.3.4 OS: WinNT4-SP6a
Private report: No CVE-ID: None
 [2004-01-05 16:52 UTC] eagle at shattered-reality dot de
Description:
------------
I encountered some serious performance problems on our server (2x 2.8 Xeon / 2gb ram / WinNT4-SP6) using scripts that had run very well on my small office workstation (Athlon 2400+ / 512gb ram / Win2k). 

I did some benchmarking (using scripts from http://www.sebastian-bergmann.de/PHP_Benchmark/ ) using cmdline php.exe on the server and found out that the "Array Index Access" test gives terrible results (around 10.000 accesses/s compared to around 745.000/s on my workstation). All other tests behaved as expected, so I don't think it is a configuration problem.

I tried different versions of php.ini (including php.ini-dist) and various versions of php itself (up to 5.0.0b1 / can't try 5.0.0b3 because of the getlongpathname bug). 
This beaviour started in 4.1.0 while everything runs fine under 4.0.6.

I don't have a second box with a similar setup, so I can't test other OS, but I have failed to reproduce this on any single-cpu system (Intel/Amd) running various OS (WinNT/Win2k/WinXP). 

Reproduce code:
---------------
$N = 1000000;
$table = array();
$start = getMicrotime();
for ($i = 0; $i < $N; $i++) {
    $table[$i] = $i;
}
for ($i = 0; $i < $N; $i++) {
    $i = $table[$i];
}
$end = getMicrotime();



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-06 17:46 UTC] sniper@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try avoid embedding huge scripts into the report.

The one provided gives parse error. (and yes, the script HAS to be self-contained)

 [2004-01-07 02:56 UTC] eagle at shattered-reality dot de
Sorry for just posting the abridgement of the script. Like mentioned above, the script can be found at http://www.sebastian-bergmann.de/PHP_Benchmark/

The script I used is at:
http://www.sebastian-bergmann.de/PHP_Benchmark/source/05_array_index_access.phps

the used include is at:
http://www.sebastian-bergmann.de/PHP_Benchmark/source/00_common.phps
 [2004-01-10 20:27 UTC] sniper@php.net
I guess your workstation is not running Windows NT..

 [2004-01-11 17:48 UTC] eagle at shattered-reality dot de
Yes - I already wrote that (it's running Win2k).

But I think it doesn't matter here. Fact is, that I should not get this kind of performance on any machine, regardless of the OS (If the problem was OS related, all other results would have been bad too, but they aren't).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Oct 08 09:01:27 2024 UTC