Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 27 Jan 2008 11:29:11 +0000
From:      Thomas Hurst <tom.hurst@clara.net>
To:        Miroslav Lachman <000.fbsd@quip.cz>
Cc:        freebsd-performance@freebsd.org
Subject:   Re: PHP with open_basedir performance problem
Message-ID:  <20080127112911.GA4024@voi.aagh.net>
In-Reply-To: <479B1185.8020604@quip.cz>
References:  <479B1185.8020604@quip.cz>

next in thread | previous in thread | raw e-mail | index | archive | help
* Miroslav Lachman (000.fbsd@quip.cz) wrote:

> I found a painful performance problem with Apache + PHP 5 when
> open_basedir directive is enabled.

Looks like it's lstat()/readlink() overhead.  I wrote a simple bit of
PHP similar to yours, but doing 10 * 1000 require "foo/%d/%d.php" calls
=66rom the command line:

-% time ktrace php main.php
Real: 0:09.61 CPU: 99.8% (3.725/5.885) Page: 0 Swap: 0 I/O: (0/0) Mem:
13704

-% time ktrace php -d open_basedir=3D'/home/freaky/openbasedir/foo'
main.php
Real: 0:16.21 CPU: 86.4% (8.185/5.840) Page: 0 Swap: 0 I/O: (0/0) Mem:
13696

Without open_basedir, a simple script to parse the kdump syscall times
produces:

   lstat        : 1.147s/70065 calls =3D 0.000s per call.  Max=3D0.000s Min=
=3D0.0000s
   fcntl        : 0.408s/60007 calls =3D 0.000s per call.  Max=3D0.000s Min=
=3D0.0000s
sigprocmask     : 0.229s/40311 calls =3D 0.000s per call.  Max=3D0.000s Min=
=3D0.0000s
    open        : 0.223s/10085 calls =3D 0.000s per call.  Max=3D0.000s Min=
=3D0.0000s

With open_basedir:

   lstat        : 4.182s/270065 calls =3D 0.000s per call.  Max=3D0.005s Mi=
n=3D0.0000s
readlink        : 2.142s/10006 calls =3D 0.000s per call.  Max=3D2.020s Min=
=3D0.0000s
   fcntl        : 0.421s/60007 calls =3D 0.000s per call.  Max=3D0.002s Min=
=3D0.0000s
   close        : 0.295s/10085 calls =3D 0.000s per call.  Max=3D0.115s Min=
=3D0.0000s
sigprocmask     : 0.237s/40311 calls =3D 0.000s per call.  Max=3D0.000s Min=
=3D0.0000s
    open        : 0.222s/10085 calls =3D 0.000s per call.  Max=3D0.000s Min=
=3D0.0000s

The top two syscalls seem to account for most of the 6.mumble seconds of
additional runtime; presumably these are much cheaper on Linux.

--=20
Thomas 'Freaky' Hurst
    http://hur.st/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080127112911.GA4024>