Open
Description
/sig scheduling
The satisfyExistingPodsAntiAffinity
function unnecessarily iterates through all node labels when checking anti-affinity constraints:
kubernetes/pkg/scheduler/framework/plugins/interpodaffinity/filtering.go
Lines 352 to 364 in 62f72ad
Instead, iterate through existingAntiAffinityCounts
directly:
nodeLabels := nodeInfo.Node().Labels
for tp, count := range state.existingAntiAffinityCounts {
if count > 0 {
if nodeValue, ok := nodeLabels[tp.key]; ok && nodeValue == tp.value {
return false
}
}
}
The performance difference depends on:
- Number of node labels (typically 10-15 on GKE, can be 20-30+ with custom labels)
- Number of entries in
existingAntiAffinityCounts