reflex-platform icon indicating copy to clipboard operation
reflex-platform copied to clipboard

Slow ghc nix-shell entry time, any way to speed up?

Open cah6 opened this issue 6 years ago • 3 comments

I was playing around with https://github.com/ElvishJerricco/reflex-project-skeleton and found that even without adding any more packages, the time to enter a GHC shell is pretty slow. Interestingly, the ghcjs shell is a lot faster. My numbers:

$ time nix-shell -A shells.ghcjs --run ""
trace: WARNING: ignoring dependency on doctest

real	0m9.771s
user	0m5.621s
sys	0m3.507s

$ time nix-shell -A shells.ghc --run ""

real	0m39.980s
user	0m19.607s
sys	0m19.092s

Note that this is with everything cached and seemingly ready to go. Is this normal? Is there any way to speed this up, specifically the GHC one? Or is this just some inherit limit of Nix? If it helps, I could also attach the verbose logs, though nothing seemed out of the ordinary (to me) there.

cah6 avatar Apr 20 '19 19:04 cah6

You can improve startup time a little bit by setting:

withHoogle = false;

in your default.nix. There is definitely more improvements available to us, and I think we'll get better at this as time goes on. Right now, I think most people keep nix-shell's open for a long time to avoid the cost.

There are two phases that happen when you open the shell:

  • evaluation (time nix-instantiate -A shells.ghc)
  • setup (drv=$(nix-instantiate -A shells.ghc); time nix-shell $drv)

each takes about 5 seconds for me. I would be interested in seeing which of those take more time for you. The setup time is something I think we have lots of room for improvement, but unfortunately means digging into the Nixpkgs setup.sh script.

matthewbauer avatar Apr 21 '19 00:04 matthewbauer

Thanks for the quick response!

Ah yes, this was with Hoogle disabled. But boy...I just ran this on the same repository (no changes, but I had been messing with another repository that was pointing to the same reflex-platform), and now the GHC shell is only taking 10s. For what it's worth, evaluation is taking 0m2.442s and setup is taking 0m7.047s.

Anecdotally, when I had previously ran it on verbose there was no output for most of the time at the end, which looks to be the setup phase. I suppose if that's a part of nixpkgs, then that's just how it is for now!

cah6 avatar Apr 21 '19 01:04 cah6

Hopefully this improves on the Nixpkgs side with https://github.com/NixOS/nixpkgs/pull/69131! I hope to eventually cherry pick this to 19.09 and 19.03 (which reflex-platform currently uses) .

matthewbauer avatar Sep 26 '19 16:09 matthewbauer