在JVM上启用了逃逸分析的经验 [英] Experiences with escape analysis enabled on the JVM

查看:344
本文介绍了在JVM上启用了逃逸分析的经验的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚尝试在 jdk6-u18 VM(在solaris上)启用了 -XX:+ DoEscapeAnalysis 选项令人失望的经历。我正在运行一个scala应用程序,它有很多演员(其中有20,000个)。这是垃圾创建的秘诀!

I've just tried the -XX:+DoEscapeAnalysis option enabled on a jdk6-u18 VM (on solaris) and had a rather disappointing experience. I'm running a scala application which has rather a lot of actors (20,000 of them). This is a recipe for garbage-creation!

通常,应用程序可以运行256Mb的堆,但会生成巨大的垃圾量。在稳定状态它:

Typically the app can run with 256Mb of heap but generates huge amounts of garbage. In its steady state it:


  • 在GC中花费10%的时间

  • 在< 30s内产生> 150Mb的垃圾然后得到GC

我认为逃逸分析可能有帮助所以我启用该选项并重新运行该应用程序。我发现应用程序变得越来越无法清除它收集的垃圾,直到最终花费整个时间做GC并且应用程序在完全分配时平坦化。

I thought that escape analysis might help so I enabled the option and re-ran the app. I found that the app became increasingly unable to clear away the garbage it had collected until it seemed eventually to spend the entire time doing GC and the app was "flatlining" at its full allocation.

此时我应该说应用程序没有抛出我原本期望的 OutOfMemoryError 。也许 JConsole (我用它来执行分析)没有正确显示带有此选项的GC统计数据(我不相信)?

At this point I should say that the app did not throw a OutOfMemoryError which I would have expected. Perhaps JConsole (which I was using to perform the analysis) does not properly display GC stats with this option on (I'm not convinced)?

然后我删除了该选项并重新启动,应用程序再次变为正常!任何人都知道可能会发生什么?

I then removed the option and restarted and the app became "normal" again! Anyone have any idea what might be going on?

推荐答案

1 逃脱分析是否显示为在JConsole中启用?您需要确保使用-server选项运行VM。我认为你有这个工作,但我只是想我会检查。

1 Did the escape analysis show up as being enabled in JConsole? You need make sure you're running the VM with the -server option. I assume you had this working, but I just thought I'd check.

2 我认为逃避分析不会有助于这种情况与Scala Actors合作。如果您执行以下操作,您可能会看到很大的收益:

2 I don't think escape analysis will help the situation with Scala Actors. You might see a big gain if you do something like:

def act():Unit = {
   val omgHugeObject = new OMGHugeObject();
   omgHugeObject.doSomethingCrazy();
 }

在上面的示例中,EscapeAnalysis会使它如此 omgHugeObject 可以在堆栈而不是堆上分配,因此不会产生垃圾。我认为逃脱分析不太可能对演员有所帮助。他们的引用总是逃避到actor子系统。

In the example above the EscapeAnalysis would make it so omgHugeObject could be allocated on the stack instead of the heap and thus not create garbage. I don't think it is likely that the escape analysis will help with actors. Their references will always "escape" to the actor subsystem.

3
你是否在Scala的最新版本中?有一个内存泄漏,我相信在最近的版本中修复了。这甚至导致 Lift 产生你可能会查看的自己的Actor库。

3 Are you on the most recent release of Scala? There was a memory leak that I believe was fixed in a recent version. This even caused Lift to spawn off its own Actor library that you might look into.

4 你可以试试G1Garbage收藏家你可以用以下方式启用它:

4 You might try the G1Garbage collector You can enable it with:

-XX :+ UnlockExperimentalVMOptions -XX:+ UseG1GC

这篇关于在JVM上启用了逃逸分析的经验的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆