r46754 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46753‎ | r46754 | r46755 >
Date:04:57, 3 February 2009
Author:werdna
Status:deferred (Comments)
Tags:
Comment:
Cache cite <references /> output by contents. That way, changes that don't affect Cite references won't cause a re-parsing of Cite, which is a big CPU hog on Wikimedia.
Modified paths:
  • /trunk/extensions/Cite/Cite_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Cite/Cite_body.php
@@ -360,12 +360,28 @@
361361 $prefix = wfMsgForContentNoTrans( 'cite_references_prefix' );
362362 $suffix = wfMsgForContentNoTrans( 'cite_references_suffix' );
363363 $content = implode( "\n", $ent );
 364+
 365+ // Let's try to cache it.
 366+ $parserInput = $prefix . $content . $suffix;
 367+ global $wgMemc;
 368+ $cacheKey = wfMemcKey( 'citeref', md5($parserInput), $this->mParser->Title()->getArticleID() );
 369+
 370+ wfProfileOut( __METHOD__ .'-entries' );
 371+
 372+ wfProfileIn( __METHOD__.'-cache-get' );
 373+ $ret = $wgMemc->get( $cacheKey );
 374+ wfProfileOut( __METHOD__.'-cache' );
364375
365 - wfProfileOut( __METHOD__ .'-entries' );
366 - wfProfileIn( __METHOD__ .'-parse' );
367 - // Live hack: parse() adds two newlines on WM, can't reproduce it locally -ævar
368 - $ret = rtrim( $this->parse( $prefix . $content . $suffix ), "\n" );
369 - wfProfileOut( __METHOD__ .'-parse' );
 376+ if ( !$ret ) {
 377+ wfProfileIn( __METHOD__ .'-parse' );
 378+
 379+ // Live hack: parse() adds two newlines on WM, can't reproduce it locally -ævar
 380+ $ret = rtrim( $this->parse( $parserInput ), "\n" );
 381+ $wgMemc->set( $cacheKey, $ret, 86400 );
 382+
 383+ wfProfileOut( __METHOD__ .'-parse' );
 384+ }
 385+
370386 wfProfileOut( __METHOD__ );
371387
372388 //done, clean up so we can reuse the group

Comments

#Comment by Aaron Schulz (talk | contribs)   03:57, 5 February 2009

git bug -> reverted in r46756

#Comment by Werdna (talk | contribs)   04:48, 5 February 2009

No, not reverted. Built upon. The bug was that this commit and its two successors should have been one, with that summary.

Status & tagging log