]> xenbits.xensource.com Git - people/liuw/osstest.git/commitdiff
cs-bisection-step: Fix memoisation of search_compute_length_at
authorIan Jackson <ian.jackson@eu.citrix.com>
Thu, 23 Jul 2015 16:31:52 +0000 (17:31 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 28 Jul 2015 14:30:21 +0000 (15:30 +0100)
There was a half-implemented memoisation.  Memoisation is necessary
because otherwise the algorithm is exponential in the commit history
depth (with base equal to the commit parent fanout).

Sort this out:
 * Break out the actual computation into a new
   search_compute_length_at_intern
 * Deleting the individual memo assignments, which incidentally
   means we no longer miss an (unimportant) one.
 * Actually having the new memoising function search_compute_length_at
   check $n->{LengthAt} (this is the bugfix).

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
cs-bisection-step

index 90111ff0d6937cef0fa7930ba941d4f571cb9608..57ecac4a042e78655e7bc2f7c619ef8ecb9498a8 100755 (executable)
@@ -639,8 +639,10 @@ sub consolidateresults () {
 our @interesting_lengths;
 
 sub search_compute_length_at ($);
-sub search_compute_length_at ($) {
+
+sub search_compute_length_at_intern ($) {
     my ($n) = @_;
+
     print DEBUG "CLA $n->{Rtuple} ";
     if (!relevant($n)) {
         print DEBUG "X (irrelevant)\n";
@@ -652,7 +654,6 @@ sub search_compute_length_at ($) {
         if ($n->{Result} ne 'pass') {
             search_compute_length_below($n);
         }
-        $n->{LengthAt}= 0;
         return 0;
     }
     my $res= 1;
@@ -662,10 +663,15 @@ sub search_compute_length_at ($) {
         next if $t eq 'X';
         $res += $t;
     }
-    $n->{LengthAt}= $res;
     return $res;
 }
 
+sub search_compute_length_at ($) {
+    my ($n) = @_;
+    return $n->{LengthAt} if exists $n->{LengthAt};
+    return $n->{LengthAt} = search_compute_length_at_intern($n);
+}
+
 sub search_compute_length_below ($) {
     my ($base) = @_;
     return if $base->{UninterestingFailure};