php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27761 Long list of require_once first slows down PHP than crashes Apache
Submitted: 2004-03-29 17:02 UTC Modified: 2004-04-21 00:15 UTC
Votes:2
Avg. Score:3.0 ± 0.0
Reproduced:1 of 2 (50.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: wf at bitplan dot com Assigned:
Status: No Feedback Package: Reproducible crash
PHP Version: 5.0.0RC1 OS: Windows XP
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: wf at bitplan dot com
New email:
PHP Version: OS:

 

 [2004-03-29 17:02 UTC] wf at bitplan dot com
Description:
------------
With the script below I generated some 200 PHP classes.
The profiling result for loading all these classes with some 25.000 lines of code is:

start:00:04:50.999346
stop :00:04:51.432091

The loading takes some 432 Milliseconds that ok for so many classes.

Doing the same with 60 classes in real code environment takes
from 3 to 25 secs before Apache crashes ...


awk '
BEGIN {
	for (i=1;i<200;i++) {
		class=sprintf("class%03d",i);
		fname=class".php";
		print "<?php"  >  fname
		printf("class %s {\n",class) >>fname
		printf("  public $somevar;\n") >> fname
		for (j=1;j<60;j++) {
		printf("  public function somefunction"j"() {\n") >> fname
		printf("  }\n") >>fname
		}
		printf("} // %s\n",class) >>fname
		print "?>" >> fname
		close(fname);
	}
	fname="test.php";
	print "<?php"  >  fname
	print "include(\"profile.php\");" >> fname
	print "profile(\"start\");" >> fname	
	for (i=1;i<200;i++) {
		class=sprintf("class%03d",i);
		classfname=class".php";
		printf("require_once(\"%s\");\n",classfname) >> fname
	}
	print "displayProfile();" >> fname	
	print "?>" >> fname
	close(fname);	
}
'

profile.php has the following content:
<?php

/**
 * get a Timestamp in string format
 */
function getTimestamp() {
	$_time = gettimeofday();
  return strftime("%X.", time()).$_time["usec"];
} 

/**
 * profile a given step
 * @param the stepname
 */
function profile($step) {
	global $profile_times;
	$profile_times[$step]=getTimestamp();
}

/**
 * display the profile
 */
function displayProfile() {
	profile("stop");
	echo "<BR>";	
	global $profile_times;
	foreach ($profile_times as $_step=>$_time) {
		echo $_step.":".$_time."<BR>";
	} // foreach
} // displayProfile		
?>

Reproduce code:
---------------
It said: 
Please do not post more than 20 lines of source code.
If the code is longer then 20 lines, provide an URL to the source code that will reproduce the bug.

Sorry - If I'd provide the URL I'd have to provide a server that may crash any time.
A Zip File with the code can be made available by us
XPath.Class.php loading took up to 1.9 secs in our enviroment alone when using the __Autoload feature:

be/estro/genepi/classUserManager.php:23:42:12.556828
  com/bitplan/common/XPath.class.php:23:42:14.405958

Expected result:
----------------
Performance should be acceptable that is class loading should take less than 300 millisecs. 

Actual result:
--------------
Loading of a single class with 5600 lines of code takes 1.9 secs:
be/estro/genepi/classSession.php:23:42:12.422696
be/estro/genepi/classUserManager.php:23:42:12.556828 (250 lines of code take approx 130 Millisecs ...)
  com/bitplan/common/XPath.class.php:23:42:14.405958
5600 lines take 1.9 secs ...

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-13 13:04 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip


 [2004-04-21 00:15 UTC] iliaa@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 12 23:01:30 2024 UTC