From:             wf at bitplan dot com
Operating system: Windows XP
PHP version:      5.0.0RC1
PHP Bug Type:     Reproducible crash
Bug description:  Long list of require_once first slows down PHP than crashes Apache

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 ...

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

Reply via email to