Search Postgresql Archives

Re: high %system time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 06 Jun 2006 09:37:16 -0400
Jacob Coby <jcoby@xxxxxxxxxxxxxxx> wrote:

> Bill Moran wrote:
>
> > 2) require_once() and include_once() are truly evil.
> 
> Can you elaborate a bit on this?  Privately if you want since it's off 
> topic for this list.

They're evil.  They are a bad idea gone horribly awry.

Here are some specific reason why they should never be used and should
be removed from the language:
1) They encourage sloppy coding.  If hackers are using *_once() it means
   they don't know their inclusion hierarchy.
2) They incur lots of system time by stat()ing lots of directories and
   files for everything you include.
3) If you have the same file included multiple times, it still runs the
   stat()s _every_time_, even if the file has already been included and
   doesn't need included again.  I believe this is necessary for security
   purposes, but it's a LOT of overhead.

After determining that require_once() was requiring significant amounts
of CPU for our application, we tasked a single developer to organize and
replace them all with require().  It took him an hour or two.  The result
was about a 2x performance boost, with significant reduction in system
time.  It was a big enough jump that the bottleneck relocated to another
location and I haven't been back to optimizing PHP since.

In conclusion, (require|include)_once() are evil.  The only time they
should be used is when the application is so small that it doesn't need
them.

-- 
Bill Moran
Collaborative Fusion Inc.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux