From 830e9159703193dc0ca37a2fc8d2b9d580eb1f8d Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 19 Aug 2004 08:44:13 +0000 Subject: [PATCH] Add some more profiling points --- includes/MessageCache.php | 17 ++++++++++++++++- includes/Parser.php | 7 ++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/includes/MessageCache.php b/includes/MessageCache.php index 7ff37787b3..059af8d31d 100755 --- a/includes/MessageCache.php +++ b/includes/MessageCache.php @@ -16,6 +16,8 @@ class MessageCache 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; @@ -24,10 +26,15 @@ class MessageCache $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 @@ -40,11 +47,14 @@ class MessageCache 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 ) { @@ -53,12 +63,16 @@ class MessageCache # 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" ); @@ -85,6 +99,7 @@ class MessageCache $this->mCache = false; } } + wfProfileOut( $fname ); return $success; } diff --git a/includes/Parser.php b/includes/Parser.php index 205b1bfb71..4af863313e 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -2669,7 +2669,9 @@ class ParserOptions # 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 ); @@ -2682,12 +2684,15 @@ class ParserOptions $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 ); } -- 2.20.1