Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:39036 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 75446 invoked from network); 17 Jul 2008 06:55:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Jul 2008 06:55:41 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@lerdorf.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@lerdorf.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lerdorf.com from 204.11.219.139 cause and error) X-PHP-List-Original-Sender: rasmus@lerdorf.com X-Host-Fingerprint: 204.11.219.139 mail.lerdorf.com Received: from [204.11.219.139] ([204.11.219.139:43555] helo=mail.lerdorf.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5A/5A-54589-CECEE784 for ; Thu, 17 Jul 2008 02:55:41 -0400 Received: from [192.168.200.148] (c-24-6-219-206.hsd1.ca.comcast.net [24.6.219.206]) (authenticated bits=0) by mail.lerdorf.com (8.14.3/8.14.3/Debian-4) with ESMTP id m6H6tZwu017848; Wed, 16 Jul 2008 23:55:35 -0700 Message-ID: <487EECE7.9090506@lerdorf.com> Date: Wed, 16 Jul 2008 23:55:35 -0700 User-Agent: Thunderbird/3.0a2pre (Macintosh; 2008071516) MIME-Version: 1.0 To: Arvids Godjuks CC: PHP Internals List References: <1216133436.6875.35.camel@amirh> <487CEF26.7030802@lerdorf.com> <1216159988.28846.12.camel@localhost> <487D22AE.20109@lerdorf.com> <5a2b1bf10807152247r563092a6l88d555d2389506e4@mail.gmail.com> <9b3df6a50807160340w578d7490xb6f2810652e1bb47@mail.gmail.com> <487DFB86.3030404@lerdorf.com> <1216224862.20625.33.camel@amirh> <487E2051.70000@lerdorf.com> <9b3df6a50807162349s4893d8d0ue7d02c0e8046bb96@mail.gmail.com> In-Reply-To: <9b3df6a50807162349s4893d8d0ue7d02c0e8046bb96@mail.gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-3.0 (mail.lerdorf.com [204.11.219.139]); Wed, 16 Jul 2008 23:55:36 -0700 (PDT) Subject: Re: [PHP-DEV] lstat call on each directory level From: rasmus@lerdorf.com (Rasmus Lerdorf) Arvids Godjuks wrote: > Yesterday I made some tests on my site with strace to see how much lstat > I have and how can I optimize them. Well, I managed to get rid of them > almost at all, but now I have some questions about include_path and > including files based on current dir. > > I have such structire of files > > /home/file/www (that's my site root dir) > > include/ > - bittorrent > - global.php > > lang/ > - eng.lang > - rus.lang > > index.php > > > My files are > ---- index.php --- > require './include/bittorrent.php'; > > --- common.php --- > require './include/global.php'; > require './lang/eng.lang'; > And some other files from include dir > > Default include path is ".:/usr/share/php5:/usr/share/php" and if I > don't change it it results in a bunch of lstat. Here is the trace > http://pastebin.com/m37704b6a > > The thing I don't understand from trace is WHY it tests include path > BEFORE the ./ ? Why it doesn't try to load file based on relative path > first (it should hit it on first try) and then use include path? > Ok, I make in bittorrent.php - set_include_path('/home/file/www'); > > The only lstat i have now is > > lstat("/home", {st_mode=S_IFDIR|0755, st_size=144, ...}) = 0 > lstat("/home/file", {st_mode=S_IFDIR|0755, st_size=1112, ...}) = 0 > lstat("/home/file/www", {st_mode=S_IFDIR|0755, st_size=11880, ...}) = 0 > lstat("/home/file/www/bittorrent.php", 0x7fff8d95cca0) = -1 ENOENT (No > such file or directory) > open("/home/file/www/bittorrent.php", O_RDONLY) = -1 ENOENT (No such > file or directory) > open("/home/file/www/include/bittorrent.php", O_RDONLY) = 14 > > So the question is - why are they happen at all, if I include > bittorrent.php as require './include/bittorrent.php' in index.php. As i > understand it should hit the right folder from first time. Could you, > please, explain how all this works, because as it turned out it is not > so obvious as it should be... > > I have PHP 5.2.6 (Gentoo Linux package name is dev-php5/php-5.2.6-r2) > and lighttpd 1.5 You missed something. You have an include 'bittorrent.php' in there somewhere. This thread would really be more appropriate on php-users at this point. -Rasmus