On Sat, 24 Apr 2004, George Schlossnagle wrote: > > 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.
Well, I disagree that this is anything like a realpath(). If your PEAR directory is the first thing in the include_path (as in get rid of "." from it) then this is a single stat call on any PEAR include regardless of how deep your directory structure is. Compared to realpath where including XML_RSS/RSS.php from a PEAR path of /usr/local/php/pear would be 6 stats. We can't avoid a single stat per file, and on include_path includes we can't avoid a single stat per attempted include_path component. The single stats don't worry me very much and we could reduce this with an intelligent request-spanning stat cache system. -Rasmus -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php