I made a simple change to the caching system for an easy 1% win. It turns out that all the Zend currency and locale libraries need to cache a lot of data. As I wrote before, Magento lumps in all cached data into one cache repository, making it more difficult to use the tag/attribute system, and generally find what you're looking for in the cache. By simply creating a new _localecache attribute of the App model, and passing it only to Zend Locale/Currency objects, we can get a quick speed up.
Separating out each major cache component into its own cache repository (directory) is the way to go. I just didn't expect it to be this easy.
Showing posts with label cache. Show all posts
Showing posts with label cache. Show all posts
Tuesday, 28 April 2009
Friday, 10 April 2009
Working on the cache
The config and cache are probably the two worst offenders in magento.
The cache can actually slow down your site because ZF doesn't keep an index of tags on your cached data. If you specify that you want to clean up all "shopping cart" tagged data, ZF cache has to search every single metadata file and look for the tag... resulting in hundreds or thousands of fopen, fread, fclose calls on your system.
If you try to use one of the memory cache backends, like memcache or APC you'll find that they perform *worse* than the file cache. Magento's concept of caching is throwing thousands of tiny little objects into individual files creates huge fragmentation in the memory and actually slows the site down.
The entire way the cache works needs to be thrown out and started over. It should be federated into different directories for config data, template data and all the other top level cache controls currently available. I'm kind of scared to load two or more instances of Zend_Cache_Core in one request. Savvy ZF people will say, "Oh, but it has a nesting depth setting.", not what I'm talking about. The next thing that needs to change: only large chunks of data need to be stored in a cache. Tiny pieces of template data which take little time to compute should not be kept in the cache. Entire pages, on the other hand, could be saved in the cache, minus the customer cart side bar and login/logout links.
The cache can actually slow down your site because ZF doesn't keep an index of tags on your cached data. If you specify that you want to clean up all "shopping cart" tagged data, ZF cache has to search every single metadata file and look for the tag... resulting in hundreds or thousands of fopen, fread, fclose calls on your system.
If you try to use one of the memory cache backends, like memcache or APC you'll find that they perform *worse* than the file cache. Magento's concept of caching is throwing thousands of tiny little objects into individual files creates huge fragmentation in the memory and actually slows the site down.
The entire way the cache works needs to be thrown out and started over. It should be federated into different directories for config data, template data and all the other top level cache controls currently available. I'm kind of scared to load two or more instances of Zend_Cache_Core in one request. Savvy ZF people will say, "Oh, but it has a nesting depth setting.", not what I'm talking about. The next thing that needs to change: only large chunks of data need to be stored in a cache. Tiny pieces of template data which take little time to compute should not be kept in the cache. Entire pages, on the other hand, could be saved in the cache, minus the customer cart side bar and login/logout links.
Subscribe to:
Posts (Atom)