Haskell: Debugging Long Compilation Times on Stack Projects

为君一笑 提交于 2019-12-07 08:00:32

问题


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.


回答1:


In case this question is still relevant, you could try this:

stack ghci --fast --no-build --ghc-options="-fbyte-code"

IIRC using this got me the quickest results with stack ghci.

If this doesn't help enough, you could look in the direction of --ghc-options="-dshow-passes". I myself am also looking in this direction currently to try to speed up a build/ghci-reload.



来源:https://stackoverflow.com/questions/35375143/haskell-debugging-long-compilation-times-on-stack-projects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!