Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cah6 opened this issue Apr 20, 2019 · 3 comments
Open

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

cah6 opened this issue Apr 20, 2019 · 3 comments

Comments

@cah6
Copy link

cah6 commented Apr 20, 2019

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.

@matthewbauer
Copy link
Member

matthewbauer commented Apr 21, 2019

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.

@cah6
Copy link
Author

cah6 commented Apr 21, 2019

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!

@matthewbauer
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants