[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [OSSTEST PATCH 07/13] sg-report-host-history: Store per-job query results in %$jr
jobquery now looks for the subquery results in %$jr, under the cachekey, and only runs the query if it's not found. It then stores the value. We are going to persist the contents of %$jr across runs, and then this will avoid rerunning queries needlessly. No functional change yet. Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> --- sg-report-host-history | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/sg-report-host-history b/sg-report-host-history index 4c40cbec..8767b25d 100755 --- a/sg-report-host-history +++ b/sg-report-host-history @@ -109,11 +109,21 @@ END print DEBUG "MINFLIGHT $minflight\n"; } +our $jqcachemisses = 0; +our $jqtotal = 0; + sub jobquery ($$$) { my ($q, $jr, $cachekey) = @_; - my ($q, $jr) = @_; - $q->execute($jr->{flight}, $jr->{job}); - return $q->fetchrow_hashref(); + $jqtotal++; + $cachekey = '%'.$cachekey; + my $cached = $jr->{$cachekey}; + if (!$cached) { + $jqcachemisses++; + $q->execute($jr->{flight}, $jr->{job}); + $cached = $q->fetchrow_hashref(); + $jr->{$cachekey} = $cached; + } + return $cached; } our %hosts; @@ -215,6 +225,12 @@ END my $inrows = $hosts{$hostname}; print DEBUG "FOUND ", (scalar @$inrows), " ROWS for $hostname\n"; + # Each entry in @$inrows is a $jr, which is a hash + # It has keys for the result columns in mainquery + # It also has keys '%<letter>' (yes, with a literal '%') + # which are the results of per-job queries. + # The contents of $jr for each job is cached across runs. (TODO) + my @rows; foreach my $jr (@$inrows) { print DEBUG "JOB $jr->{flight}.$jr->{job} "; @@ -377,3 +393,5 @@ foreach my $host (sort keys %hosts) { reporthost $host; }); } + +print DEBUG "JQ CACHE ".($jqtotal-$jqcachemisses)." / $jqtotal\n"; -- 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |