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

[OSSTEST PATCH 13/60] history reporting (nfc): Move cacheable_* further up the file


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
  • Date: Fri, 14 Aug 2020 18:21:18 +0100
  • Authentication-results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
  • Delivery-date: Fri, 14 Aug 2020 17:22:39 +0000
  • Ironport-sdr: 7Bp9EfzMfiQEfxddNHnfzGwwaggYHMYp6rygoiI/oBUADI4roYsYkTBXJ5I4imD7VjvNL8NrH4 p+P+wUvIS7oY5jMOYiEf12SvbfCLW4rUkKzjLFf02lhBCBEvTQJhlR6SlFORTYASdtcO+Xos7x xYhqs3lKjIobz9CU2NjsCY3tkUL9goDVkNJqPJIreVGOeuMsao+u1EixZgtYew11ohf1UxnZBh P7qdgYTE7PTZhglNFBnLUaeb7hlOqdNXjnQjGY2Sd3SGkeqOjfh2qAIgIPQQrBLUrq2knswwrU wu4=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Pure code motion.  Brings these together with the other work-cacheing
code.

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

diff --git a/sg-report-host-history b/sg-report-host-history
index 32414322..43ddd2af 100755
--- a/sg-report-host-history
+++ b/sg-report-host-history
@@ -88,6 +88,36 @@ sub cache_row_key ($) {
     return join $; , map { $jr->{$_} } @cache_row_key_cols;
 }
 
+our $jqcachemisses = 0;
+our $jqtotal = 0;
+
+sub cacheable_fn ($$$) {
+    my ($jr, $cachekey, $fn) = @_;
+    $jqtotal++;
+    $cachekey = '%'.$cachekey;
+    my $cached = $jr->{$cachekey};
+    $q_count{$cachekey}++;
+    if (!$cached) {
+       $jqcachemisses++;
+       $q_misses{$cachekey}++;
+       $cached = $fn->();
+       $jr->{$cachekey} = $cached;
+    }
+    return $cached;
+}
+
+sub cacheable_query ($$$) {
+    my ($q, $jr, $cachekey) = @_;
+    cacheable_fn($jr, $cachekey, sub {
+       foreach my $k (keys %{ $q->{ParamTypes} }) {
+           $k =~ m/^:/ or die "$k ?";
+           $q->bind_param($k, $jr->{$'} // die "$k ?");
+       }
+       $q->execute();
+       return $q->fetchrow_hashref();
+    });
+}
+
 sub cache_read_previous ($) {
     my ($html_file) = @_;
     if (!open H, $html_file) {
@@ -182,36 +212,6 @@ END
     print DEBUG "MINFLIGHT $minflight\n";
 }
 
-our $jqcachemisses = 0;
-our $jqtotal = 0;
-
-sub cacheable_fn ($$$) {
-    my ($jr, $cachekey, $fn) = @_;
-    $jqtotal++;
-    $cachekey = '%'.$cachekey;
-    my $cached = $jr->{$cachekey};
-    $q_count{$cachekey}++;
-    if (!$cached) {
-       $jqcachemisses++;
-       $q_misses{$cachekey}++;
-       $cached = $fn->();
-       $jr->{$cachekey} = $cached;
-    }
-    return $cached;
-}
-
-sub cacheable_query ($$$) {
-    my ($q, $jr, $cachekey) = @_;
-    cacheable_fn($jr, $cachekey, sub {
-       foreach my $k (keys %{ $q->{ParamTypes} }) {
-           $k =~ m/^:/ or die "$k ?";
-           $q->bind_param($k, $jr->{$'} // die "$k ?");
-       }
-       $q->execute();
-       return $q->fetchrow_hashref();
-    });
-}
-
 our %hosts;
 
 sub mainquery ($) {
-- 
2.11.0




 


Rackspace

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