Skip to contentSkip to conversation

host allocation: Prepare for further starvation check

PATCH New Ian Jackson 1 participant 3 messages Jun 7, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 host allocation: Prepare for further starvation check

* Add a new job pattern parameter to $starvation_q
* Add a new $thisclass parameter to starving
* Pass 0 for now.

---
 ts-hosts-allocate-Executive | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
ts-hosts-allocate-Executive +6 -4
index 459b9215..9722ce12 100755
@@ -162,6 +162,7 @@ END
      LEFT JOIN steps
          USING (flight,job)
          WHERE flight= ?
+           AND job LIKE ?
       GROUP BY job, jobs.status
 END
 
@@ -822,11 +823,12 @@ sub most_optimistic ($$$) {
     return $optimist->{Got};
 }
 
-sub starving ($$) {
-    my ($best_start_abs, $now) = @_;
+sub starving ($$$) {
+    my ($best_start_abs, $now, $thisclass) = @_;
     return (0, 'runvar says never give up') unless %$starvation_p;
     return (0, 'no estimate') unless defined $best_start_abs;
-    $starvation_q->execute($flight);
+    my $joblike = $thisclass ? ($job =~ s/(?:(-)|\W).*/$1\%/r) : '%';
+    $starvation_q->execute($flight, $joblike);
     my $d=0;
     my $w=0;
     my $maxfin=0;
@@ -935,7 +937,7 @@ sub attempt_allocation {
 	    }
 	} elsif (%$starvation_p) {
 	    my $est_abs = most_optimistic($best, $now, $starvation_p->{I});
-	    my ($starving, $m) = starving($est_abs, $now);
+	    my ($starving, $m) = starving($est_abs, $now, 0);
 	    $starvation_q->finish();
 	    if (!$starving) {
 		print DEBUG "not starving: $m\n";
Signature · 1 line
2.20.1
#1 lore raw

PATCH 2/3 host allocation: Check "job class" too

That is all jobs which start with the same \w* as this job.

---
 ts-hosts-allocate-Executive | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
ts-hosts-allocate-Executive +13 -5
index 9722ce12..849bc97b 100755
@@ -937,12 +937,20 @@ sub attempt_allocation {
 	    }
 	} elsif (%$starvation_p) {
 	    my $est_abs = most_optimistic($best, $now, $starvation_p->{I});
-	    my ($starving, $m) = starving($est_abs, $now, 0);
+	    my $all_starving = 1;
+	    foreach my $thisclass (qw(1 0)) {
+		my $tcdesc = $thisclass ? 'class' : 'flight';
+		my ($starving, $m) = starving($est_abs, $now, $thisclass);
+		if (!$starving) {
+		    print DEBUG "not starving ($tcdesc): $m\n";
+		    $all_starving = 0;
+		    last;
+		} else {
+		    logm "starving ($tcdesc) ($m)";
+		}
+	    }
 	    $starvation_q->finish();
-	    if (!$starving) {
-		print DEBUG "not starving: $m\n";
-	    } else {
-		logm "starving ($m)";
+	    if ($all_starving) {
 		return $alloc_starved_r;
 	    }
 	}
Signature · 1 line
2.20.1
#2 lore raw

PATCH 3/3 host allocation: Avoid starving out failing tests

In reply to Ian Jackson

This can result in bad pushes. Better to wait.

---
 ts-hosts-allocate-Executive | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
ts-hosts-allocate-Executive +6 -1
index 849bc97b..4dfcd0cd 100755
@@ -704,6 +704,7 @@ sub hid_recurse ($$) {
 	    Selections => [ map { $_->{Selected} } @hids ],
 	    Start => $start_time,
 	    Duration => $duration,
+	    PrevFail => ($previously_failed || $previously_failed_equiv),
 	};
     }
 }
@@ -951,7 +952,11 @@ sub attempt_allocation {
 	    }
 	    $starvation_q->finish();
 	    if ($all_starving) {
-		return $alloc_starved_r;
+		if (!$best->{PrevFail}) {
+		    return $alloc_starved_r;
+		} else {
+		    logm "starving, but previously failed, so continue...";
+		}
 	    }
 	}
     }
Signature · 1 line
2.20.1