tekrat

Apache Stat Cache

One great thing to optimize out of any system is system calls, and especially any system call that access i/o or disk.  In an attempt to exclude all stat calls from the Apache/PHP/APC stack, I created an Apache file stat cache that would cache all the stat calls in memory and never repeat a stat call.  This means also means that modifications on disk won’t be seen, which could cause problems so not ideal for anything that’s changing files often.  You also can’t flush the cash programatically, so a restart is required to have it pick up any changes.   As it turns out this patch isn’t really that useful, as the gains are pretty marginal if at all, and typically you’ll have heavier performance bottlenecks in PHP code than the one stat call that Apache is going to do per request.  However, in the interest of sharing, I’m posting this here in the hopes that someone else may find it useful. Features such as updating cache entries, TTL, or safety in case files on disk do change hasn’t been added so I don’t make any assurances to it’s stability.  Checkout the patch text for installation/usage instructions.

Download: ap_StatCache.patch


Leave a reply