php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29255 Stat much slower on network files in PHP5
Submitted: 2004-07-19 12:03 UTC Modified: 2005-02-17 13:03 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: borreo at softhome dot net Assigned:
Status: Closed Package: Performance problem
PHP Version: 5.0.0 OS: Windows 2000
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: borreo at softhome dot net
New email:
PHP Version: OS:

 

 [2004-07-19 12:03 UTC] borreo at softhome dot net
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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-19 15:15 UTC] borreo at softhome dot net
Disabling allow_url_fopen doesn't change a thing.
 [2005-02-17 12:03 UTC] borreo at softhome dot net
I confirm that the problem is still present both in 5.0.2 and in latest CVS (today)
 [2005-02-17 12:59 UTC] borreo at softhome dot net
No, sorry.
The problem IS NOT present in PHP 5.0.2, nor in the latest CVS.
 [2005-02-17 13:03 UTC] borreo at softhome dot net
Corrected in 5.0.2
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 09:01:28 2024 UTC