mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Merge pull request #89459 from chendave/scorer_desc
Trival fix: update the desc on the score plugins
This commit is contained in:
commit
894916b665
@ -56,7 +56,7 @@ func (ba *BalancedAllocation) Score(ctx context.Context, state *framework.CycleS
|
||||
// It should **NOT** be used alone, and **MUST** be used together
|
||||
// with NodeResourcesLeastAllocated plugin. It calculates the difference between the cpu and memory fraction
|
||||
// of capacity, and prioritizes the host based on how close the two metrics are to each other.
|
||||
// Detail: score = 10 - variance(cpuFraction,memoryFraction,volumeFraction)*10. The algorithm is partly inspired by:
|
||||
// Detail: score = (1 - variance(cpuFraction,memoryFraction,volumeFraction)) * MaxNodeScore. The algorithm is partly inspired by:
|
||||
// "Wei Huang et al. An Energy Efficient Virtual Machine Placement Algorithm with Balanced
|
||||
// Resource Utilization"
|
||||
return ba.score(pod, nodeInfo)
|
||||
@ -99,15 +99,15 @@ func balancedResourceScorer(requested, allocable resourceToValueMap, includeVolu
|
||||
mean := (cpuFraction + memoryFraction + volumeFraction) / float64(3)
|
||||
variance := float64((((cpuFraction - mean) * (cpuFraction - mean)) + ((memoryFraction - mean) * (memoryFraction - mean)) + ((volumeFraction - mean) * (volumeFraction - mean))) / float64(3))
|
||||
// Since the variance is between positive fractions, it will be positive fraction. 1-variance lets the
|
||||
// score to be higher for node which has least variance and multiplying it with 10 provides the scaling
|
||||
// score to be higher for node which has least variance and multiplying it with `MaxNodeScore` provides the scaling
|
||||
// factor needed.
|
||||
return int64((1 - variance) * float64(framework.MaxNodeScore))
|
||||
}
|
||||
|
||||
// Upper and lower boundary of difference between cpuFraction and memoryFraction are -1 and 1
|
||||
// respectively. Multiplying the absolute value of the difference by 10 scales the value to
|
||||
// 0-10 with 0 representing well balanced allocation and 10 poorly balanced. Subtracting it from
|
||||
// 10 leads to the score which also scales from 0 to 10 while 10 representing well balanced.
|
||||
// respectively. Multiplying the absolute value of the difference by `MaxNodeScore` scales the value to
|
||||
// 0-MaxNodeScore with 0 representing well balanced allocation and `MaxNodeScore` poorly balanced. Subtracting it from
|
||||
// `MaxNodeScore` leads to the score which also scales from 0 to `MaxNodeScore` while `MaxNodeScore` representing well balanced.
|
||||
diff := math.Abs(cpuFraction - memoryFraction)
|
||||
return int64((1 - diff) * float64(framework.MaxNodeScore))
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ func (la *LeastAllocated) Score(ctx context.Context, state *framework.CycleState
|
||||
// prioritizes based on the minimum of the average of the fraction of requested to capacity.
|
||||
//
|
||||
// Details:
|
||||
// (cpu((capacity-sum(requested))*10/capacity) + memory((capacity-sum(requested))*10/capacity))/2
|
||||
// (cpu((capacity-sum(requested))*MaxNodeScore/capacity) + memory((capacity-sum(requested))*MaxNodeScore/capacity))/weightSum
|
||||
return la.score(pod, nodeInfo)
|
||||
}
|
||||
|
||||
@ -84,8 +84,8 @@ func leastResourceScorer(requested, allocable resourceToValueMap, includeVolumes
|
||||
return nodeScore / weightSum
|
||||
}
|
||||
|
||||
// The unused capacity is calculated on a scale of 0-10
|
||||
// 0 being the lowest priority and 10 being the highest.
|
||||
// The unused capacity is calculated on a scale of 0-MaxNodeScore
|
||||
// 0 being the lowest priority and `MaxNodeScore` being the highest.
|
||||
// The more unused resources the higher the score is.
|
||||
func leastRequestedScore(requested, capacity int64) int64 {
|
||||
if capacity == 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user