On 19 March 2015 at 20:26, Eric Stenson <erics...@microsoft.com> wrote:
> PHP Internals folks--
>
> We're doing some performance work in WinCache, and we're finding that some 
> frameworks
> are...uh...enthusiastically using file_exists(), is_file() and is_dir() 
> functions on
> files/directories that don't exist.  Every. Single. Pageload.

What context are these filesystem hits in, is it class autoloading by
any chance? If so there was a function added to OPCache and a
hopefully upcoming feature to Composer that may be of interest.

http://php.net/manual/en/function.opcache-is-script-cached.php
https://github.com/composer/composer/pull/3802

Those two combined eliminate a huge number of file_exists calls,
similar to what you are describing. Though I guess the is_file and
is_dir functions might be in a different area of code.

> Does the PHP stat cache include negative cache entries?  If not, why not?

Negative caches tend to just be the wrong thing. A positive cache
returns usable data, with the proviso that the data might be out of
date. A negative cache, returns nothing usable.

For example, a browser caching a page that returns a 200 response is
fine, as it's caching some information that was acceptable. A browser
caching a 50x error page would just be caching useless information.

Another example - the Composer autoloader behaves as a negative cache,
in that it caches the 'fact' that a class doesn't exist. This gets in
the way of being able to dynamically generate code, as once you've
called `class_exists("SomeAutogeneratedClass", true);` you can no
longer use the registered autoloaders to load that class, and instead
have to load it by hand.

cheers
Dan

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to