Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49052 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66859 invoked from network); 13 Jul 2010 12:47:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Jul 2010 12:47:36 -0000 Authentication-Results: pb1.pair.com header.from=pierre.php@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=pierre.php@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.170 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: pierre.php@gmail.com X-Host-Fingerprint: 74.125.82.170 mail-wy0-f170.google.com Received: from [74.125.82.170] ([74.125.82.170:63333] helo=mail-wy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C1/71-58398-5606C3C4 for ; Tue, 13 Jul 2010 08:47:34 -0400 Received: by wyb32 with SMTP id 32so487998wyb.29 for ; Tue, 13 Jul 2010 05:47:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=eDgD1qblcy0/RYRfJFL4ISYZvHVmDWIfE2JhRYsbnU0=; b=J4AFPtuu7NkspS5I+jOeZuVBS617wGPOinHXKeLfRUvuScuWh/E/T/gXEp3Elh5qAO GbaBd+NFAOMrfS0DQ16dfViJXRzILNdSxTlNykwQBHHdQwdVb9MBe/7T30tT9GL2SvEC /2SnjweD74QGDUKVo9ew720dQxXgIAyV6r78M= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=v26xvFRz2eZiIBOmLeuSYTy4HsQdmRMkqTQmfLmDL5yCu6RHwFusgFfgZVe6CnWH9Z y7Pcl59hVBQQR5GfI0iOOEMCdmifYclvMYD7wVYI/VIR/cKbRZ5iSsGeb6a64lqVnw5U 1c0fD8CzGpCIYTC6YNSmoASOhsZlU6r20cOeQ= MIME-Version: 1.0 Received: by 10.216.177.140 with SMTP id d12mr10126418wem.37.1279025249523; Tue, 13 Jul 2010 05:47:29 -0700 (PDT) Received: by 10.216.166.70 with HTTP; Tue, 13 Jul 2010 05:47:29 -0700 (PDT) In-Reply-To: References: Date: Tue, 13 Jul 2010 14:47:29 +0200 Message-ID: To: "Vincenzo D'Amore" Cc: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Re: Performance problem with php From: pierre.php@gmail.com (Pierre Joye) hi, Please do not double posts both in the bug report and here. Or it will be a pain to follow. Cheers, On Tue, Jul 13, 2010 at 11:08 AM, Vincenzo D'Amore wro= te: > Hello All, > > could anybody explain me why if safe_mode or open_basedir are set, realpa= th > cache is disabled? > > Looking at source code main/main.c of 5.2.13 I can see: > > 1292: /* Disable realpath cache if safe_mode or open_basedir are set */ > if (PG(safe_mode) || (PG(open_basedir) && *PG(open_basedir))) { > CWDG(realpath_cache_size_limit) =3D 0; > } > > 1769: /* Disable realpath cache if safe_mode or open_basedir are set */ > if (PG(safe_mode) || (PG(open_basedir) && *PG(open_basedir))) { > CWDG(realpath_cache_size_limit) =3D 0; > } > > So realpath cache is definitely disabled in case of safe_mode or > open_basedir. > > This dramatically reduce performance of PHP Engine and, in a big producti= on > environment, this behavior can bring servers to its knees. > Especially because there is a lack of documentation! > > > On Fri, Jul 9, 2010 at 7:39 PM, Vincenzo D'Amore wro= te: > >> Hello all, >> >> I have already notified to the mailing list a performance problem with >> apache/mod_php5. >> >> Now I have an update and I think this is probably a bug. >> PHP lstat the full path more times before read the file when in apache >> httpd configuration is specified *PHP_ADMIN_VALUE open_basedir *setting. >> >> I have a simple website with only phpinfo.php page and inside we have on= ly >> "". >> >> httpd.2.2.15 fresh compiled and PHP 5.2.13. >> >> If is specified *PHP_ADMIN_VALUE open_basedir* in Virtual host >> configuration: >> >> >> =A0* =A0 =A0 =A0 =A0 =A0 =A0 =A0 PHP_ADMIN_VALUE open_basedir >> "/usr/local/myspace/webspace"* >> >> >> =A0 =A0 =A0 =A0 ServerName damorealt.xoom.it >> =A0 =A0 =A0 =A0 DocumentRoot "/usr/local/myspace/webspace/httpdocs" >> =A0 =A0 CustomLog =A0 /var/log/httpd/damorealt/access_log =A0 combined >> =A0 =A0 ErrorLog =A0 /var/log/httpd/damorealt/error_log >> >> >> Calling page http://damorealt.xoom.it/phpinfo.php we can reproduce >> following behavior: >> >> 25933 accept(3, {sa_family=3DAF_INET, sin_port=3Dhtons(47433), >> sin_addr=3Dinet_addr("212.48.14.186")}, [17179869200]) =3D 15 >> 25933 getsockname(15, {sa_family=3DAF_INET, sin_port=3Dhtons(80), >> sin_addr=3Dinet_addr("151.99.197.198")}, [17179869200]) =3D 0 >> 25933 fcntl(15, F_GETFL) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=3D 0x2 (flags O= _RDWR) >> 25933 fcntl(15, F_SETFL, O_RDWR|O_NONBLOCK) =3D 0 >> 25933 read(15, "GET /phpinfo.php HTTP/1.0\r\nUser-"..., 8000) =3D 129 >> 25933 gettimeofday({1278695388, 52976}, NULL) =3D 0 >> 25933 stat("/usr/local/myspace/webspace/httpdocs/phpinfo.php", >> {st_mode=3DS_IFREG|0644, st_size=3D16, ...}) =3D 0 >> 25933 open("/usr/local/myspace/.htaccess", O_RDONLY) =3D -1 ENOENT (No s= uch >> file or directory) >> 25933 open("/usr/local/myspace/webspace/.htaccess", O_RDONLY) =3D -1 ENO= ENT >> (No such file or directory) >> 25933 open("/usr/local/myspace/webspace/httpdocs/.htaccess", O_RDONLY) = =3D -1 >> ENOENT (No such file or directory) >> 25933 open("/usr/local/myspace/webspace/httpdocs/phpinfo.php/.htaccess", >> O_RDONLY) =3D -1 ENOTDIR (Not a directory) >> 25933 setitimer(ITIMER_PROF, {it_interval=3D{0, 0}, it_value=3D{20, 0}},= NULL) >> =3D 0 >> 25933 rt_sigaction(SIGPROF, {0x2b80442fdd80, [PROF], >> SA_RESTORER|SA_RESTART, 0x3916e302d0}, {SIG_DFL, [], 0}, 8) =3D 0 >> 25933 rt_sigprocmask(SIG_UNBLOCK, [PROF], NULL, 8) =3D 0 >> 25933 getcwd("/"..., 4095) =A0 =A0 =A0 =A0 =A0 =A0 =A0=3D 2 >> 25933 chdir("/usr/local/myspace/webspace/httpdocs") =3D 0 >> >> *water boiling point* >> >> 25933 lstat("/usr", {st_mode=3DS_IFDIR|0755, st_size=3D4096, ...}) =3D 0 >> 25933 lstat("/usr/local", {st_mode=3DS_IFDIR|0755, st_size=3D4096, ...})= =3D 0 >> 25933 lstat("/usr/local/myspace", {st_mode=3DS_IFDIR|0755, st_size=3D409= 6, >> ...}) =3D 0 >> 25933 lstat("/usr/local/myspace/webspace", {st_mode=3DS_IFDIR|0755, >> st_size=3D4096, ...}) =3D 0 >> 25933 lstat("/usr/local/myspace/webspace/httpdocs", {st_mode=3DS_IFDIR|0= 755, >> st_size=3D4096, ...}) =3D 0 >> 25933 lstat("/usr/local/myspace/webspace/httpdocs/phpinfo.php", >> {st_mode=3DS_IFREG|0644, st_size=3D16, ...}) =3D 0 >> >> First check >> >> 25933 lstat("/usr", {st_mode=3DS_IFDIR|0755, st_size=3D4096, ...}) =3D 0 >> 25933 lstat("/usr/local", {st_mode=3DS_IFDIR|0755, st_size=3D4096, ...})= =3D 0 >> 25933 lstat("/usr/local/myspace", {st_mode=3DS_IFDIR|0755, st_size=3D409= 6, >> ...}) =3D 0 >> 25933 lstat("/usr/local/myspace/webspace", {st_mode=3DS_IFDIR|0755, >> st_size=3D4096, ...}) =3D 0 >> 25933 lstat("/usr/local/myspace/webspace/httpdocs", {st_mode=3DS_IFDIR|0= 755, >> st_size=3D4096, ...}) =3D 0 >> 25933 lstat("/usr/local/myspace/webspace/httpdocs/phpinfo.php", >> {st_mode=3DS_IFREG|0644, st_size=3D16, ...}) =3D 0 >> >> Second check >> >> 25933 lstat("/usr", {st_mode=3DS_IFDIR|0755, st_size=3D4096, ...}) =3D 0 >> 25933 lstat("/usr/local", {st_mode=3DS_IFDIR|0755, st_size=3D4096, ...})= =3D 0 >> 25933 lstat("/usr/local/myspace", {st_mode=3DS_IFDIR|0755, st_size=3D409= 6, >> ...}) =3D 0 >> 25933 lstat("/usr/local/myspace/webspace", {st_mode=3DS_IFDIR|0755, >> st_size=3D4096, ...}) =3D 0 >> >> Third check (incomplete) >> >> 25933 lstat("/usr", {st_mode=3DS_IFDIR|0755, st_size=3D4096, ...}) =3D 0 >> 25933 lstat("/usr/local", {st_mode=3DS_IFDIR|0755, st_size=3D4096, ...})= =3D 0 >> 25933 lstat("/usr/local/myspace", {st_mode=3DS_IFDIR|0755, st_size=3D409= 6, >> ...}) =3D 0 >> 25933 lstat("/usr/local/myspace/webspace", {st_mode=3DS_IFDIR|0755, >> st_size=3D4096, ...}) =3D 0 >> 25933 lstat("/usr/local/myspace/webspace/httpdocs", {st_mode=3DS_IFDIR|0= 755, >> st_size=3D4096, ...}) =3D 0 >> 25933 lstat("/usr/local/myspace/webspace/httpdocs/phpinfo.php", >> {st_mode=3DS_IFREG|0644, st_size=3D16, ...}) =3D 0 >> >> Final check and then read the file. >> >> 25933 open("/usr/local/myspace/webspace/httpdocs/phpinfo.php", O_RDONLY)= =3D >> 16 >> 25933 fstat(16, {st_mode=3DS_IFREG|0644, st_size=3D16, ...}) =3D 0 >> 25933 read(16, "\n", 8192) =3D 16 >> 25933 read(16, "", 8192) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=3D 0 >> 25933 read(16, "", 8192) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=3D 0 >> 25933 close(16) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =3D 0 >> >> >> If *PHP_ADMIN_VALUE open_basedir "/usr/local/myspace/webspace" =A0is rem= oved >> * in virtual host configuration we finally have simpliest behavior: >> >> 226235 accept(3, {sa_family=3DAF_INET, sin_port=3Dhtons(59366), >> sin_addr=3Dinet_addr("212.48.14.186")}, [17179869200]) =3D 15 >> 26235 getsockname(15, {sa_family=3DAF_INET, sin_port=3Dhtons(80), >> sin_addr=3Dinet_addr("151.99.197.198")}, [17179869200]) =3D 0 >> 26235 fcntl(15, F_GETFL) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=3D 0x2 (flags O= _RDWR) >> 26235 fcntl(15, F_SETFL, O_RDWR|O_NONBLOCK) =3D 0 >> 26235 read(15, "GET /phpinfo.php HTTP/1.0\r\nUser-"..., 8000) =3D 129 >> 26235 gettimeofday({1278696735, 988799}, NULL) =3D 0 >> 26235 stat("/usr/local/myspace/webspace/httpdocs/phpinfo.php", >> {st_mode=3DS_IFREG|0644, st_size=3D16, ...}) =3D 0 >> 26235 open("/usr/local/myspace/.htaccess", O_RDONLY) =3D -1 ENOENT (No s= uch >> file or directory) >> 26235 open("/usr/local/myspace/webspace/.htaccess", O_RDONLY) =3D -1 ENO= ENT >> (No such file or directory) >> 26235 open("/usr/local/myspace/webspace/httpdocs/.htaccess", O_RDONLY) = =3D -1 >> ENOENT (No such file or directory) >> 26235 open("/usr/local/myspace/webspace/httpdocs/phpinfo.php/.htaccess", >> O_RDONLY) =3D -1 ENOTDIR (Not a directory) >> 26235 setitimer(ITIMER_PROF, {it_interval=3D{0, 0}, it_value=3D{20, 0}},= NULL) >> =3D 0 >> 26235 rt_sigaction(SIGPROF, {0x2afef587dd80, [PROF], >> SA_RESTORER|SA_RESTART, 0x3916e302d0}, {SIG_DFL, [], 0}, 8) =3D 0 >> 26235 rt_sigprocmask(SIG_UNBLOCK, [PROF], NULL, 8) =3D 0 >> 26235 getcwd("/"..., 4095) =A0 =A0 =A0 =A0 =A0 =A0 =A0=3D 2 >> 26235 chdir("/usr/local/myspace/webspace/httpdocs") =3D 0 >> >> *water boiling point* >> >> 26235 time(NULL) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=3D 1278= 696735 >> 26235 lstat("/usr", {st_mode=3DS_IFDIR|0755, st_size=3D4096, ...}) =3D 0 >> 26235 lstat("/usr/local", {st_mode=3DS_IFDIR|0755, st_size=3D4096, ...})= =3D 0 >> 26235 lstat("/usr/local/myspace", {st_mode=3DS_IFDIR|0755, st_size=3D409= 6, >> ...}) =3D 0 >> 26235 lstat("/usr/local/myspace/webspace", {st_mode=3DS_IFDIR|0755, >> st_size=3D4096, ...}) =3D 0 >> 26235 lstat("/usr/local/myspace/webspace/httpdocs", {st_mode=3DS_IFDIR|0= 755, >> st_size=3D4096, ...}) =3D 0 >> 26235 lstat("/usr/local/myspace/webspace/httpdocs/phpinfo.php", >> {st_mode=3DS_IFREG|0644, st_size=3D16, ...}) =3D 0 >> >> And read the file. >> >> 26235 open("/usr/local/myspace/webspace/httpdocs/phpinfo.php", O_RDONLY)= =3D >> 16 >> 26235 fstat(16, {st_mode=3DS_IFREG|0644, st_size=3D16, ...}) =3D 0 >> 26235 read(16, "\n", 8192) =3D 16 >> 26235 read(16, "", 8192) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=3D 0 >> 26235 read(16, "", 8192) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=3D 0 >> 26235 close(16) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =3D 0 >> 26235 uname({sys=3D"Linux", node=3D"svilpar4", ...}) =3D 0 >> 26235 time(NULL) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=3D 1278= 696735 >> 26235 writev(15, [{"HTTP/1.1 200 OK\r\nDate: Fri, 09 J"..., 173}, >> {"> cellpadding=3D\"3"..., 4101}], 3) =3D 8383 >> 26235 writev(15, [{"highlight.bg> {"sendmail_from"..., 4099}], 2) =3D 8204 >> 26235 time(NULL) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=3D 1278= 696735 >> 26235 writev(15, [{" \nHT"..., 4108}, >> {"1024> 26235 writev(15, [{"md2 md4 md5 sha1 sha256 sha384 s"..., 4098}, {" >> \n
\n> 26235 writev(15, [{"session.use_cookies> enabled > 26235 chdir("/") =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=3D 0 >> 26235 setitimer(ITIMER_PROF, {it_interval=3D{0, 0}, it_value=3D{0, 0}}, = NULL) =3D >> 0 >> 26235 writev(15, [{"\"]Keep-Alive<"..., 4206}], 1= ) =3D >> 4206 >> 26235 write(10, "212.48.14.186 - - [09/Jul/2010:1"..., 116) =3D 116 >> 26235 shutdown(15, 1 /* send */) =A0 =A0 =A0 =A0=3D 0 >> 26235 poll([{fd=3D15, events=3DPOLLIN}], 1, 2000) =3D 1 ([{fd=3D15, >> revents=3DPOLLIN|POLLHUP}]) >> 26235 read(15, "", 512) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =3D 0 >> 26235 close(15) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =3D 0 >> 26235 read(4, 0x7fff615ff5eb, 1) =A0 =A0 =A0 =A0=3D -1 EAGAIN (Resource = temporarily >> unavailable) >> 26235 accept(3, >> >> Note that this behavior also happens when safemode is ON. >> >> Can somebody explain me why PHP have such behavior? >> >> Best regards, >> Vincenzo >> > > > > -- > Vincenzo D'Amore > email: v.damore@gmail.com > msn: freedev@hotmail.com > skype: free.dev > mobile: +39 349 8513251 > --=20 Pierre @pierrejoye | http://blog.thepimp.net | http://www.libgd.org