r76998 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76997‎ | r76998 | r76999 >
Date:01:40, 19 November 2010
Author:tstarling
Status:ok
Tags:
Comment:
Use wfGetCache( CACHE_ANYTHING ) instead of $wgMemc to store the result of ResourceLoader::filter(). Speeds up cold cache view of the main page on a non-APC default installation by a factor of 2.3 (measured using siege, no concurrency, URL list captured from Firefox, server = my laptop).
Modified paths:
  • /trunk/phase3/includes/resourceloader/ResourceLoader.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/resourceloader/ResourceLoader.php
@@ -119,8 +119,6 @@
120120 * @return String: Filtered data
121121 */
122122 protected function filter( $filter, $data ) {
123 - global $wgMemc;
124 -
125123 wfProfileIn( __METHOD__ );
126124
127125 // For empty/whitespace-only data or for unknown filters, don't perform
@@ -132,9 +130,11 @@
133131 return $data;
134132 }
135133
136 - // Try for Memcached hit
 134+ // Try for cache hit
 135+ // Use CACHE_ANYTHING since filtering is very slow compared to DB queries
137136 $key = wfMemcKey( 'resourceloader', 'filter', $filter, md5( $data ) );
138 - $cacheEntry = $wgMemc->get( $key );
 137+ $cache = wfGetCache( CACHE_ANYTHING );
 138+ $cacheEntry = $cache->get( $key );
139139 if ( is_string( $cacheEntry ) ) {
140140 wfProfileOut( __METHOD__ );
141141 return $cacheEntry;
@@ -159,7 +159,7 @@
160160 }
161161
162162 // Save filtered text to Memcached
163 - $wgMemc->set( $key, $result );
 163+ $cache->set( $key, $result );
164164
165165 wfProfileOut( __METHOD__ );
166166

Status & tagging log