« Return to Thread: require_once performance issue in ZF

Re: require_once performance issue in ZF

by beberlei :: Rate this Message:

Reply to Author | View in Thread

you can write a script to remove all require_once that non dynamically load
Zend Framework classes and rely on Autoload to solve your problems, which can
use require only. This is quite easy to do.

As I understood 2.0 will have some changes regarding require and autoloadings.
Also PHP 5.3 will implement a new require_once that reduces overhead
(somewhat).

On Friday 29 August 2008 13:24:49 Gea-Suan Lin wrote:

> Hello,
>
> We've ported our application from plain PHP to ZF 1.5.3, and notice some
> performance issue in require_once().
>
> We run web server in FreeBSD 7-STABLE, apache 2.2 worker, mod_fastcgi,
> and php-fcgi 5.2.6. (install from ports)
>
> The original application needs 6 servers (E5405, 8 logical cpu) only, and
> most of them are 50% idle. But the ported version needs 17 servers and 0%
> idle, with 80% system cpu time, 20% userland cpu time.
>
> I use ktrace (similar with strace in Linux) trying to dig problem, and
> find it's because lstat(2), and FreeBSD's lstat(2) call VFS_GIANT_LOCK(9)
> to lock VFS. This behavior cause inscalability.
>
> So I also tried to install Debian (testing, 2.6.18 kernel), with same
> apache 2.2 worker, mod_fastcgi, php-fcgi 5.2.6. (all installed by
> apt-get). CPU usage in system is decreasing, but only 30% performance
> better then FreeBSD one.
>
> After reading the following article, I realize that require_once() is a
> very important factor, since it calls realpath(3) and realpath(3) calls
> lstat(2):
>
> http://www.techyouruniverse.com/software/php-performance-tip-require-versus
>-require_once
>
> I replace all require_once argument to absolute path in ZF library, and
> the performance seems much acceptable. (Down to 50% idle in 17 servers,
> still not very happy to me, since it needs change require_once() code,
> and our writing pattern)
>
> I've been told by some people that some framework will implement its
> require_once to reduce PHP's require_once code, does ZF team have such
> plan ?
>
> Thanks,
>
> PS: for people understanding Chinese, you may see my blog to talk about
>     this more specifically: http://blog.gslin.org/archives/2008/08/29/1639/



--
Benjamin Eberlei
http://www.beberlei.de

 « Return to Thread: require_once performance issue in ZF