From e8e7fdac62355063d41d3e230d592d9c943b908b Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 19 Aug 2020 13:00:58 +0100 Subject: [PATCH] host allocation: Memoise duration estimates We look at our own branch to estimate durations. If somehow we are one of multiple concurrent flights on this branch with the appropriate blessing, we don't mind not noticing the doing of our peer flights so that if our estimates are a bit out of date. So it is fine to use an estimate no older than our own runtime. Right now we generate a new duration estimator during each queueing round, because it contains a statement handle and we must disconnect from the db while waiting. So the internal memo table gets thrown away each time and is useless. To actually memoise, pass our own hash which lives as long as we do. Signed-off-by: Ian Jackson --- Osstest/Executive.pm | 2 +- ts-hosts-allocate-Executive | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm index 50c84cc..61a99bc 100644 --- a/Osstest/Executive.pm +++ b/Osstest/Executive.pm @@ -1274,7 +1274,7 @@ END return sub { my ($job, $hostidname, $onhost, $uptoincl_testid) = @_; - my $memokey = "$job $hostidname $onhost $uptoincl_testid"; + my $memokey = "$job $hostidname $onhost ".($uptoincl_testid//""); my $memo = $our_memo->{$memokey}; return @$memo if $memo; diff --git a/ts-hosts-allocate-Executive b/ts-hosts-allocate-Executive index e5a6fbf..58ffd1b 100755 --- a/ts-hosts-allocate-Executive +++ b/ts-hosts-allocate-Executive @@ -145,8 +145,10 @@ END AND hostflag LIKE 'equiv-%' END + our %duration_memo; $duration_estimator= duration_estimator($fi->{branch}, $blessing, - sub { print DEBUG "@_\n"; }); + sub { print DEBUG "@_\n"; }, + 0, \%duration_memo); $resprop_q= $dbh_tests->prepare(<