Re: Benchmarking 4.3.2 vs 4.1.2

From: Date: Mon, 09 Jun 2003 16:58:08 +0000
Subject: Re: Benchmarking 4.3.2 vs 4.1.2
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-2255@lists.php.net to get a copy of this message
At 01:27 PM 6/4/2003 -0400, Ilia A. wrote:
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.
Two different full paths can point to the same file and not using realpath() would break include_once() and require_once(). We might be able to use stat() information to compare the files but it would require some thinking. Andi
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. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.internals (#2255) next »