php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27215 include in php5 is very slow
Submitted: 2004-02-10 20:19 UTC Modified: 2004-06-11 09:07 UTC
Votes:34
Avg. Score:4.9 ± 0.4
Reproduced:30 of 30 (100.0%)
Same Version:19 (63.3%)
Same OS:6 (20.0%)
From: waboring at 3gstech dot com Assigned:
Status: Closed Package: Performance problem
PHP Version: 5CVS-2004-02-10 (dev) OS: Redhat 9
Private report: No CVE-ID: None
 [2004-02-10 20:19 UTC] waboring at 3gstech dot com
Description:
------------
I am the maintainer of phphtmllib.  I just got the latest php5 from cvs built and working, but have noticed a serious performance issue with just doing includes.

reproduce:
download phphtmllib from 
http://phphtmllib.newsblob.com/downloads/download.php?version=2.4.0
tar -zxvf phptmllib-2.4.0.tgz  into your favorite location

create a simple script that does nothing but include the library include file. "phphtmllib-2.4.0/include.inc" 

The execution of which takes over 1 second to complete.  

This script takes 0.075 to complete in php 4.3.2





Reproduce code:
---------------
<?php
$phphtmllib = "/location/where/you/installed/it";
include_once($phphtmlib."/includes.inc");
//Those 2 lines take over 1 second
?>

Expected result:
----------------
expected the simple include script to return in under .1 ms

Actual result:
--------------
The script took over 1 second to execute.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-02-11 14:00 UTC] waboring at 3gstech dot com
I'm not sure what else you want me to provide.  The bug is very clear.  There is a big performance issue with php5 just including a file with a class in it. php4 does not show this problem.


I have created a directory on my web server that shows the test code.
http://phphtmllib.newsblob.com/bug/index.php

This is running in an php4 environment and it takes 0.005s to execute the index.php code.

I don't have php5 running on this machine, as it is a production box.

You can look at the source code of the scripts by pointing to the following files.
http://phphtmllib.newsblob.com/bug/index.phps
http://phphtmllib.newsblob.com/bug/includes.phps
http://phphtmllib.newsblob.com/bug/ContainerClass.phps 
http://phphtmllib.newsblob.com/bug/XMLTagClass.phps
http://phphtmllib.newsblob.com/bug/HTMLTagClass.phps

When I run this on my machine (Pentium 4 1.8Ghz 512M ram)
php4: 0.005s
php5: 0.100s
 [2004-02-11 15:05 UTC] sniper@php.net
I have not noticed any performance problem with PHP 5, quite the opposite actually. Please provide information how you have configured PHP (what web server is used, are you running PHP5 as CGI or as a module, what configure line was used when compiling PHP, what possible extensions you load in php.ini if any, etc.) 

(isn't all this mentioned in the instructions about HOW to report???)

 [2004-03-23 17:06 UTC] waboring at 3gstech dot com
ok with further testing, I have trimmed my configure line down to the following.

./configure \
-with-apxs=/usr/local/apache/bin/apxs

I then restart apache.
First hit to the test script .097 s
Second hit .187 s
third .264 s
.332 s
.346 s
.392 s  (peaked out here)

In each test, I wait a few seconds to make sure there is no load on the machine.  I'm using a seperate machine to run the browser as to not polute the server response times.

The entire php script.

<?php
$_time = explode(" ",microtime());
$start = $_time[1] + $_time[0];

$phphtmllib = "phphtmllib";
include_once( $phphtmllib."/includes.inc");

$_time = explode(" ", microtime());
$stop = $_time[1] + $_time[0];
$elapsed = substr($stop - $start, 0, 5);
echo "<i>elapsed time: ".$elapsed." s </i><br>\n";
?>
 [2004-03-23 17:44 UTC] waboring at 3gstech dot com
Some more data points.  I used apache bench to run the test.php script in my last post.  I tested against php 4.3.2 and today's cvs php5.  Here are the results.

php4:
Server Software:        Apache/1.3.26
Server Hostname:        phphtmllib.hemna.corp.qualys.com
Server Port:            80

Document Path:          /test.php
Document Length:        34 bytes

Concurrency Level:      1
Time taken for tests:   9.748 seconds
Complete requests:      100
Failed requests:        0
Broken pipe errors:     0
Total transferred:      22900 bytes
HTML transferred:       3400 bytes
Requests per second:    10.26 [#/sec] (mean)
Time per request:       97.48 [ms] (mean)


php5:
Server Software:        Apache/1.3.26
Server Hostname:        phphtmllib.hemna.corp.qualys.com
Server Port:            80

Document Path:          /test.php
Document Length:        34 bytes

Concurrency Level:      1
Time taken for tests:   39.551 seconds
Complete requests:      100
Failed requests:        0
Broken pipe errors:     0
Total transferred:      24300 bytes
HTML transferred:       3400 bytes
Requests per second:    2.53 [#/sec] (mean)
Time per request:       395.51 [ms] (mean)
 [2004-04-23 09:03 UTC] hagen at xiag dot ch
The same thing on PHP5/Windows XP SP1.
I think there's nothing to add to the things said above.
PHP5 simply parses code too slow.

The bug is extremely easy to reproduce ? I?ve tried with different configurations and on different Apache/platform combinations ? but it still there.

You take any class put it to separate file then include it from another one and measure the time taken by include. The difference between php4 and php5 is up to 15-20 times.
 [2004-04-25 11:18 UTC] olivier dot bichler at laposte dot net
I have the same problem with the version : 5CVS-2004-04-24 (dev)
Includes are very slow...
 [2004-05-06 14:49 UTC] alexis dot butplease at nospam dot net
I installed PHP5RC1 on my WindowsXP so that I can have a look at my oo php4 app and see what I would have to change with PHP5.
Unfortunatly with this PHP5, my require_once() calls at the beginning of my scripts become by far the performance bottleneck. Where any page of the app used to take an average 0.2s it now takes about 1.5s, mostly due to require_once() calls.
I can't think of migrating because of this. Well, i'm sure it will all be fixed soon :)
Keep up the good work.
 [2004-05-25 12:47 UTC] shie@php.net
plz test again with latest CVS version. it should be a lot better now. my system (gentoo linux) shows much better performance, so i'd want some feedback.

btw: my system runs the script at about 0.74s (almost constant)

thanks!
 [2004-05-26 09:53 UTC] alexis dot butplease at nospam dot net
Thanks a lot Shie for this fix,

Unfortunatly, i can't test it on my regular PC since it's a XP without Visual Studio (and no cant dual boot here, it's not really my PC see). There's this old broken dinosaur in my basement at home. I'll try to repair it and install Linux to try your fix out. I'll post here my comments if i can make my old crap run again :)
Thanks again
 [2004-05-26 10:16 UTC] derick@php.net
No need to fiddle with compiling yourself, just grab a binary snapshot from http://snaps.php.net . Also, i've no clue to what Shie is referring as there were no changes regarding to this, nor did I notice any preformance problems at all with PHP 5.
 [2004-05-27 11:26 UTC] shie@php.net
derick:
i'm referring the commits by andi:
zend_alloc.h 1.50,1.51
zend_alloc.c 1.132
regarding memory leaks in mem cache.

i've tested phphtmllib myself (as described in the bug report), and on my system php5 did much worse than php4 (gentoo, apache 1.3.x). this commit makes it better though ;-)

 [2004-05-27 16:22 UTC] mikedransfield1 at hotmail dot com
I have also seen this error with a different application (sorry cant post examples)

On a page with heavy object use and multiple include_once statements, pages that took aroung 0.15 sec with php4 (with mmcache) were taking upto 2 seconds with php5-RC2 (with mmcache).

I have just checked out the latest cvs and there are indeed some speed improvements, now the page takes around 0.25 seconds in php5, this is without mmcache.
 [2004-05-28 00:15 UTC] shie@php.net
i think we're not quite done with that issue yet. the fix makes php5 perform much better, but not quite there yet. i'll keep working on this next week, using the phphtmllib as a case study. will keep you posted ...
 [2004-06-04 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2004-06-04 01:05 UTC] waboring at 3gstech dot com
the last comment said they weren't done fixing the issue yet.
 [2004-06-11 00:00 UTC] waboring at 3gstech dot com
It seems that the latest CVS (after 5.0.0RC3) is much better in includes.  It is still slightly slower then php4, but now back down to acceptable levels.

Doing an includes of phphtmllib's includes.inc takes .077s in php5 and .060 in php4 on a P4 1.8Ghz box.  

yes  .07 is still slow, but by default the library comes with everything included, which isn't necesarry.  It's a test case.  A minimal include set for using the lib is .03.  Much much better!  Thanks guys

I'd say this is fixed.
 [2004-06-11 09:07 UTC] derick@php.net
Closing then
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 19:01:29 2024 UTC