php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8945 include, require, et al.
Submitted: 2001-01-26 18:58 UTC Modified: 2001-03-20 04:44 UTC
From: Jason at hspace dot net Assigned:
Status: Closed Package: Performance problem
PHP Version: 4.0.4pl1 OS: Windows 2000
Private report: No CVE-ID: None
 [2001-01-26 18:58 UTC] Jason at hspace dot net
I discovered that the include(), require() or include_only(), require_only() functions have a profound effect on performance. I use conditional statements to conditionally require files, however, it seems that the PHP interpreter has a performance problem with this.
Commenting out all the require() or include() code shows that performance improved by 200%.
Web Stressing the app and PHP, I have found that PHP can sometimes crash with an Access Violation at 12345 and CPU usage maxing at 100%.
Memory leaks very much when CPU usage is at maximum threshold.
Zend Optimizer seems to reduce performance by a noticeable amount. It does not seem to reduce CPU usage, unfortunately.
I got the best performance from PHP using page cacheing. Results seem to show that it's faster than static HTML...

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-02-17 13:09 UTC] sbergmann@php.net
You say that you use conditional statements to determine whether or not to REQUIRE a file.

Just to make sure: You're not using require or require_once inside a conditional block, such as:

<?php
  if($condition)
  {
    require "some_file.php";
  }
?>

I'm asking this, because require and require_once are UNCONDITIONALY called, see the manual pages for require and include on this topic.

 [2001-03-16 17:00 UTC] sniper@php.net
No feedback.

--Jani

 [2001-03-16 17:29 UTC] Jason at hspace dot net
I tried both include() and require():

<?php
  if(false)
  {
    require "some_file.php";
  }
?>

and

<?php
  if(false)
  {
    include "some_file.php";
  }
?>

Both performed poorly, which is why I'm submitting this report.
At the moment, I've changed my code to use only require() without conditions, as require() is much faster than include().

Including one more file decreases performance by 2x.
Including another file decreases performance by another 2x.
eg: If you have 8 included files, the performance would be decreased by 256x. This is the performance drop that I'm pointing out here.


 [2001-03-20 03:24 UTC] sbergmann@php.net
I don't see your point.

Using require in a conditional block make absolutely NO SENSE, as it gets executed wheter or not the condition of the block holds true or not.

Of course the performance "decreases" when you load more files into your application: they need to be scanned, parsed and probably executed.

 [2001-03-20 04:23 UTC] Jason at hspace dot net
Never mind, I think that PHP can't handle parsing too many include files (Files too large/complex, more than 8 include files, not enough memory/CPU to handle PHP, whatever etc.)
 [2001-03-20 04:44 UTC] sbergmann@php.net
Works for me.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 06:01:29 2024 UTC