Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug long compile times in Scala and SBT

Tags:

scala

sbt

In my Scala/SBT project, I have one file that takes up to 5(!) minutes to compile. All the other ones can compile in a few seconds. This makes development pretty painful.

I'm sure that I'm abusing some Scala constructs, but I have no idea how to go about debugging it. How does one debug long compile times in Scala?

I'm using Scala 2.9.2 and SBT 0.11.2

like image 724
Eyal Avatar asked Oct 16 '12 17:10

Eyal


1 Answers

You can try the following Scala compiler options:

  • -Ystatistics Print compiler statistics

Find a phase that takes the most time. Then, try those:

  • -Xprint:<phase> Print out program after or "all"
  • -Yshow-trees Show detailed trees when used in connection with -print:phase
  • -Ydebug Output debugging messages
  • -Ypmat-debug Trace all pattern matcher activity.

To enable these settings directly from the sbt console, you can use set scalacOptions in ThisBuild += "-Ystatistics", or for more than one, set scalacOptions in ThisBuild ++= Seq("-Yshow-trees", "-Ydebug")

like image 162
nau Avatar answered Sep 18 '22 09:09

nau