NixOS / nix

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

Tar download very slow #10683

Open shyim opened 6 months ago

shyim commented 6 months ago

Describe the bug

When running nix flake update, it downloads the tar.gz file, which takes a lot of time. This usually takes me a minute, but for my colleagues, it takes some time up to half an hour.

image

The same download using curl takes just a second:

❯ time curl -L -o foo.tar.gz 'https://github.com/NixOS/nixpkgs/archive/e4e7a43a9db7e22613accfeb1005cca1b2b1ee0d.tar.gz'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 40.4M  100 40.4M    0     0  24.2M      0  0:00:01  0:00:01 --:--:-- 28.5M

________________________________________________________
Executed in    1.68 secs      fish           external
   usr time  225.63 millis   92.00 micros  225.54 millis
   sys time  129.86 millis  978.00 micros  128.89 millis

I suspect that Nix does a range download and GitHub does not like that and have to export the tar always again from GIt 🤔

Steps To Reproduce

  1. Run a nix flake update so nixpkgs fetches the new tarball

Expected behavior

A clear and concise description of what you expected to happen.

nix-env --version output

❯ nix-env --version
nix-env (Nix) 2.22.0

Additional context

Add any other context about the problem here.

Priorities

Add :+1: to issues you find important.

JayanSmart commented 6 months ago

I can reproduce this on a 1Gbps connection, I am taking over 10 min's to download the tarball when I run the following command on a fresh nix install: echo "Hello world" | nix run "nixpkgs#cowsay"

edolstra commented 6 months ago

Can you check if the slow performance also happens with Nix 2.20 (nix shell nix/2.20.6)? It might be related to the Git-based tarball cache that we started using in 2.21.

Rucadi commented 6 months ago

I was having the same problem with centos7, (inside a container), works well in an ubuntu host, using the latest nix from unstable.

nixos-discourse commented 6 months ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2024-05-15-nix-team-meeting-minutes-146/45491/1

shyim commented 6 months ago

2.20.6 is A LOT faster for me. With 2.21 it's slow again

JayanSmart commented 6 months ago

I can confirm, 2.20.6 is a lot faster for me as well. Same issue persists on verison 2.21.2.

Bird87ZA commented 4 months ago

I have the same problem on a 1Gbps connection.

rbutera commented 3 months ago

also facing this issue on a 1gbps connection in the UK

ccalhoun1999 commented 1 month ago

I am also dealing with horribly slow downloads in Japan.

Aneeqasif commented 1 month ago

is there a fix or workaround guyz?