r45068 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45067‎ | r45068 | r45069 >
Date:07:07, 27 December 2008
Author:aaron
Status:ok (Comments)
Tags:
Comment:
* Move filecache hits to faster lower level index.php code
* Disable outputpage after file cache hit, since output was streamed already.
Modified paths:
  • /trunk/phase3/includes/Wiki.php (modified) (history)
  • /trunk/phase3/index.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Wiki.php
@@ -111,7 +111,6 @@
112112 // about the possible different language variants
113113 if( count( $wgContLang->getVariants() ) > 1 && !is_null( $ret ) && $ret->getArticleID() == 0 )
114114 $wgContLang->findVariantLink( $title, $ret );
115 -
116115 }
117116 if( ( $oldid = $wgRequest->getInt( 'oldid' ) )
118117 && ( is_null( $ret ) || $ret->getNamespace() != NS_SPECIAL ) ) {
@@ -221,25 +220,6 @@
222221 /* actions that need to be made when we have a special pages */
223222 SpecialPage::executePath( $title );
224223 } else {
225 - /* Try low-level file cache hit */
226 - if( $title->getNamespace() != NS_MEDIAWIKI && HTMLFileCache::useFileCache() ) {
227 - $cache = new HTMLFileCache( $title );
228 - if( $cache->isFileCacheGood( /* Assume up to date */ ) ) {
229 - global $wgOut;
230 - /* Check incoming headers to see if client has this cached */
231 - if( !$wgOut->checkLastModified( $cache->fileCacheTime() ) ) {
232 - wfDebug( "MediaWiki::initializeSpecialCases(): about to load file cache\n" );
233 - $cache->loadFromFileCache();
234 - # Tell $wgOut that output is taken care of
235 - $wgOut->disable();
236 - # Do any stats increment/watchlist stuff
237 - $article = self::articleFromTitle( $title );
238 - $article->viewUpdates();
239 - }
240 - wfProfileOut( __METHOD__ );
241 - return true;
242 - }
243 - }
244224 /* No match to special cases */
245225 wfProfileOut( __METHOD__ );
246226 return false;
Index: trunk/phase3/index.php
@@ -67,13 +67,35 @@
6868 #
6969 if( $wgUseAjax && $action == 'ajax' ) {
7070 require_once( $IP . '/includes/AjaxDispatcher.php' );
71 -
7271 $dispatcher = new AjaxDispatcher();
7372 $dispatcher->performAction();
7473 $mediaWiki->restInPeace();
7574 exit;
7675 }
7776
 77+if( $wgUseFileCache && isset($wgTitle) ) {
 78+ wfProfileIn( 'main-try-filecache' );
 79+ if( HTMLFileCache::useFileCache() ) {
 80+ /* Try low-level file cache hit */
 81+ $cache = new HTMLFileCache( $wgTitle );
 82+ if( $cache->isFileCacheGood( /* Assume up to date */ ) ) {
 83+ /* Check incoming headers to see if client has this cached */
 84+ if( !$wgOut->checkLastModified( $cache->fileCacheTime() ) ) {
 85+ $cache->loadFromFileCache();
 86+ # Do any stats increment/watchlist stuff
 87+ $wgArticle = self::articleFromTitle( $wgTitle );
 88+ $wgArticle->viewUpdates();
 89+ }
 90+ # Tell $wgOut that output is taken care of
 91+ $wgOut->disable();
 92+ wfProfileOut( 'main-try-filecache' );
 93+ $mediaWiki->restInPeace();
 94+ exit;
 95+ }
 96+ }
 97+ wfProfileOut( 'main-try-filecache' );
 98+}
 99+
78100 # Setting global variables in mediaWiki
79101 $mediaWiki->setVal( 'action', $action );
80102 $mediaWiki->setVal( 'CommandLineMode', $wgCommandLineMode );
@@ -89,7 +111,7 @@
90112 $mediaWiki->setVal( 'UsePathInfo', $wgUsePathInfo );
91113
92114 $mediaWiki->initialize( $wgTitle, $wgArticle, $wgOut, $wgUser, $wgRequest );
93 -$mediaWiki->finalCleanup ( $wgDeferredUpdateList, $wgOut );
 115+$mediaWiki->finalCleanup( $wgDeferredUpdateList, $wgOut );
94116
95117 # Not sure when $wgPostCommitUpdateList gets set, so I keep this separate from finalCleanup
96118 $mediaWiki->doUpdates( $wgPostCommitUpdateList );

Comments

#Comment by Brion VIBBER (talk | contribs)   18:44, 31 December 2008

Ok for now, though I'd recommend a couple directions to consider for the future...

Generally we should treat the file cache as kind of like a front-end HTTP proxy cache; since that's a case we actively test ;) it might be good to make sure that our checks (eg in HTMLFileCache::useFileCache()) are as similar as possible to what would trigger a Squid hit.

I'm also still leery of an early 'exit' call on general principle; it'd be good if we can avoid that.

Status & tagging log