Hi all,
I've been trying opcode caches like apc/eaccelerator/xcache/etc. for many years now but have been unsatisfied with their instability, often causing apache/fastcgi crashed under heavy load (reproducible with apache benchmark 1000 concurrent requests).
It's only the latest version of xcache and php5.4 with the setting "xcache.readonly_protection = On" in php.ini that has managed not to crash so far under heavy load, so I've investigated how much more performance I can get out of atk4 by modifying some of the core functions to store things in the variable cache.
Here are some apache benchmark results (500 requests, concurrency: 10 requests) with php5.4 on a windows pc (core2duo 2.4ghz cpu, mechanical HDD) for a page with an mvcform.
No xcache enabled: 12.54 requests per second, a mean request time of 797ms and max request time of 1861ms.
With xcache enabled I get 13.9 requests per second, a mean request time of 718ms and a max request time of 1522ms.
With xcache enabled and by caching the parsed template in the xcache memory cache (SMLite->template, not SMLite->tags) as well as the class sourcecode that pathfinder->loadclass includes I get 20.43 requests per second, a mean request time of 491ms and a max request time of 1073ms.
So, by doing just 2 small tweaks to 2 classes (SMLite and PathFinder) it is possible to nearly double the performance of atk4. When concurrency is higher and IO bottlenecks caused by class includes and template parsing get more limiting, the performance well exceeds double. I'm not checking for filemtime on the cache keys so at the moment you have to clear the xcache variable cache if you change your template or source code, but this typically doesn't happen on a production server. I will make checking if the file has been changed an option later, but for me this isn't required.
I tested with APC and I got similar results, but it's not as reliable for me on windows so I chose xcache - but have written the code to detect either opcode cache.
For future performance improvements, I looked at atk's performance with xdebug and I found that around 30% of the processing time is taken building the template tags, but since these are dynamic it's hard to cache these as simply as you can the parsed template and class files.
Do you want me to share the source code of these files?
Perhaps we could make a variable cache class in atk which is implementation agnostic and will also allow the user to store things like dsql results?
Thanks