diff mbox series

[OSSTEST,17/60] history reporting: Cache stats reporting: Centralise and rework

Message ID 20200814172205.9624-18-ian.jackson@eu.citrix.com (mailing list archive)
State New, archived
Headers show
Series Speed up sg-report-job-history | expand

Commit Message

Ian Jackson Aug. 14, 2020, 5:21 p.m. UTC
This uses the new variables instead of the old ones.

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

Patch

diff --git a/sg-report-host-history b/sg-report-host-history
index 32cc883d..9c70b560 100755
--- a/sg-report-host-history
+++ b/sg-report-host-history
@@ -185,6 +185,17 @@  sub cache_write_entry ($$) {
     print $fh " -->\n";
 }
 
+sub cache_report_stats ($) {
+    my ($what) = @_;
+    print ::DEBUG "CACHE $what read=$rows_previous hits $rows_hit/$rows_today";
+    for my $cachekey (sort keys %q_count) {
+	my $total = $q_count{$cachekey};
+	my $hits = $total - ($q_misses{$cachekey} // 0);
+	print ::DEBUG " $cachekey=$hits/$total";
+    }
+    print ::DEBUG "\n";
+}
+
 cache_set_key_cols(qw(flight job status name));
 
 sub computeflightsrange () {
@@ -335,9 +346,6 @@  END
 	push @rows, { %$jr, %$endedrow };
     }
 
-    print DEBUG "CACHE $hostname $rows_hit / ".(scalar @rows)
-	." of ".(scalar %cache)."\n";
-
     @rows = sort { $b->{finished} <=> $a->{finished} } @rows;
 
     print DEBUG "SORTED\n";
@@ -457,8 +465,7 @@  END
     rename "$html_file.new", "$html_file" or die "$html_file $!"
         if $doinstall;
 
-    print DEBUG "HOST CACHE RQ $runvarq_hits / ".
-	  ($runvarq_hits+$runvarq_misses)."\n";
+    cache_report_stats("$hostname");
 }
 
 foreach my $host (@ARGV) {
@@ -528,7 +535,6 @@  foreach my $host (sort keys %hosts) {
             mainquery($host);
 	    reporthost $host;
 	});
-	print DEBUG "JQ CACHE ".($jqtotal-$jqcachemisses)." / $jqtotal\n";
 	exit(0);
     }
     print DEBUG "SPAWNED [$pid] $host\n";