viirya commented on code in PR #44906:
URL: https://github.com/apache/spark/pull/44906#discussion_r1468231807


##########
core/src/main/scala/org/apache/spark/deploy/master/Master.scala:
##########
@@ -824,9 +827,15 @@ private[deploy] class Master(
         // If the cores left is less than the coresPerExecutor,the cores left 
will not be allocated
         if (app.coresLeft >= coresPerExecutor) {
           // Filter out workers that don't have enough resources to launch an 
executor
-          val usableWorkers = workers.toArray.filter(_.state == 
WorkerState.ALIVE)
+          val aliveWorkers = workers.toArray.filter(_.state == 
WorkerState.ALIVE)
             .filter(canLaunchExecutor(_, resourceDesc))
-            .sortBy(_.coresFree).reverse
+          val usableWorkers = workerSelectionPolicy match {
+            case CORES_FREE_ASC => aliveWorkers.sortBy(w => (w.coresFree, 
w.id))
+            case CORES_FREE_DESC => aliveWorkers.sortBy(w => (w.coresFree, 
w.id)).reverse

Review Comment:
   Hmm, this seems to sort workers by `(free cores, id)`? Shouldn't we sort 
them by free cores only?



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to