-
Notifications
You must be signed in to change notification settings - Fork 363
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
Devenv builds and initializations are slow #1102
Comments
Do you have SSD? |
@domenkozar Yes, I also can provide some other hardware stats if it helps |
Can you pass |
Here it is:
I noticed that it downloaded some tar.gz from NixOS github for a very long time (~5-10 minutes or so), while the size of a file was around 40Mb, which with my network bandwidth should have been downloaded in less than 1 second. But other stages are slow too. |
What happens if you run |
@domenkozar I executed the command as-is, and it printed:
|
You need to run it in the same directory. |
Same with what exactly? I ran the command in the root directory of my project with devenv:
|
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: {
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
devenv.url = "github:cachix/devenv";
nixpkgs-python.url = "github:cachix/nixpkgs-python";
};
nixConfig = {
extra-trusted-public-keys = [
"devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw="
];
extra-substituters = [
"https://devenv.cachix.org"
];
};
outputs = { self, nixpkgs, devenv, ... }@inputs:
let
system = "aarch64-darwin";
pkgs = nixpkgs.legacyPackages.${system};
in
{
packages.${system}.devenv-up = self.devShells.${system}.default.config.procfileScript;
devShells.${system}.default = devenv.lib.mkShell {
inherit inputs pkgs;
modules = [
({ pkgs, config, ... }: {
name = "cooler";
# bash shell script executed when devenv shell entered
enterShell = ''
echo "devenv shell for $PROJECT"
'';
# https://devenv.sh/basics/
env = {
PROJECT = "cooler";
};
# https://devenv.sh/languages/
languages.python = {
enable = true;
};
# https://devenv.sh/scripts/
scripts = {
hello.exec = "echo \"hello from $PROJECT\"";
};
})];
};
};
} if I set When I run
enabling other languages, eg, |
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: • Building shell ...
• Using Cachix: devenv
• Running command: /nix/store/z1zrijdcxzx5a8yf4prggamg6k41hcmi-nix-2.21-devenv/bin/nix --show-trace --extra-experimental-features nix-command --extra-experimental-features flakes --option warn-dirty false --keep-going --max-jobs 4 --option eval-cache false print-dev-env --profile /Users/xxx/Code/function/.devenv/gc/shell --option extra-substituters https://devenv.cachix.org --option extra-trusted-public-keys devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw= nixpkgs-python.cachix.org-1:hxjI7pFxTyuTHn2NkvWCrAUcNZLNS3ZAvfYNuYifcEU=
• Creating symlink /nix/store/0cxqya4z0y19b5kvnxrx15dqhm4kr7gm-devenv-shell-env -> /Users/xxx/.local/share/devenv/gc/1725122347.93600000-shell
✔ Building shell in 14.7s.
• Entering shell
• Running command: /nix/store/z1zrijdcxzx5a8yf4prggamg6k41hcmi-nix-2.21-devenv/bin/nix --show-trace --extra-experimental-features nix-command --extra-experimental-features flakes --option warn-dirty false --keep-going --max-jobs 4 --option eval-cache false develop /Users/xxx/Code/function/.devenv/gc/shell Runs were:
... to build shell with no changes in-between. Then if I run
... 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. |
@SirensOfTitan see this workaround to at least avoid the This makes the |
@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? |
I see the same behaviour-- |
It is! In particular it's Sonoma 14.5. |
I recently switched to M2-based Macbook and updated to latest macos 14.5, the overall shell activation is much faster but I think it's more related to M2 chip performance. By "faster" I mean ~2x faster. There are still frequent rebuilds though. Also, if you add new scripts but don't change packages or anything else, is it supposed to trigger rebuilds? |
Does this still happen after https://devenv.sh/blog/2024/10/03/devenv-13-instant-developer-environments-with-nix-caching/ |
Yes. Devenv initialisation is much faster now (from ~30s to ~1s), but it still sometimes downloads and unpacks some 42Mb-ish nix package for 10 minutes. |
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. |
any updates? devenv super slow when there are no changes to the nix files at all. |
What version of devenv are you using? |
Describe the bug
I am facing an issue with
devenv shell
overall performance.Running
devenv shell
right afterdevenv 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.
Related Discord thread
To reproduce
devenv init
devenv shell
and wait for initializationdevenv shell
againVersion
MacOS Sonoma 14.3, Intel-based, zsh.
Logs
devenv.log
The text was updated successfully, but these errors were encountered: