Scala 2.10 compiler takes more than 10 times after the first time in SBT

I am updating the 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 finish in about 250 seconds.

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

If I use a heap size of 768 m, 2.10 runs out of memory on the 3rd compiler. With a 4g heap size, it can compile every 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 to debug to know what is going on?

+8
source share
2 answers

Thank you for the CodeCache link. I initially rejected it because using the proposed -XX:+UseCodeCacheFlushing did not improve, but I just tried using -XX:ReservedCodeCacheSize=2g and solved the problem.

Does anyone know why -XX:+UseCodeCacheFlushing does not help, or some recommended values ​​for all parameters of the java code of the code cache?

For fun, here are my resulting compilation 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 
+7
source share

You can start by attaching a profiler or monitor to see what happens to the GC. To get some initial idea of ​​what should be enough for a stock tool such as JVisualVM. Of course, if you have YourKit, this will work too.

Addenddum

As mildly interesting, but now largely irrelevant, I recently discovered that Scala 2.9.0-1 was terribly slow when compiling Specs2 tests (at least immutable). Switching to 2.9.1 was of great importance. I noticed this only when I had to add some unit tests to a project that was not previously, and the compilation time became painful. On suspicion, I switched to 2.9.1, and everything returned to normal.

0
source share

All Articles