Improved job pickup time stats for delayed jobs
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 1 Jul 2015 19:30:06 +0000 (12:30 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Wed, 1 Jul 2015 21:00:09 +0000 (21:00 +0000)
* The delay time should not count

Bug: T102743
Change-Id: I9e8b1f33b65681fd9f4f667233bce280bf6f227d

includes/jobqueue/Job.php
includes/jobqueue/JobRunner.php

index f7ef8a9..3e23391 100644 (file)
@@ -144,6 +144,14 @@ abstract class Job implements IJobSpecification {
                        : null;
        }
 
+       /**
+        * @return int|null UNIX timestamp of when the job was runnable, or null
+        * @since 1.26
+        */
+       public function getReadyTimestamp() {
+               return $this->getReleaseTimestamp() ?: $this->getQueuedTimestamp();
+       }
+
        /**
         * Whether the queue should reject insertion of this job if a duplicate exists
         *
index 3dfffae..3982134 100644 (file)
@@ -199,10 +199,10 @@ class JobRunner implements LoggerAwareInterface {
                                $timeMsTotal += $timeMs;
                                $profiler->scopedProfileOut( $psection );
 
-                               $queuedTs = $job->getQueuedTimestamp();
-                               if ( $queuedTs ) {
+                               $readyTs = $job->getReadyTimestamp();
+                               if ( $readyTs ) {
                                        // Record time to run for the job type
-                                       $pickupDelay = $popTime - $queuedTs;
+                                       $pickupDelay = $popTime - $readyTs;
                                        $stats->timing( 'jobqueue.pickup_delay.all', $pickupDelay );
                                        $stats->timing( "jobqueue.pickup_delay.$jType", $pickupDelay );
                                }