I'm currently using Stack to build a project, which totals about 80 modules and 13,000 lines of code. Currently, compilation takes about 3 minutes for a minor change in my types files, which is unacceptable -- it prevents me from rapidly testing my code via stack ghci. It also significantly slows down a number of things: for instance, pair programming with peers or consulting with experts.
I would like to be able to figure out why compilation is taking so long, and what I can do to speed it up. Is there some way to profile compilation times?
Additionally, how can I tell whether it is stack or ghc that is slow?
I know about setting -O0, though this does not seem to help compilation times. I also know that TemplateHaskell and Typeclass Resolution can take a while -- is there any way I can get better resolution on how long these are taking?
Note: i have seen Speed up compilation in GHC, but that was from 2013, and hdevtools currently does not work on my setup.
-O0
is not the same as interpreting, and if you are interpreting, then the-O
switch does nothing anyways. What is your compilation time from scratch, i.e. how does it compare to the 3 minutes? If you make a change at the module at the top of the hierarchy, then it will recompile every single module - in general it couldn't tell whether it has to or not. – user2407038 Feb 13 '16 at 3:25stack install
as compared tostack ghci
. If you could discover this it may be helpful. Have you tried it just withcabal
- i.e.cabal build
vs.cabal repl
? If these two differ significantly, then you know stack is doing something funnny. If they do not, then something weird is up with your proj (perhaps compile time is mainly dominated by TH or large type reductions? Can you give details of the proj?) – user2407038 Feb 13 '16 at 3:59