Do you use continuous compilation? sbt ~compile? It's a major help!
Peace. Michael
Yup, that is slow. sbt clean compile takes 69 seconds on my 2011 macbook pro from 2011. The project is 10kloc.
I have 8GB of ram and an SSD. We found that reduced compile time by about 20% around here, but nothing that can explain your numbers.
yours
Geir
I think it really depends on code's degree of abstraction :-) At my case your
project (2432 LOC) takes about 70 seconds to compile, while on the same
machine it takes about 50 seconds to build a project about 16K LOC (also
without comments and blanks).
Andrew
Experimental is experimental... :-)
> Does this sound unusual? Can anyone suggest ways to reduce compile
> time, or at least to work out what it is about our code that causes
> compile time to be so large?
It is my impression -- though I could be wrong! -- that some things
about typer are worse than O(n). In fact, some prints I saw looked
downright quadratic. So, if you have lot of types in scope at the same
time, things could get really nasty -- assuming, again, that this is
true.
>
> (The code is available at https://tqft.net/hg/metaphor/ if anyone is
> feeling extraordinarily helpful; "./sbt test" in the main directory
> should compile everything and run the test suite.)
How does one download from that? I saw no obvious link to do so. Or
can I pass the URL to hg?
--
Daniel C. Sobral
I travel to the future all the time.
LOCs in Scala are not created equal. Take this file (27 sloc)
https://gist.github.com/1594475 and compile it:
$ time
/cygdrive/c/StandaloneApps/scala-2.10.0.r26037-b20111121023229/bin/scalac 1.scala
real 0m4.806s
user 0m0.274s
sys 0m0.305s
Now change the line that makes the compiler prove that the type for 2^4
is a subtype of 1*10+6
println((null:( _2 # ^ [_4] )):( _1 # * [_10] # + [_6] ))
to prove 2^5 <:< 3*10+2 instead
println((null:( _2 # ^ [_5] )):( _3 # * [_10] # + [_2] ))
and get some coffee...
$ time
/cygdrive/c/StandaloneApps/scala-2.10.0.r26037-b20111121023229/bin/scalac 1.scala
real 86m11.747s
user 0m0.151s
sys 0m0.442s
From 5 seconds to 86 minutes for 27 sloc!
In general, it can help to add type annotations in order to cut down on
compilation times by making it easier for the type inferencer to find
the right types. In this specific example, there's probably not much you
can do.
-sz
Daniel -- if you are still interested, yes, you can pass that URL to
mercurial, "hg clone https://tqft.net/hg/metaphor".
best regards,
Scott
yes, the problem was (quoting Paul) "finding the lub of a bunch of
sets whose types are themselves being inferred", and you can see the
change the shaved 60 seconds off compile time here:
(Of course, it's a silly line anyway; probably I should build a Tuple3
rather a List, at least.)
When I asked Paul how he tracked it down, he said that he passed the
scalac option -Ytyper-debug, and looked where it was when it paused
for 60 seconds.
best regards,
Scott Morrison