1

Apologize for being lazy here - if my goal is to simply remote into other servers over SSH, does "upgrading" from WSL1 to WSL2 make a difference in performance?

Two main use cases:

  1. With reverse tunneling, expose a remote port to the local computer for browser access (think of Jupyternotebook and, say, hosting Django sites);
  2. Directly over SSH (in Windows Terminal), use Tmux + some editor to manipulate code.
1
  • If your goal is to simply use an SSH client, do you need WSL for that at all? Couldn't you use the native Windows version of the same SSH client (which is already included with Windows 10)? Aug 5, 2022 at 4:37

1 Answer 1

3

What a great question -- I'd honestly never considered the network speed difference between WSL1 and WSL2 before, nor really had the need personally.

The answer, apparently, is yes, an SSH connection over WSL2 appears to be be much faster than the same in WSL1.

To test, I installed pv in a WSL1 and WSL2 instance and:

yes | pv | ssh $host "cat > /dev/null"

With the host being a hosted virtual server.

  • WSL1 was around 34MiB/s, best case, but dipped to 27MiB/s at points
  • WSL2 ran a steady 110-111MiB/s

I repeated the tests again on a freshly installed (and updated/upgraded) Ubuntu 20.04 instance, doing a wsl --set-version Ubuntu 1 after the WSL2 test.

The results there were pretty much the same, but stayed at around 27MiB/s for WSL1. WSL2 was still right at 111MiB/s.

Just for fun (not a valid comparison), I ran:

yes | pv | pwsh.exe -c "ssh $host 'cat > /dev/null'"

To push the traffic through PowerShell to the Windows SSH client. That, of course, has to cross the process boundary between Windows and WSL on each call, so there's a lot more overhead. The results there were:

  • About 20MiB/s on WSL1
  • About 17MiB/s on WSL2

That's not surprising since WSL1 runs closer to the Windows API than WSL2.

I'm actually a bit surprised at the primary difference between WSL1 and WSl2. I was honestly expecting WSL1 to have the performance advantage, since it shares the network with Windows rather than being NAT'd behind a virtualized interface and switch.

4
  • 2
    Many thanks for contributing to the knowledge about WSL1 vs WSL2! If I read the unit Mib/s, is WSL2 actually reaching the limit of 1Gbps for, say, the Ethernet connection? Then, depending on the upload speed on the remote server and the download speed for the local client, as long as one side is lower than 200Mbps, may I conclude WSL1 == WSL2 under such restriction?
    – llinfeng
    Aug 6, 2022 at 12:33
  • @llinfeng Both of those sound like reasonable assumptions/conclusions to me, however I'm wondering if it's possible that there could be other factors that might change the results (e.g. packet size?). Aug 6, 2022 at 14:48
  • Great, thanks for confirming. This question is originated from running WSL on a company laptop, which has to run behind an active Cisco VPN connection. And, based on the doc other folks have contributed to, it was not straightforward to perform the conversion from WSL1 to WSL2 (due mostly to routing issues). @NotTheDr01ds Thanks to your help, it is now clear that I shouldn't invest time into getting WSL2 to work over a VPN that is capped at 200/300 Mbps for download.
    – llinfeng
    Aug 6, 2022 at 16:14
  • 1
    I HATE IT when people say WSL1 is not as good as WSL2 (or visa versa).. I use both depending on the need. WSL1 is like the PERFECT Cygwin/MingW replacement and SO CLOSE to the OS it is sitting on. WSL2 allows many things WSL1 did not.. but runs in a VM(ish) thingy. Thanks for writing this. Aug 9, 2022 at 21:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .