rel8 icon indicating copy to clipboard operation
rel8 copied to clipboard

compile times are extremely high

Open MangoIV opened this issue 2 years ago • 3 comments

With ghc9.4.6 the compile times for small modules are really high (multiple minutes), is this expected or might this be a regression in the compiler?

MangoIV avatar Aug 30 '23 21:08 MangoIV

Unfortunately this is somewhat known, but we don't really know what the root cause of the issue is. At CircuitHub, we tend to set -O0 on modules that take a significant amount of time to compile. Can you try that and see if it helps at all? It's unlikely Rel8 modules really much from an optimization, afaik.

ocharles avatar Sep 05 '23 12:09 ocharles

So I've encountered similar issues with compile times. It didn't really hit me until my application had to build via a CI pipeline, where it would slow to a halt and max out my memory budget. I was able to narrow the issue down to records that were deriving Generic and Rel8able and noticed it got slower with larger records. Removing all optimizations with -O0 also did the trick for me, however I wanted to figure out which optimizations in particular might be causing the problem. After a bit of trial and error I found that it had something to do with the interface files being generated by GHC. By adding just these two pragmas, -fomit-interface-pragmas and -fignore-interface-pragmas, while keeping all of the other optimizations, I was able to get my compile times down dramatically and resolve the memory leak.

remeike avatar Feb 04 '24 21:02 remeike

We ran into the same issue, to the point of making the project effectively uncompilable on some users laptops, and the pragmas flags suggested by @remeike did the trick. This really should be added to the main rel8 documentation.

Just toss this on top of the file defining the rel8able instance:

{-# OPTIONS_GHC -fomit-interface-pragmas #-}
{-# OPTIONS_GHC -fignore-interface-pragmas #-}

gbaz avatar Sep 20 '24 07:09 gbaz