Skip to content

Commit ebcde10

Browse files
committed
Modify default YARN memory_overhead-- from an additive constant to a multiplier (redone to resolve merge conflicts)
1 parent 2e69f11 commit ebcde10

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

docs/running-on-yarn.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ Most of the configs are the same for Spark on YARN as for other deployment modes
7979
</tr>
8080
<tr>
8181
<td><code>spark.yarn.executor.memoryOverhead</code></td>
82-
<td>384</td>
82+
<td>executorMemory * 0.07, with minimum of 384 </td>
8383
<td>
8484
The amount of off heap memory (in megabytes) to be allocated per executor. This is memory that accounts for things like VM overheads, interned strings, other native overheads, etc.
8585
</td>
8686
</tr>
8787
<tr>
8888
<td><code>spark.yarn.driver.memoryOverhead</code></td>
89-
<td>384</td>
89+
<td>driverMemory * 0.07, with minimum of 384 </td>
9090
<td>
9191
The amount of off heap memory (in megabytes) to be allocated per driver. This is memory that accounts for things like VM overheads, interned strings, other native overheads, etc.
9292
</td>

out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Already up-to-date.

yarn/common/src/main/scala/org/apache/spark/deploy/yarn/ClientBase.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ trait ClientBase extends Logging {
6161

6262
// Additional memory overhead - in mb.
6363
protected def memoryOverhead: Int = sparkConf.getInt("spark.yarn.driver.memoryOverhead",
64-
YarnSparkHadoopUtil.DEFAULT_MEMORY_OVERHEAD)
64+
math.max((YarnSparkHadoopUtil.MEMORY_OVERHEAD_FACTOR * args.amMemory).toInt,
65+
YarnSparkHadoopUtil.MEMORY_OVERHEAD_MIN))
6566

6667
// TODO(harvey): This could just go in ClientArguments.
6768
def validateArgs() = {

yarn/common/src/main/scala/org/apache/spark/deploy/yarn/YarnAllocator.scala

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,6 @@ private[yarn] abstract class YarnAllocator(
7878
// Containers to be released in next request to RM
7979
private val releasedContainers = new ConcurrentHashMap[ContainerId, Boolean]
8080

81-
// Additional memory overhead - in mb.
82-
protected val memoryOverhead: Int = sparkConf.getInt("spark.yarn.executor.memoryOverhead",
83-
YarnSparkHadoopUtil.DEFAULT_MEMORY_OVERHEAD)
84-
8581
// Number of container requests that have been sent to, but not yet allocated by the
8682
// ApplicationMaster.
8783
private val numPendingAllocate = new AtomicInteger()
@@ -97,6 +93,11 @@ private[yarn] abstract class YarnAllocator(
9793
protected val (preferredHostToCount, preferredRackToCount) =
9894
generateNodeToWeight(conf, preferredNodes)
9995

96+
// Additional memory overhead - in mb.
97+
protected val memoryOverhead: Int = sparkConf.getInt("spark.yarn.executor.memoryOverhead",
98+
math.max((YarnSparkHadoopUtil.MEMORY_OVERHEAD_FACTOR * executorMemory).toInt,
99+
YarnSparkHadoopUtil.MEMORY_OVERHEAD_MIN))
100+
100101
private val launcherPool = new ThreadPoolExecutor(
101102
// max pool size of Integer.MAX_VALUE is ignored because we use an unbounded queue
102103
sparkConf.getInt("spark.yarn.containerLauncherMaxThreads", 25), Integer.MAX_VALUE,
@@ -117,9 +118,10 @@ private[yarn] abstract class YarnAllocator(
117118

118119
if (missing > 0) {
119120
numPendingAllocate.addAndGet(missing)
120-
logInfo("Will Allocate %d executor containers, each with %d memory".format(
121+
logInfo("Will Allocate %d executor containers, each with %d+%d MB memory".format(
121122
missing,
122-
(executorMemory + memoryOverhead)))
123+
executorMemory,
124+
memoryOverhead))
123125
} else {
124126
logDebug("Empty allocation request ...")
125127
}

yarn/common/src/main/scala/org/apache/spark/deploy/yarn/YarnSparkHadoopUtil.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ class YarnSparkHadoopUtil extends SparkHadoopUtil {
8585
}
8686

8787
object YarnSparkHadoopUtil {
88-
// Additional memory overhead - in mb.
89-
val DEFAULT_MEMORY_OVERHEAD = 384
88+
// Additional memory overhead
89+
val MEMORY_OVERHEAD_FACTOR = 0.07
90+
val MEMORY_OVERHEAD_MIN = 384
9091

9192
val ANY_HOST = "*"
9293

0 commit comments

Comments
 (0)