]> xenbits.xensource.com Git - osstest.git/commitdiff
host allocation: Memoise duration estimates
authorIan Jackson <ian.jackson@eu.citrix.com>
Wed, 19 Aug 2020 12:00:58 +0000 (13:00 +0100)
committerIan Jackson <ian.jackson@eu.citrix.com>
Wed, 19 Aug 2020 16:01:07 +0000 (17:01 +0100)
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 <ian.jackson@eu.citrix.com>
Osstest/Executive.pm
ts-hosts-allocate-Executive

index 50c84cc3b74744bf805b541f13016b54e0deca4a..61a99bc3429e86d67ec7b3f8d1edc2882dce411b 100644 (file)
@@ -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;
 
index e5a6fbfe988c8d65a609e58faeaa51a6d55abb5f..58ffd1b829acf7fcbdcbbac7e002793e8933a54e 100755 (executable)
@@ -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(<<END);
             SELECT * FROM resource_properties