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

[OSSTEST PATCH 46/60] sg-report-job-history: Introduce use of cache, for hosts query


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
  • Date: Fri, 14 Aug 2020 18:21:51 +0100
  • Authentication-results: esa4.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:26:56 +0000
  • Ironport-sdr: tOXW0E1ASfq6vWuXstSZBpN89HTycJbZPlMC4UcJIvO32tDN6HB4Vn4dSHJSCzArMaHVFRl8Ff ii/oz83F8N2JgFYgmDZhls9FzVfl51Ez3mS7SGcmwLSK5F9Kbl8D+bqFCDeZBvT0mqDERp5JXS RTjWNAHmrB0uGAZO/gnQzgToY0XOf2fYSLQWGtHF3qXj1vGtFY6xfoM1Sk+fjzk0eTgOGqoFl+ YId1riTVqEJhVYC+o+L0GeZfRPLOJNjmpAj+62VViNl3q5qhMdevKA17THPZS9BHNR/NPAkFE6 N4M=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

* Set up the cache.
* Call the per-row setup hook.
* Cache the computation of $ri->{Hosts}.
* Call the per-row cache write hook.
* Finalise the cache.

Output is the same, but with cache information in the output html, and
faster.

Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 sg-report-job-history | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/sg-report-job-history b/sg-report-job-history
index 5684ac02..9f1216a6 100755
--- a/sg-report-job-history
+++ b/sg-report-job-history
@@ -121,6 +121,10 @@ sub processjobbranch ($$$) {
            AND name LIKE '%buildjob'
 END
 
+    cache_set_task_print("$j $branch_or_all");
+    cache_set_key_cols(qw(flight status)); # we process one job per process
+    cache_read_previous("$htmlout/$html_file");
+
     print DEBUG "processjobbranch('$j',", ($bra ? "'$bra'" : 'undef'), ")\n";
 
     my %rev_grid_col;
@@ -156,13 +160,17 @@ END
 END
 
     while (my $f= $flightsq->fetchrow_hashref()) {
+       cache_row_lookup_prep(\$f);
         my $ri= report_run_getinfo($f);
 
-       $ri->{Hosts} = { };
-       $hostq->execute($f->{flight}, $f->{job});
-       while (my ($hostvar,$host) = $hostq->fetchrow_array()) {
-           $ri->{Hosts}{$hostvar} = $host;
-       }
+       $ri->{Hosts} = cacheable_fn($f, 'h', sub {
+            my %hosts;
+           $hostq->execute($f->{flight}, $f->{job});
+           while (my ($hostvar,$host) = $hostq->fetchrow_array()) {
+               $hosts{$hostvar} = $host;
+           }
+           \%hosts;
+       });
 
         my %revisions;
         add_revisions(\%revisions, $f->{flight}, $f->{job}, '');
@@ -276,8 +284,10 @@ END
            print H "</td>";
        }
        print H "</tr>\n";
+       cache_write_entry(\*H, $r->{Flight});
        $alternate ^= 1;
     }
+    cache_finish(\*H, "");
     print H "</table></body></html>\n";
     H->error and die $!;
     close H or die $!;
-- 
2.11.0




 


Rackspace

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