Closed tobiasBora closed 1 year ago
I'm also confused, sometime
nix run nixpkgs#…
is really long, sometimes takes no time at all.$ nix run nixpkgs#time # takes a lot of time $ nix run nixpkgs#hello # takes no time (maybe nixpkgs#time has done some caching?)
I can think of some effects.
The mutable flake cache. nixpkgs
is a mutable flakeref. It may have been downloaded the first time and cached on the second.
Instantiation. Nix creates a bunch of .drv files. If they already exist, this process may be faster.
Evaluation cache. This is basically per installable, and it doesn't cache any dependencies. If we make nixpkgs take dependencies from its self
, this PR might help with this https://github.com/NixOS/nix/pull/4511
I expect nix to take close to no RAM/time, especially for a no-op operation.
(2) and (3) may be improved, perhaps.
Improving memory usage is by no means easy. By default, a large number of derivations must be evaluated, and cache invalidation is hard ;). Nix expressions do tend to hold on to more values and thunks than you might expect it to, but these are usually required for computations that could be done, but won't be done. It'd be interesting to see how this could be improved by significantly changing the interpreter, but this would be a research project, not an easy fix. That said, we've accepted a number of performance improvements since the 2.4 release (thanks pennae!), and perhaps some fresh eyes (or more of the same eyes) could find more of such incremental improvements.
Thanks a lot for the answer. So also, I did some tests to see if the problem was coming from flake or nix, and when I nixos-rebuild switch
twice a system without flake twice, it also takes like 10mn the two times, even without change. So I guess it takes time to evaluate all the NixOs modules, even if nearly all of them are disabled. Don't know if it would be possible somehow to avoid evaluating useless modules.
if it would be possible somehow to avoid evaluating useless modules.
There's https://github.com/NixOS/rfcs/pull/22 which I think is also good for actual modularity, and there's potential for a workaround, although that would tend to make the already complicated module system more complicated.
https://github.com/NixOS/nix/issues/8621 is a duplicate of this, but I'm closing this one, as most of the conversation here is about the specific observations that do not help with solving the problem. So any further conversation can continue in the fresh issue
Describe the bug
All the following commands takes a lot of RAM (I'd say around 1G from looking at htop,
time
tells me 500M) and time (10mn, and it's even worse when the system starts to swap because the RAM is full…) to evaluate on a raspberry pi 3b, even if I they do a no-op (i.e. if the current system is already running this version):As far as I see this is not visible on my main laptop… no idea why.
I'm also confused, sometime
nix run nixpkgs#…
is really long, sometimes takes no time at all.Steps To Reproduce
I also tried with the non-flake version and I got similar issues:
Expected behavior
I expect nix to take close to no RAM/time, especially for a no-op operation.
nix-env --version
output2.11.0