Re: Performance Consideration of 1 class per file
| From: | George Schlossnagle | Date: | Sat, 24 Apr 2004 16:16:36 +0000 |
| Subject: | Re: Performance Consideration of 1 class per file | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-9547@lists.php.net to get a copy of this message | ||
On Apr 24, 2004, at 11:43 AM, Rasmus Lerdorf wrote:
On Sat, 24 Apr 2004, George Schlossnagle wrote: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: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.
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