$this->debugCallback( $msg );
// Run the job...
+ $rssStart = $this->getMaxRssKb();
$jobStartTime = microtime( true );
try {
$status = $job->run();
// Clear out title cache data from prior snapshots
LinkCache::singleton()->clear();
$timeMs = intval( ( microtime( true ) - $jobStartTime ) * 1000 );
+ $rssEnd = $this->getMaxRssKb();
// Record how long jobs wait before getting popped
$readyTs = $job->getReadyTimestamp();
}
// Track the execution time for jobs
$stats->timing( "jobqueue.run.$jType", $timeMs );
+ // Track RSS increases for jobs (in case of memory leaks)
+ if ( $rssStart && $rssEnd ) {
+ $stats->increment( "jobqueue.rss_delta.$jType", $rssEnd - $rssStart );
+ }
if ( $status === false ) {
$msg = $job->toString() . " t=$timeMs error={$error}";
return array( 'status' => $status, 'error' => $error, 'timeMs' => $timeMs );
}
+ /**
+ * @return int|null Max memory RSS in kilobytes
+ */
+ private function getMaxRssKb() {
+ $info = wfGetRusage() ?: array();
+ // see http://linux.die.net/man/2/getrusage
+ return isset( $info['ru_maxrss'] ) ? (int)$info['ru_maxrss'] : null;
+ }
+
/**
* @param Job $job
* @return int Seconds for this runner to avoid doing more jobs of this type