> Weird.  That was totally contrary to the way I remember it working.  In 
> trying to figure out why I remembered incorrectly, I realized the 
> reason why you (in general) want to resolve the path to a canonical 
> path is that you can seriously break include_once and require_once if 
> you dont.  Otherwise require_once wont correctly work if you do
> 
> <?
>        require_once("/home/george/foo.php");
>        require_once("/home/george/../george/foo.php");
> ?>

Right, but guarding against this edge case is costing us a lot on the 
normal case.

100,000 realpath() calls on Linux on file /home/rasmus/foo/u2.inc:
real    0m1.286s
user    0m0.190s
sys     0m1.030s

100,000 stat() calls on Linux on file /home/rasmus/foo/u2.inc:
real    0m0.421s
user    0m0.070s
sys     0m0.290s

The deeper the directory hierachy, the larger the difference.

On FreeBSD we get slammed!  Looks like they don't have the same 
dcache-like thing that Linux has.

100,000 realpath() calls on /home/rasmus/foo/u2.inc on FreeBSD:
real    0m51.274s
user    0m6.752s
sys     0m26.478s

100,000 stats() calls on the same file on FreeBSD:
real    0m8.873s
user    0m0.165s
sys     0m8.042s

So yes, it does look like we don't need to worry too much on Linux, but 
clearly on FreeBSD avoiding stat() calls and calls that create cascading 
stat()'s are to be avoided at all costs.

-Rasmus


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

Reply via email to