mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
Merge pull request #95809 from alculquicondor/rebench-spread
Optimize NormalizeScore for PodTopologySpread
This commit is contained in:
commit
5ed903dbfd
@ -30,6 +30,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const preScoreStateKey = "PreScore" + Name
|
const preScoreStateKey = "PreScore" + Name
|
||||||
|
const invalidScore = -1
|
||||||
|
|
||||||
// preScoreState computed at PreScore and used at Score.
|
// preScoreState computed at PreScore and used at Score.
|
||||||
// Fields are exported for comparison during testing.
|
// Fields are exported for comparison during testing.
|
||||||
@ -219,9 +220,10 @@ func (pl *PodTopologySpread) NormalizeScore(ctx context.Context, cycleState *fra
|
|||||||
// Calculate <minScore> and <maxScore>
|
// Calculate <minScore> and <maxScore>
|
||||||
var minScore int64 = math.MaxInt64
|
var minScore int64 = math.MaxInt64
|
||||||
var maxScore int64
|
var maxScore int64
|
||||||
for _, score := range scores {
|
for i, score := range scores {
|
||||||
// it's mandatory to check if <score.Name> is present in m.IgnoredNodes
|
// it's mandatory to check if <score.Name> is present in m.IgnoredNodes
|
||||||
if s.IgnoredNodes.Has(score.Name) {
|
if s.IgnoredNodes.Has(score.Name) {
|
||||||
|
scores[i].Score = invalidScore
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if score.Score < minScore {
|
if score.Score < minScore {
|
||||||
@ -233,22 +235,14 @@ func (pl *PodTopologySpread) NormalizeScore(ctx context.Context, cycleState *fra
|
|||||||
}
|
}
|
||||||
|
|
||||||
for i := range scores {
|
for i := range scores {
|
||||||
nodeInfo, err := pl.sharedLister.NodeInfos().Get(scores[i].Name)
|
if scores[i].Score == invalidScore {
|
||||||
if err != nil {
|
|
||||||
return framework.AsStatus(err)
|
|
||||||
}
|
|
||||||
node := nodeInfo.Node()
|
|
||||||
|
|
||||||
if s.IgnoredNodes.Has(node.Name) {
|
|
||||||
scores[i].Score = 0
|
scores[i].Score = 0
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if maxScore == 0 {
|
if maxScore == 0 {
|
||||||
scores[i].Score = framework.MaxNodeScore
|
scores[i].Score = framework.MaxNodeScore
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
s := scores[i].Score
|
s := scores[i].Score
|
||||||
scores[i].Score = framework.MaxNodeScore * (maxScore + minScore - s) / maxScore
|
scores[i].Score = framework.MaxNodeScore * (maxScore + minScore - s) / maxScore
|
||||||
}
|
}
|
||||||
|
@ -807,6 +807,11 @@ var (
|
|||||||
existingPodsNum: 10000,
|
existingPodsNum: 10000,
|
||||||
allNodesNum: 1000,
|
allNodesNum: 1000,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "5000nodes",
|
||||||
|
existingPodsNum: 50000,
|
||||||
|
allNodesNum: 5000,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user