@@ -56,7 +56,7 @@ func (ba *BalancedAllocation) Score(ctx context.Context, state *framework.CycleS
56
56
// It should **NOT** be used alone, and **MUST** be used together
57
57
// with NodeResourcesLeastAllocated plugin. It calculates the difference between the cpu and memory fraction
58
58
// of capacity, and prioritizes the host based on how close the two metrics are to each other.
59
- // Detail: score = 10 - variance(cpuFraction,memoryFraction,volumeFraction)*10 . The algorithm is partly inspired by:
59
+ // Detail: score = (1 - variance(cpuFraction,memoryFraction,volumeFraction)) * MaxNodeScore . The algorithm is partly inspired by:
60
60
// "Wei Huang et al. An Energy Efficient Virtual Machine Placement Algorithm with Balanced
61
61
// Resource Utilization"
62
62
return ba .score (pod , nodeInfo )
@@ -99,15 +99,15 @@ func balancedResourceScorer(requested, allocable resourceToValueMap, includeVolu
99
99
mean := (cpuFraction + memoryFraction + volumeFraction ) / float64 (3 )
100
100
variance := float64 ((((cpuFraction - mean ) * (cpuFraction - mean )) + ((memoryFraction - mean ) * (memoryFraction - mean )) + ((volumeFraction - mean ) * (volumeFraction - mean ))) / float64 (3 ))
101
101
// Since the variance is between positive fractions, it will be positive fraction. 1-variance lets the
102
- // score to be higher for node which has least variance and multiplying it with 10 provides the scaling
102
+ // score to be higher for node which has least variance and multiplying it with `MaxNodeScore` provides the scaling
103
103
// factor needed.
104
104
return int64 ((1 - variance ) * float64 (framework .MaxNodeScore ))
105
105
}
106
106
107
107
// Upper and lower boundary of difference between cpuFraction and memoryFraction are -1 and 1
108
- // respectively. Multiplying the absolute value of the difference by 10 scales the value to
109
- // 0-10 with 0 representing well balanced allocation and 10 poorly balanced. Subtracting it from
110
- // 10 leads to the score which also scales from 0 to 10 while 10 representing well balanced.
108
+ // respectively. Multiplying the absolute value of the difference by `MaxNodeScore` scales the value to
109
+ // 0-MaxNodeScore with 0 representing well balanced allocation and `MaxNodeScore` poorly balanced. Subtracting it from
110
+ // `MaxNodeScore` leads to the score which also scales from 0 to `MaxNodeScore` while `MaxNodeScore` representing well balanced.
111
111
diff := math .Abs (cpuFraction - memoryFraction )
112
112
return int64 ((1 - diff ) * float64 (framework .MaxNodeScore ))
113
113
}
0 commit comments