From: addshore Date: Thu, 24 Jan 2019 16:58:04 +0000 (+0100) Subject: parser: Add new pcache metrics, split by page content model X-Git-Tag: 1.34.0-rc.0~2845^2 X-Git-Url: http://git.cyclocoop.org/data/%24oldEdit?a=commitdiff_plain;h=bc86b698cd55c99704143a86bbb637d2aac1b434;p=lhc%2Fweb%2Fwiklou.git parser: Add new pcache metrics, split by page content model Change-Id: I31c3c5b863309ffcc4424c43891b577b3fb7a753 --- diff --git a/includes/parser/ParserCache.php b/includes/parser/ParserCache.php index 43c72b18f8..ce7ae1328a 100644 --- a/includes/parser/ParserCache.php +++ b/includes/parser/ParserCache.php @@ -145,6 +145,19 @@ class ParserCache { return is_object( $value ) ? $value : false; } + /** + * @param WikiPage $article + * @param string $metricSuffix + */ + private function incrementStats( $article, $metricSuffix ) { + // old style global metric (can be removed once no longer used) + wfIncrStats( 'pcache.' . $metricSuffix ); + // new per content model metric + $contentModel = str_replace( '.', '_', $article->getContentModel() ); + $metricSuffix = str_replace( '.', '_', $metricSuffix ); + wfIncrStats( 'pcache.' . $contentModel . '.' . $metricSuffix ); + } + /** * Generates a key for caching the given article considering * the given parser options. @@ -181,7 +194,7 @@ class ParserCache { $this->getOptionsKey( $article ), $casToken, BagOStuff::READ_VERIFIED ); if ( $optionsKey instanceof CacheTime ) { if ( $useOutdated < self::USE_EXPIRED && $optionsKey->expired( $article->getTouched() ) ) { - wfIncrStats( "pcache.miss.expired" ); + $this->incrementStats( $article, "miss.expired" ); $cacheTime = $optionsKey->getCacheTime(); wfDebugLog( "ParserCache", "Parser options key expired, touched " . $article->getTouched() @@ -190,7 +203,7 @@ class ParserCache { } elseif ( $useOutdated < self::USE_OUTDATED && $optionsKey->isDifferentRevision( $article->getLatest() ) ) { - wfIncrStats( "pcache.miss.revid" ); + $this->incrementStats( $article, "miss.revid" ); $revId = $article->getLatest(); $cachedRevId = $optionsKey->getCacheRevisionId(); wfDebugLog( "ParserCache", @@ -238,7 +251,7 @@ class ParserCache { $useOutdated ? self::USE_OUTDATED : self::USE_CURRENT_ONLY ); if ( $parserOutputKey === false ) { - wfIncrStats( 'pcache.miss.absent' ); + $this->incrementStats( $article, 'miss.absent' ); return false; } @@ -247,7 +260,7 @@ class ParserCache { $value = $this->mMemc->get( $parserOutputKey, $casToken, BagOStuff::READ_VERIFIED ); if ( !$value ) { wfDebug( "ParserOutput cache miss.\n" ); - wfIncrStats( "pcache.miss.absent" ); + $this->incrementStats( $article, "miss.absent" ); return false; } @@ -258,14 +271,14 @@ class ParserCache { : $article; if ( !$useOutdated && $value->expired( $touched ) ) { - wfIncrStats( "pcache.miss.expired" ); + $this->incrementStats( $article, "miss.expired" ); $cacheTime = $value->getCacheTime(); wfDebugLog( "ParserCache", "ParserOutput key expired, touched $touched, " . "epoch {$this->cacheEpoch}, cached $cacheTime\n" ); $value = false; } elseif ( !$useOutdated && $value->isDifferentRevision( $article->getLatest() ) ) { - wfIncrStats( "pcache.miss.revid" ); + $this->incrementStats( $article, "miss.revid" ); $revId = $article->getLatest(); $cachedRevId = $value->getCacheRevisionId(); wfDebugLog( "ParserCache", @@ -275,13 +288,13 @@ class ParserCache { } elseif ( Hooks::run( 'RejectParserCacheValue', [ $value, $wikiPage, $popts ] ) === false ) { - wfIncrStats( 'pcache.miss.rejected' ); + $this->incrementStats( $article, 'miss.rejected' ); wfDebugLog( "ParserCache", "ParserOutput key valid, but rejected by RejectParserCacheValue hook handler.\n" ); $value = false; } else { - wfIncrStats( "pcache.hit" ); + $this->incrementStats( $article, "hit" ); } return $value;