objectcache: add regen_walltime metric to WANObjectCache::getWithSetCallback()
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 12 Jul 2019 18:24:51 +0000 (11:24 -0700)
committerKrinkle <krinklemail@gmail.com>
Sun, 14 Jul 2019 17:08:44 +0000 (17:08 +0000)
Change-Id: I7918a6ed7a5d3d845c640aeeb78c88f1345f5157

includes/libs/objectcache/README.md
includes/libs/objectcache/WANObjectCache.php

index 833c045..42bf636 100644 (file)
@@ -35,6 +35,14 @@ in sending the value to the backend server.
 * Type: Measure (in milliseconds).
 * Variable `kClass`: The first part of your cache key.
 
+#### `wanobjectcache.{kClass}.regen_walltime`
+
+Upon cache miss, this measures the time spent in `WANObjectCache::getWithSetCallback()`
+from the start of the callback to right after the new value has been computed.
+
+* Type: Measure (in milliseconds).
+* Variable `kClass`: The first part of your cache key.
+
 #### `wanobjectcache.{kClass}.ck_touch.{result}`
 
 Call counter from `WANObjectCache::touchCheckKey()`.
index 45caa78..07e4fad 100644 (file)
@@ -1423,6 +1423,7 @@ class WANObjectCache implements IExpiringStore, IStoreKeyEncoder, LoggerAwareInt
                ) {
                        // How long it took to generate the value
                        $walltime = max( $postCallbackTime - $preCallbackTime, 0.0 );
+                       $this->stats->timing( "wanobjectcache.$kClass.regen_walltime", 1e3 * $walltime );
                        // If the key is write-holed then use the (volatile) interim key as an alternative
                        if ( $isKeyTombstoned ) {
                                $this->setInterimValue( $key, $value, $lockTSE, $version, $walltime );