r46725 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46724‎ | r46725 | r46726 >
Date:19:29, 2 February 2009
Author:werdna
Status:reverted (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

Follow-up revisions

RevisionCommit summaryAuthorDate
r46738Revert r46725, r46726 "Cache cite <references /> output by contents. That way...brion21:49, 2 February 2009
r46756Re-implementation of r46725 (caching of Cite <references /> output)....werdna04:58, 3 February 2009

Comments

#Comment by Jelte (talk | contribs)   19:39, 2 February 2009

Will the -block still re-render when templates or page status(red/blue links) change?

#Comment by Werdna (talk | contribs)   19:45, 2 February 2009

I don't think so, no. I'm not sure how this could be improved.

#Comment by Brion VIBBER (talk | contribs)   19:51, 2 February 2009

Short of separately tracking the reference contents to allow selective purging, I don't see a really good way of handling this either. It's an acceptable CPU compromise for now...

#Comment by Midom (talk | contribs)   19:45, 2 February 2009

thats the idea not to.

#Comment by P.Copp (talk | contribs)   21:08, 2 February 2009

Err.. How would that work for anything that depends on parser state, like strip markers?

#Comment by Brion VIBBER (talk | contribs)   21:31, 2 February 2009

Fatally broken -- strip marker issues

#Comment by Brion VIBBER (talk | contribs)   21:38, 2 February 2009

Has been removed from live update.

#Comment by Brion VIBBER (talk | contribs)   21:49, 2 February 2009

Reverted in r46738.

Status & tagging log