digitallyinduced / ihp

šŸ”„ The fastest way to build type safe web apps. IHP is a new batteries-included web framework optimized for longterm productivity and programmer happiness
https://ihp.digitallyinduced.com/
MIT License
4.94k stars 196 forks source link

DevServer GHCi flags causing slow compilation #1075

Open zacwood9 opened 3 years ago

zacwood9 commented 3 years ago

So I've been having issues with the Dev Server recently where the build would get stuck on build/Generated/Types.hs, whereas if I load the app using make ghci everything would compile nice and fast.

Here are the GHCi args, found in startGHCI in exe/IHP/IDE/DevServer.hs

    let args =
            [ "-threaded"
            , "-fomit-interface-pragmas"
            , "-j"
            , "-O0"
            , "-package-env -" -- Do not load `~/.ghc/arch-os-version/environments/name file`, global packages interfere with our packages
            , "-ignore-dot-ghci" -- Ignore the global ~/.ghc/ghci.conf That file sometimes causes trouble (specifically `:set +c +s`)
            , "-ghci-script", ".ghci" -- Because the previous line ignored default ghci config file locations, we have to manual load our .ghci
            , "+RTS", "-A128m", "-n2m", "-H2m", "--nonmoving-gc", "-N"
            ]

I have no idea what the performance implications of the RTS flags are, but I tried removing them, recompiled IHP, and the builds started to pass again.

Is there a reason to have these specific RTS flags in the dev server? We shouldn't really need to tune for performance in dev and if I remember correctly the nonmoving GC still had some bugs.

Possibly related to #1051?

mpscholten commented 3 years ago

The flag have been changed very recently. Was the performance better in previous versions?

zacwood9 commented 3 years ago

It was better but I would still have issues occasionally. The latest version almost never finishes compiling though so I think the flags caused a regression. I believe the latest flags give GHC only a 2MB heap? I could imagine that would slow things down a lot since it is so memory constrained, especially when compiling a file like Generated.Types