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

    https://github.com/apache/spark/pull/4168#discussion_r24367502
  
    --- Diff: 
core/src/main/scala/org/apache/spark/ExecutorAllocationManager.scala ---
    @@ -224,54 +241,75 @@ private[spark] class ExecutorAllocationManager(
       }
     
       /**
    +   * Check to see whether our existing allocation and the requests we've 
made previously exceed our
    +   * current needs. If so, let the cluster manager know so that it can 
cancel pending requests that
    +   * are unneeded.
    +   *
    +   * If not, and the add time has expired, see if we can request new 
executors and refresh the add
    +   * time.
    +   *
    +   * @return the delta in the target number of executors.
    +   */
    +  private def adjustRequestedExecutors(now: Long): Int = synchronized {
    +    val currentTarget = targetNumExecutors
    +    val maxNeeded = maxNumExecutorsNeeded
    +
    +    if (maxNeeded < currentTarget) {
    +      // The target number exceeds the number we actually need, so stop 
adding new
    +      // executors and inform the cluster manager to cancel the extra 
pending requests.
    +      client.requestTotalExecutors(maxNeeded)
    +      val delta = math.min(maxNeeded - currentTarget, 0)
    +      numExecutorsPending += delta
    +      numExecutorsToAdd = 1
    +      delta
    +    } else if (addTime != NOT_SET && now >= addTime) {
    +      val delta = addExecutors(maxNeeded)
    +      logDebug(s"Starting timer to add more executors (to " +
    +        s"expire in $sustainedSchedulerBacklogTimeout seconds)")
    +      addTime += sustainedSchedulerBacklogTimeout * 1000
    +      delta
    +    } else {
    +      0
    +    }
    +  }
    --- End diff --
    
    I see what you mean.  `maybeAddExecutors` would be a little confusing 
because we might cancel requests.  What do you think of 
`addOrCancelExecutorRequests`?



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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to