繁体   English   中英

“spark.yarn.executor.memoryOverhead”和“spark.memory.offHeap.size”之间的区别

[英]Difference between “spark.yarn.executor.memoryOverhead” and “spark.memory.offHeap.size”

我在纱线上运行火花。 我不明白以下设置spark.yarn.executor.memoryOverheadspark.memory.offHeap.size有什么区别。 两者似乎都是将堆外 memory 分配给 spark executor 的设置。 我应该使用哪一个? 另外,执行程序堆外 memory 的推荐设置是什么?

非常感谢!

spark.executor.memoryOverhead被 YARN 等资源管理使用,而spark.memory.offHeap.size被 Spark 核心(内存管理器)使用。 关系因版本而有所不同。

Spark 2.4.5 及之前版本:

spark.executor.memoryOverhead应该包括spark.memory.offHeap.size 这意味着如果您指定offHeap.size ,则需要手动将此部分添加到 YARN 的memoryOverhead中。 正如您从YarnAllocator.scala的以下代码中看到的那样,当 YARN 请求资源时,它对offHeap.size

private[yarn] val resource = Resource.newInstance(
    executorMemory + memoryOverhead + pysparkWorkerMemory,
    executorCores)

但是,Spark 3.0 中的行为发生了变化:

spark.executor.memoryOverhead不再包括spark.memory.offHeap.size YARN 会在请求资源时为您包含offHeap.size 从新文档中:

Note: Additional memory includes PySpark executor memory (when spark.executor.pyspark.memory is not configured) and memory used by other non-executor processes running in the same container. The maximum memory size of container to running executor is determined by the sum of spark.executor.memoryOverhead, spark.executor.memory, spark.memory.offHeap.size and spark.executor.pyspark.memory.

代码中您还可以看出:

private[yarn] val resource: Resource = {
    val resource = Resource.newInstance(
      executorMemory + executorOffHeapMemory + memoryOverhead + pysparkWorkerMemory, executorCores)
    ResourceRequestHelper.setResourceRequests(executorResourceRequests, resource)
    logDebug(s"Created resource capability: $resource")
    resource
  }

有关此更改的更多详细信息,您可以参考此 Pull Request

对于您的第二个问题,executor offheap memory 的推荐设置是什么? 这取决于您的应用程序,您需要进行一些测试。 我发现页面有助于进一步解释:

堆外 memory 是减少 GC 暂停的好方法,因为它不在 GC 的 scope 中。 但是,它带来了序列化和反序列化的开销。 后者反过来使得堆外数据有时可以放入堆 memory 并因此暴露给 GC。 此外,Project Tungsten(字节数组)带来的新数据格式有助于减少 GC 开销。 这两个原因使得在 Apache Spark 应用程序中使用堆外 memory 应该仔细规划,尤其是经过测试。

顺便说一句, spark.yarn.executor.memoryOverhead已弃用并更改为spark.executor.memoryOverhead ,这对于 YARN 和 Kubernetes 很常见。

  1. spark.yarn.executor.memoryOverhead在 StaticMemoryManager 中使用。 这用于较旧的 Spark 版本,如 1.2。

每个执行程序分配的堆外 memory(以兆字节为单位)的数量。 这是 memory,它考虑了 VM 开销、内部字符串、其他本机开销等。这往往会随着执行程序的大小(通常为 6-10%)而增长。

你可以在旧的 Spark 文档中找到这个,比如 Spark1.2 文档:

https://spark.apache.org/docs/1.2.0/running-on-yarn.html

  1. 在UnifiedMemoryManager中使用spark.memory.offHeap.size ,1.6版本以后默认使用

可用于堆外分配的 memory 的绝对数量(以字节为单位)。 此设置对堆 memory 的使用没有影响,因此如果您的执行程序的总 memory 消耗必须符合某个硬限制,那么请务必相应地缩小您的 JVM 堆大小。 当 spark.memory.offHeap.enabled=true 时,这必须设置为正值。

你可以在最新的 Spark 文档中找到这个,比如 Spark2.4 文档:

https://spark.apache.org/docs/2.4.4/configuration.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM