ZF-12478: PluginLoader file cache and scalability
Description
Upon moving to an architecture that is more dependent on helpers than before, we have noticed a substantial decrease in site performance. After doing some benchmarking, enabling the PluginLoaderCache has given us a substantial performance boost (~15%), but we are noticing that it is still inefficient:
PluginLoader has no persistent cache across requests mapping name to classname, so it needs to loop through prefixes and check class_exists() on every one, every time, until it finds the helper it needs.
The filesystem is hit on every prefix (see ZF-11426), resulting in many disk accesses. This is especially pronounced in larger codebases.
The includeFileCache requires that every helper be loaded up front in one big file on every request. This is not scalable for large codebases with many helpers.
We have a couple of potential solutions -
A) Give us an option to auto-load these classes. This could be done by replacing the includeFileCache with a classNameCache which maps $name => $className. Rather than loop through each prefix/name combo with class_exists, and then going to the disk on each one, we could check the name array for $name, return the $className, then allow the auto-loader to manage the class loading.
B) Allow the user to replace PluginLoader entirely with our own logic. I don't think we're the only ones who have a reason to do this: http://stackoverflow.com/questions/11849531/…
Comments
Posted by Ralph Schindler (ralph) on 2013-04-05T16:07:08.000+0000
This issue has been closed on Jira and moved to GitHub for issue tracking. To continue following the resolution of this issues, please visit: https://github.com/zendframework/zf1/issues/37