Re: high %system time - Mailing list pgsql-general

From Bill Moran
Subject Re: high %system time
Date
Msg-id 20060606095452.a59c50ab.wmoran@collaborativefusion.com
Whole thread Raw
In response to Re: high %system time  (Jacob Coby <jcoby@listingbook.com>)
List pgsql-general
On Tue, 06 Jun 2006 09:37:16 -0400
Jacob Coby <jcoby@listingbook.com> 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.

pgsql-general by date:

Previous
From: Jacob Coby
Date:
Subject: Re: high %system time
Next
From: Tom Lane
Date:
Subject: Re: 7.3.3, Fedora Core 5, test geometry and test horology