jonascarpay / template-haskell

batteries-included nix-based haskell project template
BSD 3-Clause "New" or "Revised" License
61 stars 10 forks source link

Large build times due to cache miss #15

Closed malteneuss closed 1 year ago

malteneuss commented 2 years ago

Thanks for setting this example up. I tried running nix develop with your template checked out but for whatever reason it starts building ghc 8.6.5 (even though 8.10.7 is required). Do you why? Could it be related to https://github.com/input-output-hk/haskell.nix/issues/1084?

jonascarpay commented 2 years ago

I'm pretty sure 8.6.5 is the bootstrapping compiler that builds 8.10.7, so if you get a cache miss on 8.10.7, it will first need to build 8.6.5. I'm not sure what's going on though, for me it pulls it from cache as normal:

image

If you want a workaround, you can try using the no-haskell-nix branch. It works the exact same way, just run the wizard. The Haskell stuff in nixpkgs had some updates and for simple projects is almost as easy as haskell.nix, plus a lot faster and less finicky wrt. caches.

malteneuss commented 2 years ago

Thanks for that explanation. Do you happen to know or know a guide how to debug the cache miss?

Regarding that no-haskell-nix branch, it looks straightforward and readable. We should get something like this into the official Nix docs along with a list or other possible Haskell setup variants like in https://discourse.nixos.org/t/super-simple-haskell-development-with-nix/14287/3

jonascarpay commented 2 years ago

I wish there was. In the past I've looked at the derivations themselves, to check if and where SHA's differed, or what wasn't being pulled from the cache that should've been, but it's annoying manual labor. Also, it's significantly more painful with haskell.nix since it uses IFD. The reason I set up my own cachix for this repo is because I've found that is more robust than relying on IOHK's hydra, so you can also consider setting up either mine or your own cachix.

One thing to keep in mind when doing cache miss debugging is first remove your local cache info and always pass --option narinfo-cache-negative-ttl 0 to make sure the cache is retried every time.

https://nix.dev/faq#how-do-i-force-nix-to-re-check-whether-something-exists-at-a-binary-cache

malteneuss commented 1 year ago

In the mean time i moved away from haskell.nix setup and am quite happy with the non-invasive Stack nix setup from the Stack docs.