EBernhardson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/279065
Change subject: Collect timing information about pool counter usage
......................................................................
Collect timing information about pool counter usage
We realized we don't have any good information about how pool
counters are utilized. This still doesn't get us what we want, meaning
the size of queue's throughout the day, but it should at least give
partial insight into how long requests are waiting which gives hints
at the size of the backlog.
Change-Id: I7a63da0ec1c53ef5a3ec7e89f23196149e8ca65e
---
M includes/Util.php
1 file changed, 37 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch
refs/changes/65/279065/1
diff --git a/includes/Util.php b/includes/Util.php
index 2861b32..f17bea7 100644
--- a/includes/Util.php
+++ b/includes/Util.php
@@ -99,6 +99,38 @@
}
/**
+ * @param string $type The pool counter type, such as
CirrusSearch-Search
+ * @param bool $isSuccess If the pool counter gave a success, or failed
the request
+ * @return string The key used for collecting timing stats about this
pool counter request
+ */
+ private static function getPoolStatsKey( $type, $isSuccess ) {
+ $pos = strpos( $type, '-' );
+ if ( $pos !== false ) {
+ $type = substr( $type, $pos + 1 );
+ }
+ $postfix = $isSuccess ? 'successMs' : 'failureMs';
+ return "CirrusSearch.poolCounter.$type.$postfix";
+ }
+
+ /**
+ * @param float $startPoolWork The time this pool request started, from
microtime( true )
+ * @param string $type The pool counter type, such as
CirrusSearch-Search
+ * @param bool $isSuccess If the pool counter gave a success, or failed
the request
+ * @param callable $callback The function to wrap
+ * @return callable The original callback wrapped to collect pool
counter stats
+ */
+ private static function wrapWithPoolStats( $startPoolWork, $type,
$isSuccess, $callback ) {
+ return function () use ( $type, $isSuccess, $callback,
$startPoolWork ) {
+ RequestContext::getMain()->getStats()->timing(
+ self::getPoolStatsKey( $type, $isSucess ),
+ intval( 1000 * (microtime( true ) -
$startPoolWork) )
+ );
+
+ return call_user_func_array( $callback, func_get_args()
);
+ };
+ }
+
+ /**
* Wraps the complex pool counter interface to force the single call
pattern
* that Cirrus always uses.
* @param string $type same as type parameter on PoolCounter::factory
@@ -134,6 +166,11 @@
return Status::newFatal(
'cirrussearch-backend-error' );
};
}
+ // wrap some stats collection on the success/failure handlers
+ $startPoolWork = microtime( true );
+ $workCallback = self::wrapWithPoolStats( $startPoolWork, $type,
true, $workCallback );
+ $errorCallback = self::wrapWithPoolStats( $startPoolWork,
$type, false, $errorCallback );
+
$errorHandler = function( $key ) use ( $errorCallback, $user ) {
return function( Status $status ) use ( $errorCallback,
$key, $user ) {
$status = $status->getErrorsArray();
--
To view, visit https://gerrit.wikimedia.org/r/279065
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7a63da0ec1c53ef5a3ec7e89f23196149e8ca65e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits