microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.26k stars 812 forks source link

WSL 2 - Surface Pro X - slow network on localhost #4946

Closed dennisameling closed 7 months ago

dennisameling commented 4 years ago

Microsoft Windows [Version 10.0.19041.113] Device: Microsoft Surface Pro X (ARM64)

When trying to use WSL 2 (Ubuntu) to debug NodeJS applications, like Angular (e.g. with ng serve), network performance is very slow (~1Mbps). This results in a very sluggish experience with long loading times.

Speeds from Ubuntu to external (internet) servers are absolutely fine:

$ speedtest

   Speedtest by Ookla

     Server: WorldStream B.V. - Naaldwijk (id = 6554)
        ISP: T-Mobile Thuis
    Latency:     7.58 ms   (0.60 ms jitter)
   Download:   174.12 Mbps (data used: 249.3 MB)
     Upload:   130.86 Mbps (data used: 71.4 MB)
Packet Loss:     0.0%

In order to quantify my experience, I installed Docker in Ubuntu/WSL 2 and then ran https://hub.docker.com/r/linuxserver/librespeed to run a speedtest on my Windows computer against the Ubuntu/WSL 2 installation. The results:

image

I tried temporarily disabling Windows Defender, but that didn't make any difference unfortunately.

The network speed between Ubuntu/WSL 2 and Windows should be much higher than it is now. Please note that this was tested on the Surface Pro X, an ARM64 device. Not sure if the issue is ARM64-specific though.

N/A

I'm not sure where to start looking in order to troubleshoot this issue. More than willing to help troubleshooting, but if someone could give me some hints on where to start looking that'd be great 😃

Steps to reproduce

  1. Install Docker in WSL2 (Ubuntu instructions: https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository)
  2. Run the following command in WSL2 to start a Speedtest server:
docker run -d --rm \
  --name=librespeed \
  -e PUID=1000 \
  -e PGID=1000 \
  -e TZ=Europe/London \
  -e PASSWORD=PASSWORD \
  -p 80:80 \
  -v /path/to/appdata/config:/config \
  --restart no \
  ghcr.io/linuxserver/librespeed
  1. Go to http://localhost in Windows and start the speedtest. You'll notice the slow speed.
  2. Run ifconfig in WSL2 and copy the IP address of eth0 (e.g. 172.24.216.50)
  3. Go to that IP address in your browser in Windows: http://172.24.216.50. The speedtest should now be very fast.
therealkenc commented 4 years ago

/dupe #4901

ghost commented 4 years ago

Hi! We've identified this issue as a duplicate of another one that already exists in this repository. This specific instance is being closed in favor of tracking the concern over on the referenced thread.

Thanks for your report!

dennisameling commented 4 years ago

@therealkenc I saw #4901, but thought it wasn't the same issue as that issue is related to external networking (e.g. Speedtest.net). In my case, the external network is fast (>100Mbps) but the connection between Ubuntu and Windows is slow (~1Mbps). Do you think we should keep it together in #4901 (I'll add my case there then) or should this remain a separate ticket?

therealkenc commented 4 years ago

Yeah, it was a tough call because you're okay externally. Reasoning was that this one will likely only draw "slow for me too" posts, and it is better to keep those in one place. None of this is on you; there is no doubt you are seeing local networking slowness for an as yet unidentified reason (in the same sense that the peeps in #4901 are seeing slowness for as yet unknown reasons). But let's call it "different enough" de-dupe ya.

therealkenc commented 4 years ago

Slowness has been observed on localhost too ref #5069.

eldiablolives commented 4 years ago

image

Same here, I am running this on Surface Pro X, with WSL2 starting up Angular app and accessing it from GUI via browser 4.3 minutes to push through 9.5MB of data is not ideal. For me this is a showstopper as I can't have dev cycle where I wait for 5 minutes every time I click ctrl+s

dennisameling commented 3 years ago

@eldiablolives Have you been able to find a solution for this in the meantime? Just updated my WSL2 installation but the issue is still there 😞 I'm in the same boat as you, would love to have my dev workloads on the Surface Pro X but this is a showstopper indeed

UPDATE: as described in https://github.com/microsoft/WSL/issues/5069#issuecomment-622251239, it's possible to serve apps on 0.0.0.0, then look up the WSL2 IP address (e.g. 172.21.52.3) and use that to connect to the app. It's blazing fast that way (but have to check the WSL2 client IP every time WSL2 is restarted), so it definitely has something to do with connecting through localhost. Very weird issue.

Speedtest is indeed much faster when connecting directly to the WSL2 IP instead of localhost:

image

Rowanto commented 3 years ago

wsl command to get the IP address: ip addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}'

maxboone commented 3 years ago

+1

dennisameling commented 3 years ago

Unfortunately, the issue is still present in Windows 11 ARM64 beta. Just filed additional feedback using Feedback Hub: https://aka.ms/AAdaz7r

Really hoping that this will be resolved soon, as it's the final blocker for me to move my web development workflows to Windows on ARM 🤞🏼

dennisameling commented 3 years ago

I found another workaround in Windows 11: using the new WSL2 GUI functionality, I was able to install Firefox in Ubuntu (sudo apt install firefox) and do everything in Firefox instead. That basically means that everything is running locally inside WSL2, so the localhost issue with slow speeds doesn't apply here 🎉

It's not perfect since there's no vGPU driver for arm64/Qualcomm yet, but it gets the job done for now 😊

dennisameling commented 2 years ago

Good news: this has been fixed in Windows 11 build 22449. This build is currently in the Dev channel (Windows 11 RTM is build 22000). It was mentioned specifically in the release notes of 22449 as well:

We did some work on WSL2 to help improve the performance and reliability of localhost relay.

https://blogs.windows.com/windows-insider/2021/09/02/announcing-windows-11-insider-preview-build-22449/

Will leave this issue open for visibility 👍🏼

jonshipman commented 2 years ago

Wanted to point out that this is an issue even when adding your WSL2 IP to C:\Windows\drivers\etc\hosts with a custom domain.

microsoft-github-policy-service[bot] commented 7 months ago

This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request.

Thank you!