mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 05:03:09 +00:00
Set initial map size
Signed-off-by: Aldo Culquicondor <acondor@google.com>
This commit is contained in:
parent
65d9f81758
commit
93fc02cf54
@ -223,7 +223,7 @@ func (pl *PodTopologySpread) calPreFilterState(pod *v1.Pod) (*preFilterState, er
|
|||||||
s := preFilterState{
|
s := preFilterState{
|
||||||
Constraints: constraints,
|
Constraints: constraints,
|
||||||
TpKeyToCriticalPaths: make(map[string]*criticalPaths, len(constraints)),
|
TpKeyToCriticalPaths: make(map[string]*criticalPaths, len(constraints)),
|
||||||
TpPairToMatchNum: make(map[topologyPair]*int32),
|
TpPairToMatchNum: make(map[topologyPair]*int32, sizeHeuristic(len(allNodes), constraints)),
|
||||||
}
|
}
|
||||||
for _, n := range allNodes {
|
for _, n := range allNodes {
|
||||||
node := n.Node()
|
node := n.Node()
|
||||||
@ -328,3 +328,12 @@ func (pl *PodTopologySpread) Filter(ctx context.Context, cycleState *framework.C
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func sizeHeuristic(nodes int, constraints []topologySpreadConstraint) int {
|
||||||
|
for _, c := range constraints {
|
||||||
|
if c.TopologyKey == v1.LabelHostname {
|
||||||
|
return nodes
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user