ID:               40970
 User updated by:  php at edwardk dot info
 Reported By:      php at edwardk dot info
 Status:           Bogus
 Bug Type:         Performance problem
 Operating System: Windows 2003
 PHP Version:      5.2.1
 New Comment:

I have new information, the slowness is present only when safe mode is
on.
(for 1000 iterations)
For PHP 4.4.6
-----
G:\>C:\php4\php.exe -n -d safe_mode=On filemtime.php
X-Powered-By: PHP/4.4.6
Content-type: text/plain

Took 7.451ms
G:\>C:\php4\php.exe -n -d safe_mode=Off filemtime.php
X-Powered-By: PHP/4.4.6
Content-type: text/plain

Took 0.152ms
G:\>



For PHP 5.2.1
-----
G:\>C:\php5\php-cgi.exe -n -d safe_mode=On filemtime.php
X-Powered-By: PHP/5.2.1
Content-type: text/plain

Took 12.172ms
G:\>C:\php5\php-cgi.exe -n -d safe_mode=Off filemtime.php
X-Powered-By: PHP/5.2.1
Content-type: text/plain

Took 0.108ms
G:\>


Additionally, I checked with FileMon, and the requests made are
different for each version (Safe mode On).

PHP 4.4.6
6:03:02.751 AM  php.exe:2344    OPEN    G:\     SUCCESS Options: Open Directory 
Access: 00100001        
6:03:02.751
AM      php.exe:2344    DIRECTORY       G:\     SUCCESS 
FileBothDirectoryInformation:
filemtime.php   
6:03:02.751 AM  php.exe:2344    CLOSE   G:\     SUCCESS         

PHP 5.2.1
6:03:04.158 AM  php-cgi.exe:2216        QUERY
INFORMATION     G:\filemtime.php        SUCCESS Attributes: A   
6:03:04.158 AM  php-cgi.exe:2216        OPEN    G:\     SUCCESS Options: Open
Directory  Access: 00100001     
6:03:04.158
AM      php-cgi.exe:2216        DIRECTORY       G:\     SUCCESS 
FileBothDirectoryInformation:
filemtime.php   
6:03:04.158 AM  php-cgi.exe:2216        CLOSE   G:\     SUCCESS         



note the additional "QUERY INFORMATION" access.


I've tried disabling safe mode and though performance has improved, it
is still slower than the PHP4 version on my script when run under an
apache module. The stats are now:

~40ms safe mode on (PHP5)
~15ms safe mode off (PHP5)

~5.5ms safe mode on (PHP4)
~0.7ms safe mode off (PHP4)


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

[2007-04-02 20:38:07] php at edwardk dot info

One thing I have noticed is that when the PHP5 version runs, Apache2's
kernel CPU time shoots up (measured in (Process Explorer) while
processing the request where as in PHP4, CPU use remains low.

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

[2007-04-02 20:32:03] php at edwardk dot info

Here's the new code:

<?
header('Content-type: text/plain');
function microtime_float()
{
    list($usec, $sec) = explode(" ", microtime());
    return ((float)$usec + (float)$sec);
}

$time_start = microtime_float();
$c = 0;
foreach (glob("*.torrent") as $filename) {
    $blah = stat($filename);
    $c++;
}
$time_end = microtime_float();
$time = $time_end - $time_start;
echo 'Took '.round(($time*100),3).'ms for '.$c.' files';
?>
and the results:
PHP 4.4.6
Took 5.232ms for 481 files
PHP 5.2.1
Took 107.762ms for 481 files

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

[2007-04-02 20:13:21] [EMAIL PROTECTED]

Might be related to stat cache usage... Try to see if you see the
difference stat'ing a set of files in random order, not the same file
repeatedly.

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

[2007-04-01 20:42:47] php at edwardk dot info

I have modified the code to use, $blah = stat('.htaccess');
This file does exist, it is 161 bytes on NTFS.

PHP 4.4.6: 1.641ms
PHP 5.1.2: 108.29ms

Normally, I would be using the commands on many small files (400ish) in
the current folder to determine if any of them had changed. This was
fast enough on PHP4, but on PHP5, the same code takes much longer.

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

[2007-04-01 14:44:02] [EMAIL PROTECTED]

This is only the case when stat() fails.

If you change stat('.'); to stat('<some file>'); you will se that PHP5
is faster than php4. Almost 2x.

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

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/40970

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

Reply via email to