Github user mridulm commented on a diff in the pull request:

    https://github.com/apache/spark/pull/636#discussion_r12381217
  
    --- Diff: core/src/main/scala/org/apache/spark/deploy/master/Master.scala 
---
    @@ -523,6 +504,90 @@ private[spark] class Master(
         }
       }
     
    +  private def startMultiExecutorsPerWorker() {
    +    // allow user to run multiple executors in the same worker
    +    // (within the same worker JVM process)
    +    if (spreadOutApps) {
    +      for (app <- waitingApps if app.coresLeft > 0) {
    +        val coreNumPerExecutor = app.desc.corePerExecutor
    +        var usableWorkers = workers.toArray.filter(_.state == 
WorkerState.ALIVE)
    +          .filter(_.coresFree > 0).sortBy(_.coresFree).reverse
    +        var leftCoreToAssign = math.min(app.coresLeft, 
usableWorkers.map(_.coresFree).sum)
    +        val numUsable = usableWorkers.length
    +        // Number of cores of each executor assigned to each worker
    +        val assigned = Array.fill[ListBuffer[Int]](numUsable)(new 
ListBuffer[Int])
    +        var pos = 0
    +        val memoryNotEnoughFlags = new Array[Boolean](numUsable)
    +        while (leftCoreToAssign > 0 && 
memoryNotEnoughFlags.contains(false)) {
    +          val coreToAssign = math.min(coreNumPerExecutor, leftCoreToAssign)
    +          if (usableWorkers(pos).coresFree - assigned(pos).sum >= 
coreToAssign &&
    +            !memoryNotEnoughFlags(pos)) {
    +            if (usableWorkers(pos).memoryFree >=
    +              app.desc.memoryPerExecutor * (assigned(pos).length + 1)) {
    +              leftCoreToAssign -= coreToAssign
    +              assigned(pos) += coreToAssign
    +            } else {
    +              memoryNotEnoughFlags(pos) = true
    +            }
    +          }
    +          pos = (pos + 1) % numUsable
    +        }
    --- End diff --
    
    This loop need not terminate in all cases.
    For example: required 2 cores per executor; cluster has 10 nodes, each with 
3 cores - and 2 cores of each is already being used.
    Then we are stuck in an infinite loop.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to