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

Ian Jackson posted 13 patches 6 years, 3 months ago
[Xen-devel] [OSSTEST PATCH 12/13] sg-report-host-history: Cache runvar queries (power information)
Posted by Ian Jackson 6 years, 3 months ago
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 --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) {
-- 
2.11.0


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