This provides a very significant speedup.

Signed-off-by: Ian Jackson <ian.jack...@eu.citrix.com>
---
 ts-hosts-allocate-Executive | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/ts-hosts-allocate-Executive b/ts-hosts-allocate-Executive
index 39c66346..a47bc499 100755
--- a/ts-hosts-allocate-Executive
+++ b/ts-hosts-allocate-Executive
@@ -467,9 +467,13 @@ END
         find_recent_duration($dbg,$hid,$candrow);
 
        if ($candrow->{restype} eq 'host') {
-           $equivstatusq->execute($job,$blessing,$fi->{branch},
-                                  $hid->{Ident},$candrow->{resname});
-           my $esrow = $equivstatusq->fetchrow_hashref();
+           our %equivstatus_memo;
+           my @params = ($job,$blessing,$fi->{branch},
+                         $hid->{Ident},$candrow->{resname});
+           my $esrow = $equivstatus_memo{"@params"} //= do {
+               $equivstatusq->execute(@params);
+               $equivstatusq->fetchrow_hashref() // { };
+           };
            $candrow->{EquivMostRecentStatus} = $esrow->{status};
            print DEBUG "$dbg EQUIV-MOST-RECENT ";
            print DEBUG ("$esrow->{flight}.$esrow->{job}".
-- 
2.11.0


Reply via email to