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?

2

2 Answers 2

7

Thank you retronym for the CodeCache link. I initially dismissed it, since using its suggested -XX:+UseCodeCacheFlushing option made no improvements, but I just tried using -XX:ReservedCodeCacheSize=2g and that solved the problem.

Does anyone know why -XX:+UseCodeCacheFlushing doesn't help, or some recommended values for all of the code cache java options?

For fun, here are my resulting compile times using -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
1
  • 1
    Setting -XX:ReservedCodeCacheSize to 128m works just as well as 2g
    – Mike
    Mar 17, 2013 at 3:32
0

You might start by attaching a profiler or monitor to see what's going on with GC. To get some initial idea of what's up a stock tool like JVisualVM should suffice. Of course, if you have YourKit, that would work well, too.

Addenddum

As a mildly interesting but now largely irrelevant aside, I recently discovered that Scala 2.9.0-1 was atrociously slow when compiling Specs2 tests (immutable, at least). Switching to 2.9.1 made a huge difference. I only noticed it when I had to add some unit tests to a project that had not previously had any and the compile times became agonizing. On a hunch I switched to 2.9.1 and everything went back to normal.

1
  • I looked with jvisualvm. Nothing fishy seems to be going on with GC (heaps have plenty of free space, not spending much time on GC). CPU sampling doesn't indicate much to me either (23% of time in Object.hashCode, the rest are <5%). The memory profiler never seems to get finished redefining classes. Any idea where to look from here?
    – Mike
    Mar 14, 2013 at 21:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.