jenkins-bot has submitted this change and it was merged. Change subject: Make the percentile threshold for slow function stats configurable ......................................................................
Make the percentile threshold for slow function stats configurable Introduce $wgScribuntoSlowFunctionThreshold, which is a float value between 0 and 1 (defaults to 0.9), specifying the percentile threshold for slow function invocation reporting. Change-Id: I3bd862347c21ba68d2f2f0729a834c4f7be3cd43 --- M Scribunto.php M common/Hooks.php 2 files changed, 18 insertions(+), 5 deletions(-) Approvals: Tim Starling: Looks good to me, approved jenkins-bot: Verified diff --git a/Scribunto.php b/Scribunto.php index e9f83a5..49961cf 100644 --- a/Scribunto.php +++ b/Scribunto.php @@ -188,6 +188,13 @@ */ $wgScribuntoGatherFunctionStats = false; +/** + * If $wgScribuntoGatherFunctionStats is true, this variable specifies + * the percentile threshold for slow function invocations. Should be + * a value between 0 and 1 (exclusive). + */ +$wgScribuntoSlowFunctionThreshold = 0.90; + define( 'NS_MODULE', 828 ); define( 'NS_MODULE_TALK', 829 ); diff --git a/common/Hooks.php b/common/Hooks.php index 508250e..945aad3 100644 --- a/common/Hooks.php +++ b/common/Hooks.php @@ -176,9 +176,14 @@ * @param int $timing Function execution time in milliseconds. */ public static function reportTiming( $moduleName, $functionName, $timing ) { - global $wgScribuntoGatherFunctionStats; + global $wgScribuntoGatherFunctionStats, $wgScribuntoSlowFunctionThreshold; if ( !$wgScribuntoGatherFunctionStats ) { + return; + } + + $threshold = $wgScribuntoSlowFunctionThreshold; + if ( !( is_float( $threshold ) && $threshold > 0 && $threshold < 1 ) ) { return; } @@ -189,19 +194,20 @@ } // To control the sampling rate, we keep a compact histogram of - // observations in APC, and extract the 99th percentile. We need - // APC and \RunningStat\PSquare to do that. + // observations in APC, and extract the Nth percentile (specified + // via $wgScribuntoSlowFunctionThreshold; defaults to 0.90). + // We need APC and \RunningStat\PSquare to do that. if ( !class_exists( '\RunningStat\PSquare' ) || $cache instanceof EmptyBagOStuff ) { return; } - $key = $cache->makeGlobalKey( __METHOD__ ); + $key = $cache->makeGlobalKey( __METHOD__, $threshold ); // This is a classic "read-update-write" critical section with no // mutual exclusion, but the only consequence is that some samples // will be dropped. We only need enough samples to estimate the // the shape of the data, so that's fine. - $ps = $cache->get( $key ) ?: new \RunningStat\PSquare( 0.99 ); + $ps = $cache->get( $key ) ?: new \RunningStat\PSquare( $threshold ); $ps->addObservation( $timing ); $cache->set( $key, $ps, 60 ); -- To view, visit https://gerrit.wikimedia.org/r/249915 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I3bd862347c21ba68d2f2f0729a834c4f7be3cd43 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/Scribunto Gerrit-Branch: master Gerrit-Owner: Ori.livneh <o...@wikimedia.org> Gerrit-Reviewer: Anomie <bjor...@wikimedia.org> Gerrit-Reviewer: Jackmcbarn <jackmcb...@gmail.com> Gerrit-Reviewer: Tim Starling <tstarl...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits