Re: high %system time

From: Bill Moran <wmoran(at)collaborativefusion(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: high %system time
Date: 2006-06-06 13:54:52
Message-ID: 20060606095452.a59c50ab.wmoran@collaborativefusion.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 06 Jun 2006 09:37:16 -0400
Jacob Coby <jcoby(at)listingbook(dot)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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2006-06-06 13:55:17 Re: 7.3.3, Fedora Core 5, test geometry and test horology
Previous Message Jacob Coby 2006-06-06 13:37:16 Re: high %system time