From owner-freebsd-performance@FreeBSD.ORG Sun Jan 27 11:50:50 2008 Return-Path: Delivered-To: freebsd-performance@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2471816A417 for ; Sun, 27 Jan 2008 11:50:50 +0000 (UTC) (envelope-from tom.hurst@clara.net) Received: from spork.qfe3.net (spork.qfe3.net [212.13.207.101]) by mx1.freebsd.org (Postfix) with ESMTP id DB36213C455 for ; Sun, 27 Jan 2008 11:50:49 +0000 (UTC) (envelope-from tom.hurst@clara.net) Received: from [81.104.123.28] (helo=voi.aagh.net) by spork.qfe3.net with esmtp (Exim 4.66 (FreeBSD)) (envelope-from ) id 1JJ5hH-0002cB-SH; Sun, 27 Jan 2008 11:29:11 +0000 Received: from freaky by voi.aagh.net with local (Exim 4.69 (FreeBSD)) (envelope-from ) id 1JJ5hH-0004XD-Ha; Sun, 27 Jan 2008 11:29:11 +0000 Date: Sun, 27 Jan 2008 11:29:11 +0000 From: Thomas Hurst To: Miroslav Lachman <000.fbsd@quip.cz> Message-ID: <20080127112911.GA4024@voi.aagh.net> Mail-Followup-To: Miroslav Lachman <000.fbsd@quip.cz>, freebsd-performance@freebsd.org References: <479B1185.8020604@quip.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <479B1185.8020604@quip.cz> Organization: Not much. User-Agent: Mutt/1.5.17 (2007-11-01) Sender: Thomas Hurst Cc: freebsd-performance@freebsd.org Subject: Re: PHP with open_basedir performance problem X-BeenThere: freebsd-performance@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Performance/tuning List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Jan 2008 11:50:50 -0000 * 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/