From 0f1ffa4da707217ab2dc1efae68c8ced24500548 Mon Sep 17 00:00:00 2001 From: Ori Livneh Date: Mon, 18 Apr 2016 18:13:08 -0700 Subject: [PATCH] Segment stash edit cache stats by basis for hit/miss Instead of just counting cache hits and misses, segment the counts by reason, so we can differentiate (for example) timestamp-based cache hits from staleness-check-survivor cache hits. I want this data so I can determine whether increasing the cutoff for timestamp-based hits from 3 to 5 seconds has a substantial enough impact to warrant the slightly weaker consistency. Also changed 'cache-hit' to 'cache_hit'. MediaWiki normalizes the dash to an underscore anyway, but the normalization is there for dynamically-constructed key names (or name segments). In the case of hard-coded values, it is desirable for the code to be as close as possible to the final form of the metric name, to simplify metric lookup. Change-Id: I0cd61da9746e3ca3695e23200f698b8b1371798c --- includes/api/ApiStashEdit.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/includes/api/ApiStashEdit.php b/includes/api/ApiStashEdit.php index 3c02c9ce63..cc8e39079f 100644 --- a/includes/api/ApiStashEdit.php +++ b/includes/api/ApiStashEdit.php @@ -272,18 +272,18 @@ class ApiStashEdit extends ApiBase { } $timeMs = 1000 * max( 0, microtime( true ) - $start ); - $stats->timing( 'editstash.lock-wait-time', $timeMs ); + $stats->timing( 'editstash.lock_wait_time', $timeMs ); } if ( !is_object( $editInfo ) || !$editInfo->output ) { - $stats->increment( 'editstash.cache-misses' ); + $stats->increment( 'editstash.cache_misses.no_stash' ); $logger->debug( "No cache value for key '$key'." ); return false; } $time = wfTimestamp( TS_UNIX, $editInfo->output->getTimestamp() ); if ( ( time() - $time ) <= 3 ) { - $stats->increment( 'editstash.cache-hits' ); + $stats->increment( 'editstash.cache_hits.presumed_fresh' ); $logger->debug( "Timestamp-based cache hit for key '$key'." ); return $editInfo; // assume nothing changed } @@ -312,7 +312,7 @@ class ApiStashEdit extends ApiBase { } if ( $changed || $res->numRows() != $templateUses ) { - $stats->increment( 'editstash.cache-misses' ); + $stats->increment( 'editstash.cache_misses.proven_stale' ); $logger->info( "Stale cache for key '$key'; template changed." ); return false; } @@ -336,13 +336,13 @@ class ApiStashEdit extends ApiBase { } if ( $changed || $res->numRows() != count( $files ) ) { - $stats->increment( 'editstash.cache-misses' ); + $stats->increment( 'editstash.cache_misses.proven_stale' ); $logger->info( "Stale cache for key '$key'; file changed." ); return false; } } - $stats->increment( 'editstash.cache-hits' ); + $stats->increment( 'editstash.cache_hits.proven_fresh' ); $logger->debug( "Cache hit for key '$key'." ); return $editInfo; -- 2.20.1