WSL icon indicating copy to clipboard operation
WSL copied to clipboard

apt-get update/upgrade/install downloads packages at unacceptably slow speeds.

Open RalphORama opened this issue 9 years ago • 91 comments

  • Your Windows build number: Microsoft Windows [Version 10.0.15063]

  • What you're doing and what's happening: sudo apt-get update && sudo apt-get upgrade -y downloads packages at less that 100 kB/s. image

  • What's wrong / what should be happening instead: apt should fetch packages much faster. My internet speed is 100 down / 10 up, on a bare-metal Linux installation or VirtualBox instance, apt is blazing fast. Packages are downloaded at upwards of 1024 kB/s.

  • Strace of the failing command, if applicable: n/a

RalphORama avatar Sep 08 '17 03:09 RalphORama

If there is nothing meaningful in the environment and you don't mind completely destroying it, try the following in an elevated command prompt:

lxrun /uninstall /full /y lxrun /install

See if the problem persists if you completely redeploy the environment.

gravcat avatar Sep 08 '17 20:09 gravcat

@RalphORama - Thanks for your post. We are aware that WSL networking perf is not at par with native Linux, but should not be unbearable. There are plans to improve the WSL n/w perf. I am not sure if uninstall/reinstalling will change much here for you.

sunilmut avatar Sep 08 '17 20:09 sunilmut

network speeds wget

my network speeds are fine and maxing out my link speed on Microsoft Windows [Version 10.0.15063]

gravcat avatar Sep 08 '17 20:09 gravcat

We are aware that WSL networking perf is not at par with native Linux

Yeah WSL might not be on par with Real Linux, but we're talking Phoronix-style quibbling not mass degradation. I get awful apt-get speeds like the OP sometimes too (measured kbs/sec on a mbps link), but best evidence seems to be it is on Canonical's end (or something in between). I get the same thing in my Ubunutu VM from time to time. I am not sure why this is, but I think (speculating) that sometimes you just get a redirect to an unlucky server.

@RalphORama Best thing to do would be take Ubuntu out as a variable. Use speedtest from WSL CLI like @gravcat suggests and then visit their website on Windows, and see if there is a serious gap in performance.

$ sudo apt install speedtest-cli
$ speedtest-cli
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from Skyway West (69.50.175.134)...
Selecting best server based on latency...
Hosted by Shaw Communications (Vancouver, BC) [28.08 km]: 28.778 ms
Testing download speed........................................
Download: 34.39 Mbit/s
Testing upload speed..................................................
Upload: 5.22 Mbit/s

If you see an orders-of-magnitude difference between Windows and WSL, report back because that would be good to know; it is always possible there is something unique going on with your setup.

therealkenc avatar Sep 08 '17 22:09 therealkenc

I found that Windows Defender absolutely murders performance in WSL, especially tools like apt-get. Try temporally disabling it and see if that improves it or not.

Aerocatia avatar Sep 09 '17 04:09 Aerocatia

I found that Windows Defender absolutely murders performance in WSL, especially tools like apt-get. Try temporally disabling it and see if that improves it or not.

this. Windows Defender really messes with I/O actions in WSL, not just with apt-get... adding scan exemptions does not seem to help much.

heldchen avatar Sep 09 '17 13:09 heldchen

this. Windows Defender really messes with I/O actions in WSL

It does. But keep in mind, in the OP this was the 'Get' phase, which is literally just a curl of a .deb. 46.6 kilobytes per second on a 100Mbit/s downlink. Install phase I understand, sure. Windows Defender gets upset when thousands of little untrusted files start appearing from nowhere (from Defender's perspective) though its filesystem filter driver. But if it were Defender you should see the same slowdown on a bog standard curl from a fast server, and you don't; at least not to this degree. Couple that with the fact that turning Defender off doesn't help. So, something else. I could be wrong, because Defender is a ginormous black box that does who knows what, on or off. But I'm not seeing the causality here.

therealkenc avatar Sep 09 '17 22:09 therealkenc

I reinstalled WSL as @gravcat suggested, and installed speedtest-cli. After running speedtest-cli and visiting the speedtest website, it appears WSL only uses 5% of my available bandwidth, maximum (1.6 Mbit/s vs 36 Mbit/s). I believe I have Windows Defender disabled, and I don't think I have any other programs that interfere with I/O on my machine. I use Malwarebytes as my antivirus, which doesn't run in the background. I'll try creating a firewall rule for bash.exe and report back.

Update: Creating a firewall rule and switching to OpenDNS had no effect on apt's download speeds.

image image

RalphORama avatar Sep 09 '17 23:09 RalphORama

image

image

ghost avatar Sep 17 '17 03:09 ghost

@therealkenc - Thanks for the repro steps. I tracked this down to a directory rename failing due something that has a handle open to one of the directory's children. Unfortunately this is an NTFS limitation that I can't think of a workaround without NTFS supporting posix-style rename. I know they were looking at that at some point, but I'm not sure of the status.

benhillis avatar Oct 05 '17 00:10 benhillis

I am also experiencing this issue, did the solution suggested by @gravcat work for anyone? I would hate to have to download the entire distro again at these below 100 kB/s speeds, so am reticent about attempting it.

DarkIlluminatus avatar Jan 27 '18 06:01 DarkIlluminatus

Just turn off Windows Defender Real-time protection.

Add WSL folder and apt process in exclusion list will not work.

You should to completely disable real-time protection, reboot and will see how fast it will be

leandrocrs avatar Jan 27 '18 16:01 leandrocrs

I no longer have this issue, it appears that I just lost the repo mirror lotto when I did the dist-upgrade

On Sat, Jan 27, 2018 at 9:25 AM, leandrw [email protected] wrote:

Just turn off Windows Defender Real-time protection.

Add WSL folder and apt process in exclusion list will not work.

You should to completely disable real-time protection, reboot and will see how fast it will be

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Microsoft/WSL/issues/2477#issuecomment-360995831, or mute the thread https://github.com/notifications/unsubscribe-auth/ARdVlnwMEBb5_joxJ8evpNNunyCRSYR8ks5tO03pgaJpZM4PQqnc .

DarkIlluminatus avatar Jan 28 '18 04:01 DarkIlluminatus

same here. speedtest: both good speed (download: 70-90Mbps) apt: always 30-300kb/s (ftp.jaist.ac.jp)

Using ESET Internet Security 11. no help disable anti-virus. 16299.214

Garry050 avatar Feb 22 '18 13:02 Garry050

@DarthSpock - unfortunately I think the posix-style rename work the ntfs team did doesn't handle the case where a directory has children with open handles. Adding @SvenGroot to confirm.

benhillis avatar Feb 22 '18 15:02 benhillis

@benhillis Your "this is an NTFS limitation that I can't think of a workaround" comment was posted to the wrong thread at the time (you thank me for repro steps that don't exist here). That is #640 aka #1529, which is unrelated to "apt-get update/upgrade/install downloads packages at unacceptably slow speeds".

Adding SvenGroot to confirm.

Like this

therealkenc avatar Feb 22 '18 18:02 therealkenc

I can confirm, this is slow as hell. For me the speed is 219 B/s, while my internet speed on windows is 24mbps

sewashinobi avatar Feb 28 '18 10:02 sewashinobi

I can confirm as well, the speed has dropped down significantly especially when downloading many things

mskd12 avatar Mar 03 '18 02:03 mskd12

Has anyone found a fix? getting speeds of 40 kB/s

Wingmore avatar Mar 07 '18 06:03 Wingmore

I'm having the same problem! >_<

rondi74 avatar Mar 07 '18 19:03 rondi74