Re: Benchmarking 4.3.2 vs 4.1.2

From: Date: Wed, 04 Jun 2003 17:27:14 +0000
Subject: Re: Benchmarking 4.3.2 vs 4.1.2
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-2165@lists.php.net to get a copy of this message
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.

« previous php.internals (#2165) next »