Merge pull request #95809 from alculquicondor/rebench-spread

Optimize NormalizeScore for PodTopologySpread
This commit is contained in:
Kubernetes Prow Robot 2020-10-26 11:23:02 -07:00 committed by GitHub
commit 5ed903dbfd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 10 deletions

View File

@ -30,6 +30,7 @@ import (
)
const preScoreStateKey = "PreScore" + Name
const invalidScore = -1
// preScoreState computed at PreScore and used at Score.
// Fields are exported for comparison during testing.
@ -219,9 +220,10 @@ func (pl *PodTopologySpread) NormalizeScore(ctx context.Context, cycleState *fra
// Calculate <minScore> and <maxScore>
var minScore int64 = math.MaxInt64
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
if s.IgnoredNodes.Has(score.Name) {
scores[i].Score = invalidScore
continue
}
if score.Score < minScore {
@ -233,22 +235,14 @@ func (pl *PodTopologySpread) NormalizeScore(ctx context.Context, cycleState *fra
}
for i := range scores {
nodeInfo, err := pl.sharedLister.NodeInfos().Get(scores[i].Name)
if err != nil {
return framework.AsStatus(err)
}
node := nodeInfo.Node()
if s.IgnoredNodes.Has(node.Name) {
if scores[i].Score == invalidScore {
scores[i].Score = 0
continue
}
if maxScore == 0 {
scores[i].Score = framework.MaxNodeScore
continue
}
s := scores[i].Score
scores[i].Score = framework.MaxNodeScore * (maxScore + minScore - s) / maxScore
}

View File

@ -807,6 +807,11 @@ var (
existingPodsNum: 10000,
allNodesNum: 1000,
},
{
name: "5000nodes",
existingPodsNum: 50000,
allNodesNum: 5000,
},
}
)