Re: Performance problem with php
| From: | Rasmus Lerdorf | Date: | Wed, 23 Jun 2010 14:02:09 +0000 |
| Subject: | Re: Performance problem with php | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-48952@lists.php.net to get a copy of this message | ||
On 6/23/10 6:56 AM, Wietse Venema wrote:
> Stas Malyshev:
>> Hi!
>>
>>> could anybody tell me why also for every single php file engine must lstat
>>> all path?
>>> Why php engine don't simply try to open directly the file?
>>
>> There are some places where PHP engine has to know "true" name of the
>> file - i.e. filename that would be the same for each file regardless of
>> how it is accessed - through relative path, symlinks, etc. Example can
>> be {include|require}_once. For that, it needs to figure out the whole
>> path. It is done only once per file, then cached. If you seeing it on
>> repeated runs in the same process, increase your realpath cache size
>> (yes, the default is way too small for any big app).
>
> Another option may be to compute a hash of the file. When you find
> that file content has the same hash value as a known file you flag
> them as "same file". This could be faster (file contents are cached
> in main memory because the OS already knows the files are the same,
> and finding the "real" name of a file is a slow process).
When properly configured the realpath result should be cached as well
though and we avoid calling a hash function on what could potentially be
a lot of data.
-Rasmus