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

[OSSTEST PATCH 4/7] duration estimates: Memoise results


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
  • Date: Wed, 19 Aug 2020 17:01:40 +0100
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
  • Delivery-date: Wed, 19 Aug 2020 16:01:59 +0000
  • Ironport-sdr: kR4+DsxdUAKyV3QuyttODNk15P5BJICEd4LYVvUg52Lf2JKP2ShdZp7LhGB62+EhZ0YRZS+Zn8 ZpcfYWEOzzDlJ3P28zHBElIK/GTYXAvhP11zLHsRmf8jmbQ7i2O8p9eUTCXFVtyQweGbSLR0Vw xZfW6BThqDAGNY6qCTokdW1qhqY9uZAqtxcHlDyjFFpA19cUzQHanFUfpoCTUGyfFgJjI3y/g0 Phes50Iht7uWLi7Zh1D1C1TKLgnS+AOzn6sqK+ebjJ7DpgBrKLpZL73rLdsuF2qIpyLi5uk1Mh pzk=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

The caller may provide a memoisation hash.  If they don't we embed
one in the estimator.

The estimator contains a db statement handle so shouldn't be so
long-lived that this gives significantly wrong answers.

I am aiming this work at ts-hosts-allocate-Executive, but it is
possible that this might speed up sg-report-flight.

Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 Osstest/Executive.pm | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm
index d6b2736b..50c84cc3 100644
--- a/Osstest/Executive.pm
+++ b/Osstest/Executive.pm
@@ -1164,8 +1164,8 @@ sub hostalloc_starvation_calculate_X ($$$) {
 
 #---------- duration estimator ----------
 
-sub duration_estimator ($$;$$) {
-    my ($branch, $blessing, $debug, $will_uptoincl_testid) = @_;
+sub duration_estimator ($$;$$$) {
+    my ($branch, $blessing, $debug, $will_uptoincl_testid, $our_memo) = @_;
     # returns a function which you call like this
     #    $durest->($job, $hostidname, $onhost [, $uptoincl_testid])
     # and returns one of
@@ -1269,9 +1269,15 @@ END
     my $recentflights_q= $prepare_combi->($recentflights_qtxt);
     my $duration_anyref_q= $prepare_combi->($duration_anyref_qtxt);
 
+    $our_memo //= { };
+
     return sub {
         my ($job, $hostidname, $onhost, $uptoincl_testid) = @_;
 
+       my $memokey = "$job $hostidname $onhost $uptoincl_testid";
+       my $memo = $our_memo->{$memokey};
+       return @$memo if $memo;
+
        my @x_params;
        push @x_params, $uptoincl_testid if $will_uptoincl_testid;
 
@@ -1319,7 +1325,9 @@ END
             }
         }
 
-        return ($duration_max, $refs->[0]{started}, $refs->[0]{status});
+       $memo = [$duration_max, $refs->[0]{started}, $refs->[0]{status}];
+       $our_memo->{$memokey} = $memo;
+        return @$memo;
     };
 }
 
-- 
2.11.0




 


Rackspace

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