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

    https://github.com/apache/spark/pull/8017#discussion_r36542315
  
    --- Diff: core/src/main/scala/org/apache/spark/deploy/master/Master.scala 
---
    @@ -591,9 +591,15 @@ private[deploy] class Master(
               true
             }
           val assignedMemory = assignedExecutors(pos) * memoryPerExecutor
    -      usableWorkers(pos).memoryFree - assignedMemory >= memoryPerExecutor 
&&
    +      val enoughMemory =
    +        if (launchingNewExecutor) {
    +          usableWorkers(pos).memoryFree - assignedMemory >= 
memoryPerExecutor
    +        } else {
    +          true
    +        }
           usableWorkers(pos).coresFree - assignedCores(pos) >= 
minCoresPerExecutor &&
           coresToAssign >= minCoresPerExecutor &&
    +      enoughMemory &&
           underLimit
    --- End diff --
    
    would you mind rewriting this as follows now that we have more shared code?
    ```
    val keepScheduling = coresToAssign >= minCoresPerExecutor
    val enoughCores = usableWorkers(pos).coresFree - assignedCores(pos) >= 
minCoresPerExecutor
    
    // If we allow multiple executors per worker, then we can always launch new 
executors.
    // Otherwise, if there is already an executor on this worker, just give it 
more cores.
    val launchingNewExecutor = !oneExecutorPerWorker || assignedExecutors(pos) 
== 0
    if (launchingNewExecutor) {
      val assignedMemory = assignedExecutors(pos) * memoryPerExecutor
      val enoughMemory = usableWorkers(pos).memoryFree - assignedMemory >= 
memoryPerExecutor
      val underLimit = assignedExecutors.sum + app.executors.size < 
app.executorLimit
      keepScheduling && enoughCores && enoughMemory && underLimit
    } else {
      // We're adding cores to an existing executor, so no need to check memory 
and executor limits
      keepScheduling && enoughCores
    }
    ```


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to