#28268 [Opn->Bgs]: Performance problem with require_once
| From: | derick@php.net | Date: | Tue, 04 May 2004 06:59:38 +0000 |
| Subject: | #28268 [Opn->Bgs]: Performance problem with require_once | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-59195@lists.php.net to get a copy of this message | ||
ID: 28268
Updated by: derick@php.net
Reported By: webmaster at gamedrome dot com
-Status: Open
+Status: Bogus
Bug Type: Performance problem
Operating System: Windows 2003
PHP Version: 4.3.6
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2004-05-04 02:36:33] 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 dont 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 doesnt 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.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=28268&edit=1