[PATCH 1/2] testbot: Allow restricting the statistics to the recent past.

Francois Gouget fgouget at codeweavers.com
Thu Feb 8 20:22:44 CST 2018


Over long periods of time (days) and as long as the TestBot can keep
up, the job & task creation rate should be almost identical to the
job and task completion rate (modulo build errors for tasks). But for
short periods (under an hour) they can be significantly different.
Specifically the job and task completion rates are capped by the
TestBot's processing speed, while the job and task creation rates are
not.
This means jobs must be filtered based on their Submitted field when
counting new jobs, and on their Ended field when dealing with completed
jobs.
Rename the job and task counters to newjobs and newtasks to emphasize
that they count new jobs and tasks.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
 testbot/lib/WineTestBot/Activity.pm | 32 +++++++++++++++++++++-----------
 testbot/web/Stats.pl                | 12 ++++++------
 2 files changed, 27 insertions(+), 17 deletions(-)

diff --git a/testbot/lib/WineTestBot/Activity.pm b/testbot/lib/WineTestBot/Activity.pm
index 5122dc36f..df1cc59ff 100644
--- a/testbot/lib/WineTestBot/Activity.pm
+++ b/testbot/lib/WineTestBot/Activity.pm
@@ -43,6 +43,12 @@ sub _UpdateMin($$)
   $_[0] = $_[1] if (!defined $_[0] or $_[1] < $_[0]);
 }
 
+sub max($$)
+{
+  my ($a, $b) = @_;
+  return $a > $b ? $a : $b;
+}
+
 
 =pod
 =over 12
@@ -336,18 +342,20 @@ sub _AddFullStat($$$$;$)
   }
 }
 
-sub GetStatistics($)
+sub GetStatistics($;$)
 {
-  my ($VMs) = @_;
+  my ($VMs, $Seconds) = @_;
 
   my ($GlobalStats, $HostsStats, $VMsStats) = ({}, {}, {});
 
   my @JobTimes;
   my $Jobs = CreateJobs();
+  my $Cutoff = $Seconds ? (time() - $Seconds) : 0;
   foreach my $Job (@{$Jobs->GetItems()})
   {
-    $GlobalStats->{"jobs.count"}++;
-    _UpdateMin($GlobalStats->{start}, $Job->Submitted);
+    my $CountsAsNew = ($Job->Submitted >= $Cutoff);
+    $GlobalStats->{"newjobs.count"}++ if ($CountsAsNew);
+    _UpdateMin($GlobalStats->{start}, max($Cutoff, $Job->Submitted));
 
     my $IsSpecialJob;
     my $Steps = $Job->Steps;
@@ -359,9 +367,11 @@ sub GetStatistics($)
       my $Tasks = $Step->Tasks;
       foreach my $Task (@{$Tasks->GetItems()})
       {
-        $GlobalStats->{"tasks.count"}++;
-        if ($Task->Started and $Task->Ended and
-            $Task->Status !~ /^(?:queued|running|canceled)$/)
+        $GlobalStats->{"newtasks.count"}++ if ($CountsAsNew);
+        next if (!$Task->Ended or $Task->Ended < $Cutoff);
+
+        # $Task->Started should really be set since $Task->Ended is
+        if ($Task->Started and $Task->Status !~ /^(?:queued|running|canceled)$/)
         {
           my $Time = $Task->Ended - $Task->Started;
           _AddFullStat($GlobalStats, "$StepType.time", $Time, undef, $Task);
@@ -383,7 +393,7 @@ sub GetStatistics($)
       }
     }
 
-    if (!$IsSpecialJob and$Job->Ended and
+    if (!$IsSpecialJob and $Job->Ended and $Job->Ended >= $Cutoff and
         $Job->Status !~ /^(?:queued|running|canceled)$/)
     {
       my $Time = $Job->Ended - $Job->Submitted;
@@ -402,7 +412,7 @@ sub GetStatistics($)
     @JobTimes = (); # free early
   }
 
-  my ($Activity, $Counters) = GetActivity($VMs);
+  my ($Activity, $Counters) = GetActivity($VMs, $Seconds);
   $GlobalStats->{"recordgroups.count"} = $Counters->{recordgroups};
   $GlobalStats->{"records.count"} = $Counters->{records};
   foreach my $Group (@$Activity)
@@ -456,14 +466,14 @@ sub GetStatistics($)
         # Note that we cannot simply sum the VMs busy wall clock times to get
         # the host busy wall clock time because this would count periods where
         # more than one VM is busy multiple times.
-        $HostStats->{"busy.elapsed"} += $Group->{end} - $Group->{start};
+        $HostStats->{"busy.elapsed"} += $Group->{end} - max($Cutoff, $Group->{start});
         $IsHostBusy{$Host} = 1;
         $IsGroupBusy = 1;
       }
     }
     if ($IsGroupBusy)
     {
-      $GlobalStats->{"busy.elapsed"} += $Group->{end} - $Group->{start};
+      $GlobalStats->{"busy.elapsed"} += $Group->{end} - max($Cutoff, $Group->{start});
     }
   }
 
diff --git a/testbot/web/Stats.pl b/testbot/web/Stats.pl
index 9db2ad377..51a72278e 100644
--- a/testbot/web/Stats.pl
+++ b/testbot/web/Stats.pl
@@ -206,12 +206,12 @@ sub GenerateBody($)
 
   _GenGlobalLine($GlobalStats, "elapsed", "Job history", "How far back the job history goes.");
 
-  _GenGlobalLine($GlobalStats, "jobs.count", "Job count", "The number of jobs in the job history.");
-  _AddRate($GlobalStats, "jobs.count");
-  _GenGlobalLine($GlobalStats, "jobs.rate", "Job rate", "How fast new jobs are coming in.");
-  _GenGlobalLine($GlobalStats, "tasks.count", "Task count", "The number of tasks.");
-  _AddRate($GlobalStats, "tasks.count");
-  _GenGlobalLine($GlobalStats, "tasks.rate", "Task rate", "How fast new tasks are coming in.");
+  _GenGlobalLine($GlobalStats, "newjobs.count", "Job count", "The number of jobs in the job history.");
+  _AddRate($GlobalStats, "newjobs.count");
+  _GenGlobalLine($GlobalStats, "newjobs.rate", "Job rate", "How fast new jobs are coming in.");
+  _GenGlobalLine($GlobalStats, "newtasks.count", "Task count", "The number of tasks.");
+  _AddRate($GlobalStats, "newtasks.count");
+  _GenGlobalLine($GlobalStats, "newtasks.rate", "Task rate", "How fast new tasks are coming in.");
   _GenGlobalLine($GlobalStats, "busy.elapsed", "Busy time", "How much wall clock time was spent running jobs.", $NO_PERCENTAGE);
   _GenGlobalLine($GlobalStats, "busy.elapsed", "Busy \%", "The percentage of wall clock time where the TestBot was busy running jobs.");
 
-- 
2.15.1




More information about the wine-devel mailing list