@@ -1615,7 +1615,8 @@ public void maintain() {
16151615 // Ensure that identification of blocked tasks is using the live state: JENKINS-27708 & JENKINS-27871
16161616 updateSnapshot ();
16171617
1618- // put label has no candidates here to accelerate the buildableItem circle
1618+ // JENKINS-75152. Save the label and blockage reasons of items that have no candidates into this map.
1619+ // It is used to speed up the judgement of other buildable items with the same label.
16191620 Map <Label , List <CauseOfBlockage >> noCandidateLabelsMap = new HashMap <>();
16201621 // allocate buildable jobs to executors
16211622 for (BuildableItem p : new ArrayList <>(
@@ -1632,11 +1633,6 @@ public void maintain() {
16321633 continue ;
16331634 }
16341635
1635- Label itemLabel = p .getAssignedLabel ();
1636- if (noCandidateLabelsMap .containsKey (itemLabel )) {
1637- p .transientCausesOfBlockage = noCandidateLabelsMap .get (itemLabel );
1638- continue ;
1639- }
16401636 String taskDisplayName = LOGGER .isLoggable (Level .FINEST ) ? p .task .getFullDisplayName () : null ;
16411637
16421638 if (p .task instanceof FlyweightTask ) {
@@ -1648,6 +1644,13 @@ public void maintain() {
16481644 updateSnapshot ();
16491645 }
16501646 } else {
1647+ // JENKINS-75152. Skip the remaining steps if the label of this item has been determined
1648+ // to have no candidate executors in the previous allocation process.
1649+ Label itemLabel = p .getAssignedLabel ();
1650+ if (noCandidateLabelsMap .containsKey (itemLabel )) {
1651+ p .transientCausesOfBlockage = noCandidateLabelsMap .get (itemLabel );
1652+ continue ;
1653+ }
16511654
16521655 List <JobOffer > candidates = new ArrayList <>(parked .size ());
16531656 Map <Node , CauseOfBlockage > reasonMap = new HashMap <>();
@@ -1680,7 +1683,7 @@ public void maintain() {
16801683 new Object []{p , candidates , parked .values ()});
16811684 List <CauseOfBlockage > reasons = reasonMap .values ().stream ().filter (Objects ::nonNull ).collect (Collectors .toList ());
16821685 p .transientCausesOfBlockage = reasons .isEmpty () ? null : reasons ;
1683- // If no candidates, mark the label and reasons
1686+ // If no candidates, save the label and blockage reasons.
16841687 if (candidates .isEmpty ()) {
16851688 noCandidateLabelsMap .put (itemLabel , p .transientCausesOfBlockage );
16861689 LOGGER .log (Level .FINEST , "{0} changes to the state of no candidate executor" , itemLabel );
0 commit comments