commercialhaskell / stack

The Haskell Tool Stack
http://haskellstack.org
BSD 3-Clause "New" or "Revised" License
3.99k stars 841 forks source link

Adjusting default GHC RTS options for faster builds #3435

Open bitemyapp opened 7 years ago

bitemyapp commented 7 years ago

Was poking through this, occurred to me that Stack could have some nicer defaults: https://rybczak.net/2016/03/26/how-to-reduce-compilation-times-of-haskell-projects/

Main thing that stands out to me is +RTS -Asize, I assume Stack isn't doing anything by default here? I know we have --fast but independent of that, it seems like Stack should almost always boost -A because GHC's defaults are too low for the majority of users.

What do y'all think?

mgsloan commented 7 years ago

Hmm, makes sense to me! Users can always specify their own --ghc-options "+RTS -Asize to override it.

Another thing that stands out to me is that AFAIK we are not passing -j to ghc, and I don't think cabal does that. One thing to keep in mind is that this will increase memory usage, possibly leading to some OOM cases. Stack now has a behavior where if a probable OOM is detected, it will retry compilation but without building packages in parallel. When running in this mode, it also makes sense to not increase the allocation area / pass -j.

Also makes sense to pass similar options when using stack ghci.

May make sense to also open an upstream issue with ghc about tweaking the default rts options.

bitemyapp commented 7 years ago

That all makes sense. I think the main unforced error is the allocation arena size being too small by default. GHC uses gobs of memory regardless, you can't compile anything on a 512mb VPS without creating a fat swap partition and activating it with vm.swappiness=100 anyway, might as well make it a spend less time in GC.

Wizek commented 5 years ago

It currently seems impossible to pass in --ghc-options "+RTS -Asize" due to #3353 and #3315, or is it possible somehow?

dbaynard commented 5 years ago

You may be able to set this in the cabal/hpack file, or override it in a stack.yaml file. Otherwise #3315 is tagged 'help wanted'.