@@ -1116,19 +1116,23 @@ func sortTargetCandidateSetAndPick(
1116
1116
// only reason we will consider a set later than the first one is if the
1117
1117
// earlier sets get fully discarded solely because of nls and have no
1118
1118
// pending changes, or because of ignoreHigherThanLoadThreshold.
1119
- lowestLoad := cands .candidates [0 ].sls
1119
+ lowestLoadSet := cands .candidates [0 ].sls
1120
+ currentLoadSet := lowestLoadSet
1120
1121
discardedCandsHadNoPendingChanges := true
1121
1122
for _ , cand := range cands .candidates {
1122
- if cand .sls > lowestLoad {
1123
+ if cand .sls > currentLoadSet {
1123
1124
if ! discardedCandsHadNoPendingChanges {
1124
- // Never go beyond lowestLoad if we have discarded candidates that
1125
- // have pending changes. We will wait for those to have no pending
1126
- // changes before we consider candidates with load > lowestLoad .
1125
+ // Never go to the next set if we have discarded candidates that have
1126
+ // pending changes. We will wait for those to have no pending changes
1127
+ // before we consider later sets .
1127
1128
break
1128
1129
}
1130
+ currentLoadSet = cand .sls
1131
+ }
1132
+ if cand .sls > lowestLoadSet {
1129
1133
if j == 0 {
1130
1134
// This is the lowestLoad set being considered now.
1131
- lowestLoad = cand .sls
1135
+ lowestLoadSet = cand .sls
1132
1136
} else if ignoreLevel < ignoreHigherThanLoadThreshold || overloadedDim == NumLoadDimensions {
1133
1137
// Past the lowestLoad set. We don't care about these.
1134
1138
break
@@ -1161,8 +1165,8 @@ func sortTargetCandidateSetAndPick(
1161
1165
log .VInfof (ctx , 2 , "sortTargetCandidateSetAndPick: no candidates due to load" )
1162
1166
return 0
1163
1167
}
1164
- lowestLoad = cands .candidates [0 ].sls
1165
- highestLoad := cands .candidates [j - 1 ].sls
1168
+ lowestLoadSet = cands .candidates [0 ].sls
1169
+ highestLoadSet := cands .candidates [j - 1 ].sls
1166
1170
cands .candidates = cands .candidates [:j ]
1167
1171
// The set of candidates we will consider all have load <= loadThreshold.
1168
1172
// They may all be lowestLoad, or we may have allowed additional candidates
@@ -1184,11 +1188,11 @@ func sortTargetCandidateSetAndPick(
1184
1188
// conservative choice, since pending added work is slightly inflated in
1185
1189
// size, and we want to have a true picture of all of these potential
1186
1190
// candidates before we start using the ones with load >= loadNoChange.
1187
- if lowestLoad > loadThreshold {
1191
+ if lowestLoadSet > loadThreshold {
1188
1192
panic ("candidates should not have lowestLoad > loadThreshold" )
1189
1193
}
1190
1194
// INVARIANT: lowestLoad <= loadThreshold.
1191
- if lowestLoad == loadThreshold && ignoreLevel < ignoreHigherThanLoadThreshold {
1195
+ if lowestLoadSet == loadThreshold && ignoreLevel < ignoreHigherThanLoadThreshold {
1192
1196
log .VInfof (ctx , 2 , "sortTargetCandidateSetAndPick: no candidates due to equal to loadThreshold" )
1193
1197
return 0
1194
1198
}
@@ -1197,12 +1201,12 @@ func sortTargetCandidateSetAndPick(
1197
1201
1198
1202
// < loadNoChange is fine. We need to check whether the following cases can continue.
1199
1203
// [loadNoChange, loadThreshold), or loadThreshold && ignoreHigherThanLoadThreshold.
1200
- if lowestLoad >= loadNoChange &&
1204
+ if lowestLoadSet >= loadNoChange &&
1201
1205
(! discardedCandsHadNoPendingChanges || ignoreLevel == ignoreLoadNoChangeAndHigher ) {
1202
1206
log .VInfof (ctx , 2 , "sortTargetCandidateSetAndPick: no candidates due to loadNoChange" )
1203
1207
return 0
1204
1208
}
1205
- if lowestLoad != highestLoad {
1209
+ if lowestLoadSet != highestLoadSet {
1206
1210
slices .SortFunc (cands .candidates , func (a , b candidateInfo ) int {
1207
1211
return cmp .Or (
1208
1212
cmp .Compare (a .leasePreferenceIndex , b .leasePreferenceIndex ),
@@ -1223,7 +1227,7 @@ func sortTargetCandidateSetAndPick(
1223
1227
return 0
1224
1228
}
1225
1229
cands .candidates = cands .candidates [:j ]
1226
- if lowestLoad != highestLoad || (lowestLoad >= loadNoChange && overloadedDim != NumLoadDimensions ) {
1230
+ if lowestLoadSet != highestLoadSet || (lowestLoadSet >= loadNoChange && overloadedDim != NumLoadDimensions ) {
1227
1231
// Sort candidates from lowest to highest along overloaded dimension. We
1228
1232
// limit when we do this, since this will further restrict the pool of
1229
1233
// candidates and in general we don't want to restrict the pool.
0 commit comments