NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.16k stars 1.47k forks source link

nix-collect-garbage is slow on OS X because of lsof #3011

Open basvandijk opened 5 years ago

basvandijk commented 5 years ago

nix-collect-garbage uses lsof on OS X to find all opened files by all processes in order to not collect opened files: https://github.com/NixOS/nix/blob/41a52466854ab3a7d4adedc3777c0b0585ef79fe/src/libstore/gc.cc#L450

Unfortunately lsof is really slow on OS X. On my Macbook Pro lsof takes more than 6 seconds:

time lsof -n -w -F n > /dev/null
lsof -n -w -F n > /dev/null  0.24s user 6.01s system 99% cpu 6.252 total

This actually caused the gc-concurrent.sh test to fail because nix-collect-garbage takes longer to run than the nix build started earlier.

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

stale[bot] commented 2 years ago

I closed this issue due to inactivity. → More info

thiagokokada commented 1 month ago

Lix has an interesting fix for this issue, using libproc to workaround this issue: https://gerrit.lix.systems/c/lix/+/723.

Curious if this patch could be backported to Nix.