On Fri, 05 Apr 2013 06:45:52 -0700, vitalif@yourcmc.ru wrote:
You can't cache program state and loaded code like that in PHP. We explicitly have to abuse the autoloader and develop other patterns to avoid loading unused portions of code because if we don't our initialization is unreasonably long.
Yeah, I understand it, the idea was to serialize globals like $wgHooks $wgAutoloadClasses and etc - and load them in the beginning of each request... So each extension would be separated in two parts: (1) metadata, executed once and then cached and (2) classes, cached by opcode cacher and loaded by a slim autoloader. By this approach you'll get rid of executing even the main file of each extension; the downside is that it of course would require some extension rewriting. I'm curious is such feature going to result in any performance benefit or not :)
Opcode caches are pretty efficient at optimizing simple stuff. The difference between loading serialized data and executing the simple opcode cached files that generated that data should be negligible. And if you go the serialize route things start to become more complex and less flexible.
Our biggest performance penalties came from stuff like loading dozens of classes that aren't being used and loading all of the i18n. Which we had to rewrite with a per-language cache.