craigcondit commented on a change in pull request #323:
URL:
https://github.com/apache/incubator-yunikorn-core/pull/323#discussion_r710191726
##########
File path: pkg/scheduler/objects/nodesorting.go
##########
@@ -42,33 +48,79 @@ func (fairnessNodeSortingPolicy) PolicyType()
policies.SortingPolicy {
return policies.FairnessPolicy
}
-func (binPackingNodeSortingPolicy) ScoreNode(node *Node) float64 {
- // choose most loaded node first
- return resources.LargestUsageShare(node.GetAvailableResource())
+func absResourceUsage(node *Node, weights *map[string]float64) float64 {
+ totalWeight := float64(0)
+ usage := float64(0)
+
+ shares := node.GetResourceUsageShares()
+ for k, v := range shares {
+ weight, found := (*weights)[k]
+ if !found || weight == float64(0) {
+ continue
+ }
+ if math.IsNaN(v) {
+ continue
+ }
+ usage += v * weight
+ totalWeight += weight
+ }
+
+ var result float64
+
+ if totalWeight == float64(0) {
+ result = float64(0)
+ } else {
+ result = usage / totalWeight
+ }
+ return result
Review comment:
If we are allowing fractional weights (and I think that's imperative) we
really do need fractional calculations. Modern CPUs can calculate and operate
on 64-bit floats basically as quickly as ints, and we don't do it often enough
for this to matter. I've seen optimizations like this in the past result in
really weird edge cases where rounding doesn't behave as expected.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]