r83617 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83616‎ | r83617 | r83618 >
Date:00:00, 10 March 2011
Author:tstarling
Status:resolved (Comments)
Tags:
Comment:
* Add a $count argument to wfIncrStats(), to allow it to increase the count by more than one at a time.
* Added stats to job insert and pop.
* Formalised live patch for UDP stats aggregation, adding $wgAggregateStatsID.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/job/JobQueue.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -2071,15 +2071,20 @@
20722072 /**
20732073 * Increment a statistics counter
20742074 */
2075 -function wfIncrStats( $key ) {
 2075+function wfIncrStats( $key, $count = 1 ) {
20762076 global $wgStatsMethod;
20772077
 2078+ $count = intval( $count );
 2079+
20782080 if( $wgStatsMethod == 'udp' ) {
2079 - global $wgUDPProfilerHost, $wgUDPProfilerPort, $wgDBname;
 2081+ global $wgUDPProfilerHost, $wgUDPProfilerPort, $wgDBname, $wgAggregateStatsID;
20802082 static $socket;
 2083+
 2084+ $id = $wgAggregateStatsID !== false ? $wgAggregateStatsID : $wgDBname;
 2085+
20812086 if ( !$socket ) {
20822087 $socket = socket_create( AF_INET, SOCK_DGRAM, SOL_UDP );
2083 - $statline = "stats/{$wgDBname} - 1 1 1 1 1 -total\n";
 2088+ $statline = "stats/{$id} - {$count} 1 1 1 1 -total\n";
20842089 socket_sendto(
20852090 $socket,
20862091 $statline,
@@ -2089,7 +2094,7 @@
20902095 $wgUDPProfilerPort
20912096 );
20922097 }
2093 - $statline = "stats/{$wgDBname} - 1 1 1 1 1 {$key}\n";
 2098+ $statline = "stats/{$id} - {$count} 1 1 1 1 {$key}\n";
20942099 wfSuppressWarnings();
20952100 socket_sendto(
20962101 $socket,
@@ -2103,8 +2108,8 @@
21042109 } elseif( $wgStatsMethod == 'cache' ) {
21052110 global $wgMemc;
21062111 $key = wfMemcKey( 'stats', $key );
2107 - if ( is_null( $wgMemc->incr( $key ) ) ) {
2108 - $wgMemc->add( $key, 1 );
 2112+ if ( is_null( $wgMemc->incr( $key, $count ) ) ) {
 2113+ $wgMemc->add( $key, $count );
21092114 }
21102115 } else {
21112116 // Disabled
Index: trunk/phase3/includes/job/JobQueue.php
@@ -74,6 +74,7 @@
7575 return false;
7676 }
7777
 78+ wfIncrStats( 'job-pop' );
7879 $namespace = $row->job_namespace;
7980 $dbkey = $row->job_title;
8081 $title = Title::makeTitleSafe( $namespace, $dbkey );
@@ -163,6 +164,7 @@
164165
165166 // If execution got to here, there's a row in $row that has been deleted from the database
166167 // by this thread. Hence the concurrent pop was successful.
 168+ wfIncrStats( 'job-pop' );
167169 $namespace = $row->job_namespace;
168170 $dbkey = $row->job_title;
169171 $title = Title::makeTitleSafe( $namespace, $dbkey );
@@ -238,6 +240,7 @@
239241 }
240242 }
241243 if ( $rows ) {
 244+ wfIncrStats( 'job-insert', count( $rows ) );
242245 $dbw->begin();
243246 $dbw->insert( 'job', $rows, __METHOD__, 'IGNORE' );
244247 $dbw->commit();
@@ -280,6 +283,7 @@
281284 return;
282285 }
283286 }
 287+ wfIncrStats( 'job-insert' );
284288 return $dbw->insert( 'job', $fields, __METHOD__ );
285289 }
286290
Index: trunk/phase3/includes/DefaultSettings.php
@@ -3940,6 +3940,14 @@
39413941 */
39423942 $wgStatsMethod = 'cache';
39433943
 3944+/**
 3945+ * When $wgStatsMethod is 'udp', setting this to a string allows statistics to
 3946+ * be aggregated over more than one wiki. The string will be used in place of
 3947+ * the DB name in outgoing UDP packets. If this is set to false, the DB name
 3948+ * will be used.
 3949+ */
 3950+$wgAggregateStatsID = false;
 3951+
39443952 /** Whereas to count the number of time an article is viewed.
39453953 * Does not work if pages are cached (for example with squid).
39463954 */
Index: trunk/phase3/RELEASE-NOTES
@@ -94,6 +94,8 @@
9595 * Added UserGetLanguageObject hook to change the language used in $wgLang
9696 * (bug 14645) When $wgMiserMode is on, expensive special pages are styled
9797 differently (italicized by default) on Special:SpecialPages
 98+* Added $wgAggregateStatsID, which allows UDP stats to be aggregated over
 99+ several wikis.
98100
99101 === Bug fixes in 1.18 ===
100102 * (bug 23119) WikiError class and subclasses are now marked as deprecated

Follow-up revisions

RevisionCommit summaryAuthorDate
r83628MFT r83617: job queue statststarling02:18, 10 March 2011
r84228* Fixed wfIncrStats calls from r83617 (I assume this wants the # of jobs added)...aaron07:06, 18 March 2011

Comments

#Comment by Aaron Schulz (talk | contribs)   07:55, 17 March 2011

+wfIncrStats( 'job-insert', count( $rows ) )

This only counts (#jobs mod 50), is that what it was meant to do?

Status & tagging log