Hi,
I have a small patch (2k lines) at http://p.defau.lt/? Jnc0Y1AY0hc0SNOhmFtzSw
that eliminates most of require_once() calls and uses require() in __autoload() handler. Generally it makes things faster, as less require_once means less stat (), as well as that might be more APC-friendly.
As well as some refactoring was needed, I could introduce lots of bugs. And break extensions of course.
As included source is executed at function scope, rather than file scope, various other issues could arise - like missing global declarations, etc.
So, please send your comments ;-)
Domas
I have a small patch (2k lines) that eliminates most of require_once() calls and uses require() in __autoload() handler. Generally it makes things faster, as less require_once means less stat(), as well as that might be more APC-friendly.
Not questioning anything, but out of interest: I don't understand how this saves any stat()s? Surely multiple calls to require_once for the same file still require only one stat().
Timwi wrote:
I have a small patch (2k lines) that eliminates most of require_once() calls and uses require() in __autoload() handler. Generally it makes things faster, as less require_once means less stat(), as well as that might be more APC-friendly.
Not questioning anything, but out of interest: I don't understand how this saves any stat()s? Surely multiple calls to require_once for the same file still require only one stat().
Apparently not, particularly if you're using relative paths (as we have traditionally). As I've heard this explained, the stat()s here are done in require_once itself so the opcode cache plugin can't avoid them.
Note that you can also tell APC to cheat and *never* itself stat for files that have been cached: in this case you need to explicitly clear the opcode cache when pushing updated files. If using require() this might get you totally stat-free. (In theory.)
-- brion vibber (brion @ pobox.com)
Hi Timwi,
Not questioning anything, but out of interest: I don't understand how this saves any stat()s? Surely multiple calls to require_once for the same file still require only one stat().
require_once() calls realpath() every time, which calls stat() for every directory up to the root.
Domas
wikitech-l@lists.wikimedia.org