Skip to content

Commit e16f190

Browse files
committed
different memoryOverhead
1 parent ffa7569 commit e16f190

File tree

3 files changed

+33
-8
lines changed

3 files changed

+33
-8
lines changed

yarn/alpha/src/main/scala/org/apache/spark/deploy/yarn/YarnAllocationHandler.scala

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,16 @@ private[yarn] class YarnAllocationHandler(
8989
private val pendingReleaseContainers = new ConcurrentHashMap[ContainerId, Boolean]
9090

9191
// Additional memory overhead - in mb.
92-
private val memoryOverhead = sparkConf.getInt("spark.yarn.container.memoryOverhead",
93-
YarnAllocationHandler.MEMORY_OVERHEAD)
92+
private def memoryOverhead: Int = {
93+
var defaultMemoryOverhead = YarnAllocationHandler.MEMORY_OVERHEAD
94+
sparkConf.getOption("spark.yarn.container.memoryOverhead").foreach { s =>
95+
defaultMemoryOverhead = s.toInt
96+
}
97+
sparkConf.getOption(s"spark.yarn.executor.memoryOverhead").foreach { s =>
98+
defaultMemoryOverhead = s.toInt
99+
}
100+
defaultMemoryOverhead
101+
}
94102

95103
private val numExecutorsRunning = new AtomicInteger()
96104
// Used to generate a unique id per executor

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,16 @@ trait ClientBase extends Logging {
6666
FsPermission.createImmutable(Integer.parseInt("644", 8).toShort)
6767

6868
// Additional memory overhead - in mb.
69-
def memoryOverhead = sparkConf.getInt("spark.yarn.container.memoryOverhead",
70-
YarnAllocationHandler.MEMORY_OVERHEAD)
69+
protected def memoryOverhead: Int = {
70+
var defaultMemoryOverhead = (args.amMemory * 0.25D).ceil.toInt
71+
sparkConf.getOption("spark.yarn.container.memoryOverhead").foreach { s =>
72+
defaultMemoryOverhead = s.toInt
73+
}
74+
sparkConf.getOption(s"spark.yarn.driver.memoryOverhead").foreach { s =>
75+
defaultMemoryOverhead = s.toInt
76+
}
77+
defaultMemoryOverhead
78+
}
7179

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

yarn/stable/src/main/scala/org/apache/spark/deploy/yarn/YarnAllocationHandler.scala

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,20 @@ private[yarn] class YarnAllocationHandler(
9090
// Containers to be released in next request to RM
9191
private val pendingReleaseContainers = new ConcurrentHashMap[ContainerId, Boolean]
9292

93-
// TODO: Here we can dynamically calculate the default value.
94-
// eg: val memoryOverhead = (executorMemory * 0.25D).ceil.toInt
9593
// Additional memory overhead - in mb.
96-
private val memoryOverhead = sparkConf.getInt("spark.yarn.container.memoryOverhead",
97-
YarnAllocationHandler.MEMORY_OVERHEAD)
94+
private def memoryOverhead: Int = {
95+
// TODO: Here we can dynamically calculate the default value.
96+
// eg: val defaultMemoryOverhead = (executorMemory * 0.25D).ceil.toInt
97+
var defaultMemoryOverhead = YarnAllocationHandler.MEMORY_OVERHEAD
98+
sparkConf.getOption("spark.yarn.container.memoryOverhead").foreach { s =>
99+
defaultMemoryOverhead = s.toInt
100+
}
101+
sparkConf.getOption(s"spark.yarn.executor.memoryOverhead").foreach { s =>
102+
defaultMemoryOverhead = s.toInt
103+
}
104+
defaultMemoryOverhead
105+
}
106+
98107

99108
// Number of container requests that have been sent to, but not yet allocated by the
100109
// ApplicationMaster.

0 commit comments

Comments
 (0)