[development] Increase performance of caching

Jeff Fillmore jfillmore at sublimenet.com
Mon Apr 30 17:22:04 UTC 2007

Dear Developers,


            I’ve been working with a few modifications to the caching system of Drupal, and have found a simple way to speed it up by about 5% across the board ( more with pages that use the cache system more) with only adding five lines of code.  


            I found that Drupal was calling the cache table multiple times to get the same data so I put the data in a static array.  

At the top of cache_get function in includes/cache.inc I added these four lines on line 15:


static $cache_array = array();

if ($cache_array[$key] != null){

                        return $cache_array[$key];



            Right before $cache is returned I added this line on line 45:




I am sure there are lots of other ways to do this, but the reason that I modified the core code directly is that I felt that this type of increase should not a matter of adding a new module, if it is even possible with another module. Although this will increase the overall size of the apache children during runtime I felt that it was a small price for the speed of the application and overall user throughput. Also are there any other places that we could do something similar. For instance cache the menus in memory for the ‘drupal_lookup_path’ for instance. 


Because this is in the caching for registered and anonymous users the benefit is across the board. Although the increase will diminish over the size of the site, it should be a rather substantial increase for about 70-80% of the drupal installs out there.


I am curious to hear feedback as to what you guys think of this addition, and the overall speed increase and offsets. And potentially other increases that would be of similar avenues and if we should pursue them.





Jeff Fillmore

HYPERLINK "mailto:jfillmore at sublimenet.com"jfillmore at sublimenet.com

Sublimenet INC


No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.467 / Virus Database: 269.6.2/781 - Release Date: 4/30/2007 9:14 AM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20070430/b20e7359/attachment.htm 

More information about the development mailing list