On Apr 24, 2004, at 11:43 AM, Rasmus Lerdorf wrote:


On Sat, 24 Apr 2004, George Schlossnagle wrote:
A nitpick - apc now uses device/inode information and not the file name
as hash keys. It's no less or more expensive before, both require an
equivalent of realpath() (actually in the apache case the new version
is twice as efficient as the old - thanks rasmus).

What do you mean by that? APC doesn't require anything near a realpath.
If you get rid of realpath() in PHP, APC will work just fine. With my
syscall hacks I am using APC this way and I just have 1 stat per file.
The only visible difference is when you ask APC which files it has cached
and it doesn't return full-path filenames but rather just the paths used
to include the files.


For the top file there is no stat in PHP/APC at all anymore as we inherit
the stat struct from Apache (which I guess is what you are alluding to)
and then for each include file only a single stat is needed. That is
nowhere near the equivalent of a realpath which adds N stats per file
where N is the depth of the file in the directory structure.

Yes, that was what I was alluding to. That only works for the top level file though, not any includes. Without that though, you need to call apc_stat_paths(), which does this:


paths = apc_tokenize(path, ':'); /* TODO - on windows, it's ';' */
if (!paths)
return -1;


/* for each directory in paths, look for filename inside */
for (i = 0; paths[i]; i++) {
snprintf(filepath, sizeof(filepath), "%s/%s", paths[i], filename);
if (stat(filepath, buf) == 0) {
found = 1;
break;
}
}


And while not a realpath(), it does a similar sort of search (path here is the include_path for those following along at home). Fully qualifying your paths makes up for this, and the next best thing is to make sure your include_path is tight and optimally ordered.

George

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



Reply via email to