php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28268 Performance problem with require_once
Submitted: 2004-05-04 02:36 UTC Modified: 2004-05-04 08:59 UTC
From: webmaster at gamedrome dot com Assigned:
Status: Not a bug Package: Performance problem
PHP Version: 4.3.6 OS: Windows 2003
Private report: No CVE-ID: None
 [2004-05-04 02:36 UTC] webmaster at gamedrome dot com
Description:
------------
See http://www.gamedrome.com/ and view the source of the HTML. You will notice the last line:
<!-- SecondBuilder info: page generation time: 0.084 secs. 87% of page is cached content, no parts generated during creation. -->

0.084 seconds is the time it took to generate the page. I'm using a content cache system based similar as Story Server (known as Vignette v6) written in PHP.

Anyway, the problem also occurs with early versions of PHP too. At some point, depending of the number of hits we have on the site, the parsing time of a page goes up from around 0.070 to 0.500/1.000 secs for NO apparent reason. Almost 10 times it is normal. The only way I can fix this is by rebooting the server (windows 2003). I've tried restarting apache(2.0.18) etc.

The performance goes down not of the parsing of code, but the time it takes to include files. I have written these PHP code to do some speed tests:

<?
function lib_miscMicroTime2Float($timestr)
{
	list($usec, $sec) = explode(" ",$timestr); 
	return ((float)$usec + (float)$sec); 
}

	$glbl["parse_started"] = microtime();

	$x = 100;
	while($x--)
	{
		$filename = "C:\webroot\development\www\images\partners\epox\epox.jpg";
		$handle = fopen($filename, "r");
		$contents = fread($handle, filesize($filename));
		fclose($handle);
	}

	printf("%.3f<br>\n", lib_miscMicroTime2Float(microtime()) - lib_miscMicroTime2Float($glbl["parse_started"])) . " secs";

	$glbl["parse_started"] = microtime();

	require_once($_SERVER["DOCUMENT_ROOT"] . "/admin/modules/system/sb_log/LibrarySite.php");
	require_once($_SERVER["DOCUMENT_ROOT"] . "/admin/modules/system/sb_cache/LibrarySite.php"); 
	require_once($_SERVER["DOCUMENT_ROOT"] . "/admin/modules/system/sb_adminmodule/LibrarySite.php");
	require_once($_SERVER["DOCUMENT_ROOT"] . "/admin/modules/system/sb_adminsession/LibrarySite.php");
	require_once($_SERVER["DOCUMENT_ROOT"] . "/admin/modules/ws_languagetext/LibrarySite.php");
	require_once($_SERVER["DOCUMENT_ROOT"] . "/admin/modules/ws_membersession/LibrarySite.php");

	printf("%.3f\n", lib_miscMicroTime2Float(microtime()) - lib_miscMicroTime2Float($glbl["parse_started"])) . " secs";

?>

(you can find the output of this code here: http://www.gamedrome.com/speedtest.php)


The first part of the freads an image of around 400k, 100 times. The second part uses require_once on the libraries I use for my website. These files don?t produce output and only contain functions used for the website.

During normal operations the times for the first part is between 0.120-0130 secs. The second part has times of 0.007, to require_once the files.

If the performances 'bug' occurs, the times are much higher for the ?require_once? code than for the fread.
First part (the fread) is between 0.135 ? 0.152 and the ?require_once? code is much higher: 0.058 ? 0.070.

My conclusion is that there must be some bug in ?require_once? code, because loading a file doesn?t slow down as much (about 10%), while the ?require_once? increase 800% in time. I've exclude my code or mysql because in the speed test I only use PHP you see and the files include do not produce any output.

To exclude the parsing of the included files, I'll create a test with fread to read the include and use eval to test the speed.

I'm using Windows 2003 web edition, Apache 2.0.48 and PHP as FASTCGI.

Reproduce code:
---------------
Sorry can't reproduce... Just happens after a while..

Expected result:
----------------
none

Actual result:
--------------
Told you everything in the description.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-05-04 08:59 UTC] derick@php.net
This bugreport is quite useles, no information on how to reproduce. Stick with apache1 + mod_apache and preferrably a unix OS. Marking Bogus unless you can provide us with info on how to reproduce realiably.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 19:01:30 2024 UTC