[Mediawiki-l] system messages at ParserFirstCallInit time = slow?

Daniel Barrett danb at VistaPrint.com
Mon Aug 8 16:50:58 UTC 2011


I have a parser tag <foo> that does its setup with the ParserFirstCallInit hook (MW 1.17.0):

      $wgHooks['ParserFirstCallInit'][] = 'efFoo';
      function efFoo(&$parser) {
        foreach ($lotsOfStuff as $stuff) {
          // do stuff...
        }
      }

The callback seemed to be slowing down all wiki pages, so I dug into it and discovered something surprising (to me).  50% of the time in the loop is spent processing three wfMsg() calls:

      function efFoo(&$parser) {
        ...
        foreach ($lotsOfStuff as $stuff) {
          ...
          $one = wfMsg('one');
          $two = wfMsg('two');
          $three = wfMsg('three');
          ...
        }
      }

Is wfMsg() usually slow like this?  We are specifying the system message cache in LocalSettings.php before my extension is included, so I thought this would make wfMsg() faster:

      $wgMainCacheType = CACHE_ACCEL;
      $wgCacheDirectory = '/var/cache/mediawiki';

Maybe the cache isn't set up yet at ParserFirstCallInit time? Any insight appreciated. Thanks!
DanB





More information about the MediaWiki-l mailing list