8

I'm updating some code from 2.9.1 to 2.10.0 (and I tried 2.10.1 with the same results), using SBT 0.12.1 in both cases.

When I run sbt clean compile on the command line, they both complete after about 250 seconds.

However, when I run sbt interactively, and repeatedly enter clean then compile, my 2.9 compiles get faster, but my 2.10 compiles get 10x slower.

If I use a heap size of 768m, 2.10 runs out of memory on the 3rd compile. With a heap size of 4g, it's able to compile each time, but always 10x slower after the first iteration.

[success] Total time: 258 s, completed Mar 14, 2013 10:44:34 AM
[success] Total time: 2048 s, completed Mar 14, 2013 11:23:03 AM
[success] Total time: 2049 s, completed Mar 14, 2013 11:58:42 AM
[success] Total time: 2047 s, completed Mar 14, 2013 12:43:19 PM

What is the best way for me to debug to find out what's going on?

4

2 回答 2

7

谢谢你的CodeCache 链接。我最初驳回了它,因为使用其建议的-XX:+UseCodeCacheFlushing选项没有任何改进,但我只是尝试使用-XX:ReservedCodeCacheSize=2g并解决了问题。

有谁知道为什么-XX:+UseCodeCacheFlushing没有帮助,或者所有代码缓存 java 选项的一些推荐值?

为了好玩,这是我使用的编译时间-XX:+HeapDumpOnOutOfMemoryError -server -XX:ReservedCodeCacheSize=2g -Xmx4g -Xss4M -XX:MaxPermSize=512M -XX:+DoEscapeAnalysis -XX:+UseCompressedOops -XX:+CMSClassUnloadingEnabled -XX:+UseCodeCacheFlushing

2.10.1 (interactive, repeating clean/compile)
    194 s
    149 s
    95 s
    87 s
    84 s
2.9.1 (interactive, repeating clean/compile)
    187 s
    129 s
    83 s
    77 s
    74 s
2.10.1 (batch sbt clean compile)
    195 s
2.9.1 (batch sbt clean compile)
    177 s
于 2013-03-17T00:25:51.300 回答
0

您可以从附加分析器或监视器开始,以查看 GC 发生了什么。要初步了解像 JVisualVM 这样的库存工具,应该就足够了。当然,如果你有 YourKit,那也可以。

附录

作为一个有点有趣但现在基本上无关紧要的事情,我最近发现 Scala 2.9.0-1 在编译 Specs2 测试时非常慢(至少是不可变的)。切换到 2.9.1 带来了巨大的变化。当我不得不向以前没有任何单元测试的项目添加一些单元测试并且编译时间变得痛苦时,我才注意到它。预感我切换到 2.9.1,一切恢复正常。

于 2013-03-14T17:52:35.503 回答