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:
$cache_array[$key]=$cache;
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.
Thanks
Sublimenet INC
208-323-9451