[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST PATCH 07/13] sg-report-host-history: Store per-job query results in %$jr


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
  • Date: Fri, 8 Nov 2019 18:49:55 +0000
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=ian.jackson@xxxxxxxxxxxxx; spf=Pass smtp.mailfrom=Ian.Jackson@xxxxxxxxxx; spf=None smtp.helo=postmaster@xxxxxxxxxxxxxxx
  • Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
  • Delivery-date: Fri, 08 Nov 2019 18:50:42 +0000
  • Ironport-sdr: 6jzBjl6l+FJO/3D7FV/XvqJUdnOGvfUJRNRCwxoSEXHqzRbh0T86uz7J+WzMj9VLirU7Pm/Cq7 tj2NVZ5UKGIjojWxclJK8tnl+cIOiJ3/wpidSJXDVA/fj1bRA6htrToOxQg1dCkUOBwHROy9rZ VjluPZdx9kics4x39L6qItReexPc5i6G7z2khnnNXaL13utqWC95zv1yrSK0FQn0KjTvE2E1BV fGDelmpun35kr4AoYzjUaBMmyI8ysSJUELlFxZUg6hTcbcV1tiOvQ0z5b3mCGBaSXGrkZaf1zP ALs=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

jobquery now looks for the subquery results in %$jr, under the
cachekey, and only runs the query if it's not found.  It then stores
the value.

We are going to persist the contents of %$jr across runs, and then
this will avoid rerunning queries needlessly.

No functional change yet.

Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 sg-report-host-history | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/sg-report-host-history b/sg-report-host-history
index 4c40cbec..8767b25d 100755
--- a/sg-report-host-history
+++ b/sg-report-host-history
@@ -109,11 +109,21 @@ END
     print DEBUG "MINFLIGHT $minflight\n";
 }
 
+our $jqcachemisses = 0;
+our $jqtotal = 0;
+
 sub jobquery ($$$) {
     my ($q, $jr, $cachekey) = @_;
-    my ($q, $jr) = @_;
-    $q->execute($jr->{flight}, $jr->{job});
-    return $q->fetchrow_hashref();
+    $jqtotal++;
+    $cachekey = '%'.$cachekey;
+    my $cached = $jr->{$cachekey};
+    if (!$cached) {
+       $jqcachemisses++;
+       $q->execute($jr->{flight}, $jr->{job});
+       $cached = $q->fetchrow_hashref();
+       $jr->{$cachekey} = $cached;
+    }
+    return $cached;
 }
 
 our %hosts;
@@ -215,6 +225,12 @@ END
     my $inrows = $hosts{$hostname};
     print DEBUG "FOUND ", (scalar @$inrows), " ROWS for $hostname\n";
 
+    # Each entry in @$inrows is a $jr, which is a hash
+    # It has keys for the result columns in mainquery
+    # It also has keys '%<letter>' (yes, with a literal '%')
+    # which are the results of per-job queries.
+    # The contents of $jr for each job is cached across runs. (TODO)
+
     my @rows;
     foreach my $jr (@$inrows) {
        print DEBUG "JOB $jr->{flight}.$jr->{job} ";
@@ -377,3 +393,5 @@ foreach my $host (sort keys %hosts) {
        reporthost $host;
     });
 }
+
+print DEBUG "JQ CACHE ".($jqtotal-$jqcachemisses)." / $jqtotal\n";
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.