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

    https://github.com/apache/spark/pull/13338#discussion_r66685237
  
    --- Diff: core/src/main/scala/org/apache/spark/util/Utils.scala ---
    @@ -2262,21 +2262,39 @@ private[spark] object Utils extends Logging {
       }
     
       /**
    -   * Return whether dynamic allocation is enabled in the given conf
    -   * Dynamic allocation and explicitly setting the number of executors are 
inherently
    -   * incompatible. In environments where dynamic allocation is turned on 
by default,
    -   * the latter should override the former (SPARK-9092).
    +   * Return whether dynamic allocation is enabled in the given conf.
        */
       def isDynamicAllocationEnabled(conf: SparkConf): Boolean = {
    -    val numExecutor = conf.getInt("spark.executor.instances", 0)
         val dynamicAllocationEnabled = 
conf.getBoolean("spark.dynamicAllocation.enabled", false)
    -    if (numExecutor != 0 && dynamicAllocationEnabled) {
    -      logWarning("Dynamic Allocation and num executors both set, thus 
dynamic allocation disabled.")
    -    }
    -    numExecutor == 0 && dynamicAllocationEnabled &&
    +    dynamicAllocationEnabled &&
           (!isLocalMaster(conf) || 
conf.getBoolean("spark.dynamicAllocation.testing", false))
       }
     
    +  /**
    +   * Return the minimum number of executors for dynamic allocation.
    +   */
    +  def getDynamicAllocationMinExecutors(conf: SparkConf): Int = {
    +    conf.getInt("spark.dynamicAllocation.minExecutors", 0)
    +  }
    +
    +  /**
    +   * Return the maximum number of executors for dynamic allocation.
    +   */
    +  def getDynamicAllocationMaxExecutors(conf: SparkConf): Int = {
    +    conf.getInt("spark.dynamicAllocation.maxExecutors", Integer.MAX_VALUE)
    +  }
    +
    +  /**
    +   * Return the initial number of executors for dynamic allocation.
    +   */
    +  def getDynamicAllocationInitialExecutors(conf: SparkConf): Int = {
    +    math.max(
    +      math.max(
    +        conf.getInt("spark.dynamicAllocation.initialExecutors", 0),
    --- End diff --
    
    I'm not sure what you mean by the config API can't handle both calls to max.
    
    I'm happy to make the change for this to be more readable, but I think we 
should decide on semantics first. I think a reasonable way to handle this is to 
use the max of all 3, as implemented. The min value should clearly be handled 
this way -- starting at initial less than min causes an immediate change to the 
min -- so the question is how to handle both `spark.executor.instances` and 
`spark.dynamicAllocation.initialExecutors`.
    
    I think it's reasonable to use either one in different situations so I 
don't think it makes much sense to complain if they're both set. My job could 
have initialExecutors set in its config, but I can run it with --num-executors 
to bump up the value. Given that use case, I don't think it would be a good 
idea to have initialExecutors override spark.executor.instances.
    
    That leaves whether spark.executor.instances should override 
initialExecutors or whether the initial number should be the max of the two. I 
don't have a strong opinion here, but I opted for the max of the two values.


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