Skip to content

Evaluating nixpkgs takes a huge RAM #7308

@tobiasBora

Description

@tobiasBora

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):

$ nixos-rebuild switch --no-flake
$ nixos-rebuild switch --flake .
$ nix flake lock --update-input …

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.

$ nix run nixpkgs#time # takes a lot of time
$ nix run nixpkgs#hello # takes no time (maybe nixpkgs#time has done some caching?)

Steps To Reproduce

  1. Start NixOs on the raspberry pi 3 (you may need to add a swap file or it will freeze when no more RAM is available)
  2. Run twice someting like that (tested on )
# env time -v sudo nixos-rebuild switch --flake github:cwi-foosball/foosball#foosballrasp

I also tried with the non-flake version and I got similar issues:

# /nix/store/jw4jjw6ml5vymjw0yhqg1i9dln12g9k4-time-1.9/bin/time -v sudo nixos-rebuild switch -I nixos-config=configuration.nix -I "nixpkgs=/nix/store/7mffl2hq695yjvgh18vgrpqqn9cr2i1f-source" --no-flake
building Nix...
building the system configuration...
activating the configuration...
setting up /etc...
reloading user units for pi...
setting up tmpfiles
	Command being timed: "sudo nixos-rebuild switch -I nixos-config=configuration.nix -I nixpkgs=/nix/store/7mffl2hq695yjvgh18vgrpqqn9cr2i1f-source --no-flake"
	User time (seconds): 96.84
	System time (seconds): 54.42
	Percent of CPU this job got: 30%
	Elapsed (wall clock) time (h:mm:ss or m:ss): 8:22.45
	Average shared text size (kbytes): 0
	Average unshared data size (kbytes): 0
	Average stack size (kbytes): 0
	Average total size (kbytes): 0
	Maximum resident set size (kbytes): 504280
	Average resident set size (kbytes): 0
	Major (requiring I/O) page faults: 97086
	Minor (reclaiming a frame) page faults: 873927
	Voluntary context switches: 173974
	Involuntary context switches: 278897
	Swaps: 0
	File system inputs: 2584120
	File system outputs: 428560
	Socket messages sent: 0
	Socket messages received: 0
	Signals delivered: 0
	Page size (bytes): 4096
	Exit status: 0

Expected behavior

I expect nix to take close to no RAM/time, especially for a no-op operation.

nix-env --version output

2.11.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions