var $mInitialised = false;
function initialise( &$memCached, $useDB, $expiry, $memcPrefix ) {
+ $fname = "MessageCache::initialise";
+ wfProfileIn( $fname );
$this->mUseCache = !is_null( $memCached );
$this->mMemc = &$memCached;
$this->mDisable = !$useDB;
$this->mMemcKey = "$memcPrefix:messages";
$this->mKeys = false; # initialised on demand
$this->mInitialised = true;
+ wfProfileIn( "$fname-parseropt" );
$this->mParserOptions = ParserOptions::newFromUser( $u=NULL );
+ wfProfileIn( "$fname-parseropt" );
+ wfProfileOut( "$fname-parser" );
$this->mParser = new Parser;
+ wfProfileOut( "$fname-parser" );
$this->load();
+ wfProfileOut( $fname );
}
# Loads messages either from memcached or the database, if not disabled
wfDebug( "MessageCache::load(): disabled\n" );
return true;
}
-
+ $fname = "MessageCache::load";
+ wfProfileIn( $fname );
$success = true;
if ( $this->mUseCache ) {
+ wfProfileIn( "$fname-fromcache" );
$this->mCache = $this->mMemc->get( $this->mMemcKey );
+ wfProfileOut( "$fname-fromcache" );
# If there's nothing in memcached, load all the messages from the database
if ( !$this->mCache ) {
# Other threads don't need to load the messages if another thread is doing it.
$success = $this->mMemc->set( $this->mMemcKey, "loading", MSG_LOAD_TIMEOUT );
if ( $success ) {
+ wfProfileIn( "$fname-load" );
$this->loadFromDB();
+ wfProfileOut( "$fname-load" );
# Save in memcached
# Keep trying if it fails, this is kind of important
+ wfProfileIn( "$fname-save" );
for ( $i=0; $i<20 && !$this->mMemc->set( $this->mMemcKey, $this->mCache, $this->mExpiry ); $i++ ) {
usleep(mt_rand(500000,1500000));
}
+ wfProfileOut( "$fname-save" );
if ( $i == 20 ) {
$this->mMemc->set( $this->mMemcKey, "error", 86400 );
wfDebug( "MemCached set error in MessageCache: restart memcached server!\n" );
$this->mCache = false;
}
}
+ wfProfileOut( $fname );
return $success;
}
# Get user options
function initialiseFromUser( &$userInput ) {
global $wgUseTeX, $wgUseCategoryMagic, $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages;
-
+
+ $fname = "ParserOptions::initialiseFromUser";
+ wfProfileIn( $fname );
if ( !$userInput ) {
$user = new User;
$user->setLoaded( true );
$this->mUseDynamicDates = $wgUseDynamicDates;
$this->mInterwikiMagic = $wgInterwikiMagic;
$this->mAllowExternalImages = $wgAllowExternalImages;
+ wfProfileIn( "$fname-skin" );
$this->mSkin =& $user->getSkin();
+ wfProfileOut( "$fname-skin" );
$this->mDateFormat = $user->getOption( 'date' );
$this->mEditSection = $user->getOption( 'editsection' );
$this->mEditSectionOnRightClick = $user->getOption( 'editsectiononrightclick' );
$this->mNumberHeadings = $user->getOption( 'numberheadings' );
$this->mShowToc = $user->getOption( 'showtoc' );
+ wfProfileOut( $fname );
}