diff mbox series

[OSSTEST,12/13] sg-report-host-history: Cache runvar queries (power information)

Message ID 20191108185001.3319-13-ian.jackson@eu.citrix.com (mailing list archive)
State New, archived
Headers show
Series Speed up and restore host history | expand

Commit Message

Ian Jackson Nov. 8, 2019, 6:50 p.m. UTC
This per-job processing was not done with jobquery, so was not cached.
We assign it the cache letter `p'.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 sg-report-host-history | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/sg-report-host-history b/sg-report-host-history
index 7c2116d3..a11b00a0 100755
--- a/sg-report-host-history
+++ b/sg-report-host-history
@@ -322,6 +322,9 @@  END
 
     my $alternate = 0;
     my $wrote = 0;
+    my $runvarq_hits = 0;
+    my $runvarq_misses = 0;
+
     foreach my $jr (@rows) {
 	if ($wrote++ >= $limit) {
 	    $write_cache_entry->($jr);
@@ -372,7 +375,11 @@  END
 	print H "<td $ri->{ColourAttr}>$ri->{Content}</td>\n";
 
 	my %powers;
-	do {
+	if ($jr->{'%p'}) {
+	    %powers = %{ $jr->{'%p'} };
+	    $runvarq_hits++;
+	} else {
+	    $runvarq_misses++;
 	    $jrunvarq->execute($jr->{flight}, $jr->{job}, $ident);
 	    my %runvars;
 	    while (my ($n, $v) = $jrunvarq->fetchrow_array()) {
@@ -383,7 +390,8 @@  END
 		next unless $r =~ m{^\Q${ident}\E_power_};
 		$powers{$'} = $runvars{$r};
 	    }
-	};
+	    $jr->{'%p'} = { %powers };
+	}
 	my $skipped = 0;
         my $any_power = 0;
         my $pr_power_colour = sub {
@@ -429,6 +437,9 @@  END
     close H or die $!;
     rename "$html_file.new", "$html_file" or die "$html_file $!"
         if $doinstall;
+
+    print DEBUG "HOST CACHE RQ $runvarq_hits / ".
+	  ($runvarq_hits+$runvarq_misses)."\n";
 }
 
 foreach my $host (@ARGV) {