From:             webmaster at gamedrome dot com
Operating system: Windows 2003
PHP version:      4.3.6
PHP Bug Type:     Performance problem
Bug description:  Performance problem with require_once

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.

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

Reply via email to