From:             borreo at softhome dot net
Operating system: Windows 2000
PHP version:      5.0.0
PHP Bug Type:     Performance problem
Bug description:  Stat much slower on network files in PHP5

Description:
------------
Not really a bug, the code works.
The stat function, if used on a network file, is much slower in PHP5 than
in PHP 4.3.7.
On my system, PHP 5.0 takes 20 seconds to stat 1000 files.
With PHP 4.3.7, this takes 2 seconds.
If I use a local directory (e.g. C:\work) rather than a network drive,
then there is no visible difference in performance between PHP 4.3.7 and
PHP 5.

In order to produce accurate tests, I installed both version of PHP on the
same machine, in different directories, using a common php.ini

Reproduce code:
---------------
// I: points to a network drive
chdir( 'I:/work' ) ;
$ListOfFiles = rglob( ".", "*" ) ;
$StartTime = time() ;
foreach( $ListOfFiles as $i )
        stat( $i ) ;
$ElapsedTime = time() - $StartTime ;
die( "Seconds=$ElapsedTime\n" );

// Recursive version of glob
function rglob( $Dir, $Pattern )
        {
        $Files = glob( "$Dir/$Pattern", 0 ) ;

        $Directories = glob( "$Dir/*", GLOB_ONLYDIR ) ;
        if ( is_array( $Directories ) )
                {
                foreach( $Directories as $SubDir )
                        {
                        $SubFiles = rglob( $SubDir, $Pattern ) ;
                        if ( is_array( $SubFiles ) )
                                $Files = array_merge( $Files, $SubFiles ) ;
                        }
                }

        return $Files;
        }


Actual result:
--------------
With PHP 5.0:   Seconds=20
With PHP 4.3.7: Seconds=2

If I change the current directory to a local dir (e.g. C:\work) then there
is no difference between PHP 4.3.7 and PHP 5.0:

With PHP 5.0:   Seconds=2
With PHP 4.3.7: Seconds=2


-- 
Edit bug report at http://bugs.php.net/?id=29255&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=29255&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=29255&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=29255&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=29255&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=29255&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=29255&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=29255&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=29255&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=29255&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=29255&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=29255&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=29255&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29255&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=29255&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=29255&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=29255&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29255&r=float

Reply via email to