Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:2165 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 75307 invoked from network); 4 Jun 2003 17:18:06 -0000 Received: from unknown (HELO asuka.nerv) (24.112.18.98) by pb1.pair.com with SMTP; 4 Jun 2003 17:18:06 -0000 Received: (qmail 12441 invoked from network); 4 Jun 2003 17:25:57 -0000 Received: from rei.nerv (HELO dummy.com) (rei@192.168.1.1) by asuka.nerv with SMTP; 4 Jun 2003 17:25:57 -0000 Reply-To: ilia@prohost.org To: Rasmus Lerdorf , Jeff Moore , internals@lists.php.net Date: Wed, 4 Jun 2003 13:27:14 -0400 User-Agent: KMail/1.5 References: In-Reply-To: Organization: Prohost.org MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-ID: <200306041327.14883.ilia@prohost.org> Subject: Re: [PHP-DEV] Benchmarking 4.3.2 vs 4.1.2 From: ilia@prohost.org ("Ilia A.") Here is an analysis of the situation as it stands with PHP 4.3.3. As far as I can tell that even when opening files with the full path we do a lot of completely unnecessary work. We start from expand_filepath() which, gets called when opening a file. This function does a getcwd() everytime it is called even if path is full (/path/to/script.php), as far as I can tell completely useless syscal. Inside virtual_file_ex(), which gets called by expand_filepath(), even when the path is full we tokenize the path and validate every directory for '.' & '..' instead of just checking for . + DIR_SEPARATOR and only doing this work if such a thing exists. Quite a bit of completely useless cpu trashing in most cases everytime we open a file. Now, the interesting part, which I've yet to track down, are 6 lstat64() calls that occur between getcwd() (look above) and the actual open() for every file opened by PHP regardless of whether it had a full path or not. Here is strace bit: getcwd("/home/rei/PHP_CVS/STABLE/php4", 4096) = 30 <0.000011> lstat64(0xbfffad30, 0xbfffac90) = 0 <0.000015> lstat64(0xbfffad30, 0xbfffac90) = 0 <0.000008> lstat64(0xbfffad30, 0xbfffac90) = 0 <0.000008> lstat64(0xbfffad30, 0xbfffac90) = 0 <0.000008> lstat64(0xbfffad30, 0xbfffac90) = 0 <0.000008> lstat64(0xbfffad30, 0xbfffac90) = 0 <0.000009> open("/home/rei/PHP_CVS/STABLE/php4/file.html", O_RDONLY) = 4 <0.000018> Ilia P.S. I used the term 'unnecessary' because removing the mention code does not seem to affect the script's behaviour only makes it work faster.