devenv: Devenv builds and initializations are slow
Describe the bug
I am facing an issue with devenv shell overall performance.
Running devenv shell right after devenv init (no other changes in the code) takes really long time, ~1 minute usually. Moreover, the time is the same on each run.
This behaviour is the same for my real projects.
To reproduce
- Create a new empty folder and change to it
- Run
devenv init - Run
devenv shelland wait for initialization - Exit from shell and run
devenv shellagain
Version
➜ devenv-test-3 devenv version devenv 1.0.2 (x86_64-darwin) ➜ devenv-test-3 direnv --version 2.34.0 ➜ devenv-test-3 cachix --version cachix 1.7 ➜ devenv-test-3 nix --version nix (Nix) 2.21.0
MacOS Sonoma 14.3, Intel-based, zsh.
Logs
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 10
- Comments: 24 (11 by maintainers)
With rewrite to Tvix we’re going to handle the caching layer and fix this, but we need to get quite a few things in order first.
@SirensOfTitan we’re aware this is important and we’re working on changes that will run sub 50ms for all commands if nothing changes in your Nix environment.
Curious though, is this on macOS?
@SirensOfTitan see this workaround to at least avoid the
devenv upinvocation altogether: https://github.com/cachix/devenv/issues/756#issuecomment-1807860259This makes the
process-compose.ymlfile evaluation eager ondevenv shellinvoke, which is negligible. Then you can avoid any further evals viaprocess-compose up.I see the same behaviour–
devenv shelltakes between 30s to 45s on each run. I’m on macOS 13.6, MacBook Pro with SSD.Chiming in here, devenv’s slowness right now is the big issue preventing me from rolling it out to the rest of the team. I really enjoy using it but it probably took me 10x longer to chain up our service-based architecture than it should have, as the feedback loop was so long. It was fairly agonizing if I realized I forgot an env var because it cost about 60s of time on every mistake.
Running devenv 1.0.8 using a devenv.nix file, not using flake-parts or flakes for this particular project so similar to @SamoylovMD the command above fails as I don’t have a flake.nix file. Running on an M3 Pro.
devenv shell --verbose:
Runs were:
… to build shell with no changes in-between. Then if I run
devenv up, it takes on average about 25 seconds with no changes for the process-compose shell to appear:… after those two Building shell in xx s statements, it takes about another 10 seconds for process-compose to appear. I’m similarly using Python.
Happy to run whatever helps debug.
@domenkozar after upgrading to 1.5.2, I’m now seeing sub-200ms timings that indicate the cache is working!
Thanks for all your great work 💪
With 1.5.2, once the environment is cached it should take 100-400ms to set it up.
The 12-30s is the time it needs to evaluate and build, we hope to reduce that long-term with evaluator optimizations.
Watch #1548 for progress
My colleagues and myself are experiencing this as well! I’m using version 1.5.0. Building the shell takes 12-30s, and will randomly be triggered without changes made (that I’m aware of) to the
devenv.nixordevenv.local.nixfiles.any updates? devenv super slow when there are no changes to the nix files at all.
I see >20s init times on an M2 macbook pro running macos 13.6.7 when enabling support for python.
Here is the flake.nix that takes 20s to init:
if I set
languages.python.enable=false;or remove the languages expression, then it inits in <2s.When I run
nix develop --impure -vvv .it seems to spend more than 10s after printing the line:evaluating file '/nix/store/i6yzq14z49ayjinw6v9v06kqz62akkay-source/modules/hook.nix'enabling other languages, eg,
languages.nix.enable = true;does not cause the slow init time.