@@ -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;
};
}
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@eu.citrix.com> --- Osstest/Executive.pm | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)