yangwwei commented on a change in pull request #323:
URL: 
https://github.com/apache/incubator-yunikorn-core/pull/323#discussion_r710346574



##########
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:
       OK, that also makes sense. Normalization causes extra computes, based on 
your point: Modern CPUs can calculate and operate on 64-bit floats basically as 
quickly as ints. I guess we are good for now. Memory is not a major concern 
right now.




-- 
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]


Reply via email to