From 110450d73cbdba507ead62142cc8a5b3e0e41257 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 17 Apr 2013 21:50:34 -0700 Subject: [PATCH] Wrap job execution around profiling calls. Change-Id: Idf184b7c2f7003032d3a28830ee9c4a1eaeaa98b --- includes/Wiki.php | 4 +++- includes/job/jobs/RefreshLinksJob.php | 9 --------- maintenance/runJobs.php | 2 ++ 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/includes/Wiki.php b/includes/Wiki.php index f8f699c91c..b9a7aac8ee 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -621,11 +621,13 @@ class MediaWiki { if ( $job ) { $output = $job->toString() . "\n"; $t = - microtime( true ); + wfProfileIn( __METHOD__ . '-' . get_class( $job ) ); $success = $job->run(); + wfProfileOut( __METHOD__ . '-' . get_class( $job ) ); $group->ack( $job ); // done $t += microtime( true ); $t = round( $t * 1000 ); - if ( !$success ) { + if ( $success === false ) { $output .= "Error: " . $job->getLastError() . ", Time: $t ms\n"; } else { $output .= "Success, Time: $t ms\n"; diff --git a/includes/job/jobs/RefreshLinksJob.php b/includes/job/jobs/RefreshLinksJob.php index 9dbe82786f..d096da66c0 100644 --- a/includes/job/jobs/RefreshLinksJob.php +++ b/includes/job/jobs/RefreshLinksJob.php @@ -37,14 +37,11 @@ class RefreshLinksJob extends Job { * @return boolean success */ function run() { - wfProfileIn( __METHOD__ ); - $linkCache = LinkCache::singleton(); $linkCache->clear(); if ( is_null( $this->title ) ) { $this->error = "refreshLinks: Invalid title"; - wfProfileOut( __METHOD__ ); return false; } @@ -59,13 +56,11 @@ class RefreshLinksJob extends Job { if ( !$revision ) { $this->error = 'refreshLinks: Article not found "' . $this->title->getPrefixedDBkey() . '"'; - wfProfileOut( __METHOD__ ); return false; // XXX: what if it was just deleted? } self::runForTitleInternal( $this->title, $revision, __METHOD__ ); - wfProfileOut( __METHOD__ ); return true; } @@ -123,14 +118,11 @@ class RefreshLinksJob2 extends Job { function run() { global $wgUpdateRowsPerJob; - wfProfileIn( __METHOD__ ); - $linkCache = LinkCache::singleton(); $linkCache->clear(); if ( is_null( $this->title ) ) { $this->error = "refreshLinks2: Invalid title"; - wfProfileOut( __METHOD__ ); return false; } @@ -181,7 +173,6 @@ class RefreshLinksJob2 extends Job { JobQueueGroup::singleton()->push( $jobs ); } - wfProfileOut( __METHOD__ ); return true; } diff --git a/maintenance/runJobs.php b/maintenance/runJobs.php index ef80df5bc7..1f48ffe486 100644 --- a/maintenance/runJobs.php +++ b/maintenance/runJobs.php @@ -95,6 +95,7 @@ class RunJobs extends Maintenance { // Run the job... $t = microtime( true ); + wfProfileIn( __METHOD__ . '-' . get_class( $job ) ); try { $status = $job->run(); $error = $job->getLastError(); @@ -102,6 +103,7 @@ class RunJobs extends Maintenance { $status = false; $error = get_class( $e ) . ': ' . $e->getMessage(); } + wfProfileOut( __METHOD__ . '-' . get_class( $job ) ); $timeMs = intval( ( microtime( true ) - $t ) * 1000 ); // Mark the job as done on success or when the job cannot be retried -- 2.20.1