我们的 Spark 执行器日志有这些:
org.apache.spark.rpc.RpcTimeoutException: Futures timed out after [10 seconds]. This timeout is controlled by spark.executor.heartbeatInterval
弄清楚这些是从执行程序到驱动程序的心跳,我怀疑驱动程序上有 GC 问题,因此启用了 GC 日志记录,并发现了这些:
[Full GC (System.gc()) 5402.271: [CMS: 10188280K->8448710K(14849412K),27.2815605 secs] 10780958K->8448710K(15462852K), [Metaspace: 93432K->93432K(96256K)], 27.2833999 secs] [Times: user=27.28 sys=0.01, real=27.29 secs]
显然,某些东西调用了 System.gc(),导致驱动程序出现像这样的长时间 GC 暂停(27 秒)。进一步看,RMI 值得怀疑,因为这些 System.gc()
调用恰好每 30 分钟发生一次。
我在 Spark 驱动程序上找不到关于此问题的任何引用。我应该继续通过设置 -XX:+DisableExplicitGC
来禁用 System.gc()
调用吗?
最佳答案
很有趣,我只是在研究类似的问题。我可以看到 Spark 中的某些代码实际上确实调用了 System.gc()
。
可能值得在 Spark 中打开一个 JIRA 来讨论这个问题。
我知道使用 System.gc()
进行调用不是最佳做法,主要是因为它会停止对性能有重大影响的所有其他线程。但是,我可以在 Java Oracle 文档中看到,从 Java 1.6 开始引入了一个额外的 JVM 参数,以便同时运行 System.gc()
(-XX:+ExplicitGCInvokesConcurrent):
http://docs.oracle.com/javase/6/docs/technotes/guides/vm/cms-6.html
您也许可以尝试将其设置为附加参数:
spark.executor.extraJavaOptions="-XX:+ExplicitGCInvokesConcurrent"
根据您设置参数的方式,您可以将其放入 Spark 的配置文件中,或者使用 spark 命令(spark-submit、spark-shell 等)中的 --conf 行参数传递它。 ).
更新:
在 Spark 2.x 的 ContextCleaner.scala 文件中找到以下注释:
/**
* How often to trigger a garbage collection in this JVM.
*
* This context cleaner triggers cleanups only when weak references are garbage collected.
* In long-running applications with large driver JVMs, where there is little memory pressure
* on the driver, this may happen very occasionally or not at all. Not cleaning at all may
* lead to executors running out of disk space after a while.
*/
关于java - Spark 驱动程序的 RMI 库导致 Full GC 暂停(System.gc()),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45597878/