-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-1953][YARN]yarn client mode Application Master memory size is same as driver memory... #3607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0566bb8
6fd13e1
44e48c2
ab16bb5
b09c309
d619996
f6bee0e
7fa9e2e
1960d16
69c7dba
42075b0
2557c5e
b7acbb2
2b27928
987b99d
3bf70cc
ddcd592
b8410c0
6c1b264
d5ceb1b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,23 +38,27 @@ private[spark] class ClientArguments(args: Array[String], sparkConf: SparkConf) | |
| var amMemory: Int = 512 // MB | ||
| var appName: String = "Spark" | ||
| var priority = 0 | ||
| def isClusterMode: Boolean = userClass != null | ||
|
|
||
| private var driverMemory: Int = 512 // MB | ||
| private val driverMemOverheadKey = "spark.yarn.driver.memoryOverhead" | ||
| private val amMemKey = "spark.yarn.am.memory" | ||
| private val amMemOverheadKey = "spark.yarn.am.memoryOverhead" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see this config being used to set anything? ie set amMemoryOverhead |
||
| private val isDynamicAllocationEnabled = | ||
| sparkConf.getBoolean("spark.dynamicAllocation.enabled", false) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer you move this up there with other |
||
|
|
||
| parseArgs(args.toList) | ||
| loadEnvironmentArgs() | ||
| validateArgs() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. minor point, but when I refactored this I made sure to keep these three things (parseArgs ... validateArgs) right after each other so it's easy to follow what the order is. I would move |
||
|
|
||
| // Additional memory to allocate to containers | ||
| // For now, use driver's memory overhead as our AM container's memory overhead | ||
| val amMemoryOverhead = sparkConf.getInt("spark.yarn.driver.memoryOverhead", | ||
| val amMemoryOverheadConf = if (isClusterMode) driverMemOverheadKey else amMemOverheadKey | ||
| val amMemoryOverhead = sparkConf.getInt(amMemoryOverheadConf, | ||
| math.max((MEMORY_OVERHEAD_FACTOR * amMemory).toInt, MEMORY_OVERHEAD_MIN)) | ||
|
|
||
| val executorMemoryOverhead = sparkConf.getInt("spark.yarn.executor.memoryOverhead", | ||
| math.max((MEMORY_OVERHEAD_FACTOR * executorMemory).toInt, MEMORY_OVERHEAD_MIN)) | ||
|
|
||
| private val isDynamicAllocationEnabled = | ||
| sparkConf.getBoolean("spark.dynamicAllocation.enabled", false) | ||
|
|
||
| loadEnvironmentArgs() | ||
| validateArgs() | ||
|
|
||
| /** Load any default arguments provided through environment variables and Spark properties. */ | ||
| private def loadEnvironmentArgs(): Unit = { | ||
| // For backward compatibility, SPARK_YARN_DIST_{ARCHIVES/FILES} should be resolved to hdfs://, | ||
|
|
@@ -87,6 +91,21 @@ private[spark] class ClientArguments(args: Array[String], sparkConf: SparkConf) | |
| throw new IllegalArgumentException( | ||
| "You must specify at least 1 executor!\n" + getUsageMessage()) | ||
| } | ||
| if (isClusterMode) { | ||
| for (key <- Seq(amMemKey, amMemOverheadKey)) { | ||
| if (sparkConf.contains(key)) { | ||
| println(s"$key is set but does not apply in cluster mode.") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think you want to use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As BTW, |
||
| } | ||
| } | ||
| amMemory = driverMemory | ||
| } else { | ||
| if (sparkConf.contains(driverMemOverheadKey)) { | ||
| println(s"$driverMemOverheadKey is set but does not apply in client mode.") | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This warning doesn't make sense. It's a perfectly reasonable thing for YARN users to set the driver memory in client mode. |
||
| sparkConf.getOption(amMemKey) | ||
| .map(Utils.memoryStringToMb) | ||
| .foreach(mem => amMemory = mem) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unindent, I will fix when I merge |
||
| } | ||
| } | ||
|
|
||
| private def parseArgs(inputArgs: List[String]): Unit = { | ||
|
|
@@ -118,7 +137,7 @@ private[spark] class ClientArguments(args: Array[String], sparkConf: SparkConf) | |
| if (args(0) == "--master-memory") { | ||
| println("--master-memory is deprecated. Use --driver-memory instead.") | ||
| } | ||
| amMemory = value | ||
| driverMemory = value | ||
| args = tail | ||
|
|
||
| case ("--num-workers" | "--num-executors") :: IntParam(value) :: tail => | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,8 +68,6 @@ private[spark] class YarnClientSchedulerBackend( | |
| // List of (target Client argument, environment variable, Spark property) | ||
| val optionTuples = | ||
| List( | ||
| ("--driver-memory", "SPARK_MASTER_MEMORY", "spark.master.memory"), | ||
| ("--driver-memory", "SPARK_DRIVER_MEMORY", "spark.driver.memory"), | ||
| ("--num-executors", "SPARK_WORKER_INSTANCES", "spark.executor.instances"), | ||
| ("--num-executors", "SPARK_EXECUTOR_INSTANCES", "spark.executor.instances"), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wait, why remove these?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since in
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah ok. Also it doesn't really make sense to pass driver memory on in client mode anyway, because the driver by definition has already started when |
||
| ("--executor-memory", "SPARK_WORKER_MEMORY", "spark.executor.memory"), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be nice to add comment to spark.yarn.driver.memoryOverhead saying it applies in cluster mode.
This config is a bit different from the others as the memory overhead is purely a yarn thing and doesn't apply in other modes. ie There is no existing spark.driver.memoryOverhead. We could potentially just use one config for this. I'm not sure if that will be more confusing or not though... @sryza @vanzin @andrewor14 thoughts on that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it more confusing to collapse these two configs. It's immediately intuitive that
spark.yarn.am.memoryOverheadis the overhead applied on top ofspark.yarn.am.memorysince they share the same prefix, but it's not at all clear to me thatspark.driver.memoryOverheadis related at all (assuming the user does not have expertise in how different deploy modes are architected).But yes we should definitely add a comment in
spark.yarn.driver.memoryOverheadto say it's only for cluster mode.