Skip to content

Commit 80aacdb

Browse files
committed
- Patch #1064212 by catch: page caching performance has regressed by 30-40%.
1 parent b3094a0 commit 80aacdb

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

includes/cache.inc

+9-4
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,15 @@ class DrupalDatabaseCache implements DrupalCacheInterface {
325325
try {
326326
// Garbage collection necessary when enforcing a minimum cache lifetime.
327327
$this->garbageCollection($this->bin);
328-
$query = db_select($this->bin);
329-
$query->fields($this->bin, array('cid', 'data', 'created', 'expire', 'serialized'));
330-
$query->condition($this->bin . '.cid', $cids, 'IN');
331-
$result = $query->execute();
328+
329+
// When serving cached pages, the overhead of using db_select() was found
330+
// to add around 30% overhead to the request. Since $this->bin is a
331+
// variable, this means the call to db_query() here uses a concatenated
332+
// string. This is highly discouraged under any other circumstances, and
333+
// is used here only due to the performance overhead we would incur
334+
// otherwise. When serving an uncached page, the overhead of using
335+
// db_select() is a much smaller proportion of the request.
336+
$result = db_query('SELECT cid, data, created, expire, serialized FROM {' . db_escape_table($this->bin) . '} WHERE cid IN (:cids)', array(':cids' => $cids));
332337
$cache = array();
333338
foreach ($result as $item) {
334339
$item = $this->prepareItem($item);

includes/module.inc

+3
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ function system_list($type) {
127127
// if not fetch only the required information to fire bootstrap hooks
128128
// in case we are going to serve the page from cache.
129129
if ($type == 'bootstrap') {
130+
if (isset($lists['bootstrap'])) {
131+
return $lists['bootstrap'];
132+
}
130133
if ($cached = cache_get('bootstrap_modules', 'cache_bootstrap')) {
131134
$bootstrap_list = $cached->data;
132135
}

modules/system/system.api.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2552,7 +2552,7 @@ function hook_file_load($files) {
25522552
*
25532553
* @see file_validate()
25542554
*/
2555-
function hook_file_validate(&$file) {
2555+
function hook_file_validate($file) {
25562556
$errors = array();
25572557

25582558
if (empty($file->filename)) {

0 commit comments

Comments
 (0)