Unverified Commit cfe4ca80 authored by Kubernetes Prow Robot's avatar Kubernetes Prow Robot Committed by GitHub

Merge pull request #73934 from bsalamat/num_cpu

Use runtime.NumCPU() instead of a fixed value for parallel scheduler threads
parents f1603560 d0ebeefb
...@@ -19,6 +19,7 @@ package predicates ...@@ -19,6 +19,7 @@ package predicates
import ( import (
"context" "context"
"fmt" "fmt"
"runtime"
"sync" "sync"
"k8s.io/klog" "k8s.io/klog"
...@@ -415,7 +416,7 @@ func getTPMapMatchingExistingAntiAffinity(pod *v1.Pod, nodeInfoMap map[string]*s ...@@ -415,7 +416,7 @@ func getTPMapMatchingExistingAntiAffinity(pod *v1.Pod, nodeInfoMap map[string]*s
appendTopologyPairsMaps(existingPodTopologyMaps) appendTopologyPairsMaps(existingPodTopologyMaps)
} }
} }
workqueue.ParallelizeUntil(context.TODO(), 16, len(allNodeNames), processNode) workqueue.ParallelizeUntil(context.TODO(), runtime.NumCPU(), len(allNodeNames), processNode)
return topologyMaps, firstError return topologyMaps, firstError
} }
...@@ -503,7 +504,7 @@ func getTPMapMatchingIncomingAffinityAntiAffinity(pod *v1.Pod, nodeInfoMap map[s ...@@ -503,7 +504,7 @@ func getTPMapMatchingIncomingAffinityAntiAffinity(pod *v1.Pod, nodeInfoMap map[s
appendResult(node.Name, nodeTopologyPairsAffinityPodsMaps, nodeTopologyPairsAntiAffinityPodsMaps) appendResult(node.Name, nodeTopologyPairsAffinityPodsMaps, nodeTopologyPairsAntiAffinityPodsMaps)
} }
} }
workqueue.ParallelizeUntil(context.TODO(), 16, len(allNodeNames), processNode) workqueue.ParallelizeUntil(context.TODO(), runtime.NumCPU(), len(allNodeNames), processNode)
return topologyPairsAffinityPodsMaps, topologyPairsAntiAffinityPodsMaps, firstError return topologyPairsAffinityPodsMaps, topologyPairsAntiAffinityPodsMaps, firstError
} }
......
...@@ -18,6 +18,7 @@ package priorities ...@@ -18,6 +18,7 @@ package priorities
import ( import (
"context" "context"
"runtime"
"sync" "sync"
"k8s.io/api/core/v1" "k8s.io/api/core/v1"
...@@ -211,7 +212,7 @@ func (ipa *InterPodAffinity) CalculateInterPodAffinityPriority(pod *v1.Pod, node ...@@ -211,7 +212,7 @@ func (ipa *InterPodAffinity) CalculateInterPodAffinityPriority(pod *v1.Pod, node
} }
} }
} }
workqueue.ParallelizeUntil(context.TODO(), 16, len(allNodeNames), processNode) workqueue.ParallelizeUntil(context.TODO(), runtime.NumCPU(), len(allNodeNames), processNode)
if pm.firstError != nil { if pm.firstError != nil {
return nil, pm.firstError return nil, pm.firstError
} }
......
...@@ -20,6 +20,7 @@ import ( ...@@ -20,6 +20,7 @@ import (
"context" "context"
"fmt" "fmt"
"math" "math"
"runtime"
"sort" "sort"
"strings" "strings"
"sync" "sync"
...@@ -489,7 +490,7 @@ func (g *genericScheduler) findNodesThatFit(pod *v1.Pod, nodes []*v1.Node) ([]*v ...@@ -489,7 +490,7 @@ func (g *genericScheduler) findNodesThatFit(pod *v1.Pod, nodes []*v1.Node) ([]*v
// Stops searching for more nodes once the configured number of feasible nodes // Stops searching for more nodes once the configured number of feasible nodes
// are found. // are found.
workqueue.ParallelizeUntil(ctx, 16, int(allNodes), checkNode) workqueue.ParallelizeUntil(ctx, runtime.NumCPU(), int(allNodes), checkNode)
filtered = filtered[:filteredLen] filtered = filtered[:filteredLen]
if len(errs) > 0 { if len(errs) > 0 {
...@@ -695,7 +696,7 @@ func PrioritizeNodes( ...@@ -695,7 +696,7 @@ func PrioritizeNodes(
} }
} }
workqueue.ParallelizeUntil(context.TODO(), 16, len(nodes), func(index int) { workqueue.ParallelizeUntil(context.TODO(), runtime.NumCPU(), len(nodes), func(index int) {
nodeInfo := nodeNameToInfo[nodes[index].Name] nodeInfo := nodeNameToInfo[nodes[index].Name]
for i := range priorityConfigs { for i := range priorityConfigs {
if priorityConfigs[i].Function != nil { if priorityConfigs[i].Function != nil {
...@@ -943,7 +944,7 @@ func selectNodesForPreemption(pod *v1.Pod, ...@@ -943,7 +944,7 @@ func selectNodesForPreemption(pod *v1.Pod,
resultLock.Unlock() resultLock.Unlock()
} }
} }
workqueue.ParallelizeUntil(context.TODO(), 16, len(potentialNodes), checkNode) workqueue.ParallelizeUntil(context.TODO(), runtime.NumCPU(), len(potentialNodes), checkNode)
return nodeToVictims, nil return nodeToVictims, nil
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment