DEV Community

Cover image for Why is WSL2 so slow?

Why is WSL2 so slow?

Klee Thomas on July 09, 2020

I've been playing around at using WSL2. This is my first time using Window Subsystem for Linux having skipped over WSL1. I typically like to write...
Collapse
 
kidkkr profile image
kidkkr • Edited

You can use WSL2 file system itself. (its on \\wls$\.... )
/mnt/c/.. is really slow as you said.
if you use Debian, \\wls$\debian will be / in your WSL2 distribution.

Collapse
 
amorpheuz profile image
Yash Dave

WSL1 is the choice to go for if you want to have good performance across OS file systems! Check out the Comparing WSL 2 and WSL 1 on Microsoft Docs for which WSL version suits your use-case the best, since for now, Microsoft has indicated that both projects will be kept alive separately.

Collapse
 
kleeut profile image
Klee Thomas

Thanks, I think for now I'll stick with wsl2 and run from the Linux system. I was just shocked when I was caught out by the initial slow performance.

Collapse
 
aminya profile image
Amin Yahyaabadi • Edited

That was interesting. I was having the same issue on WSL2, and I was surprised because WSL2 was advertised as faster. Moving the files over to \\wsl$\Ubuntu\home\<user name>\ fixes the issue

Collapse
 
doctoru profile image
Steve H

This is the best suggestion I've found to the problem of slow compile so far.
I am now re-partitioning a spare disk to store my projects on a native Linux partition - I'll let you know!
I'm Playing with Jekyll, which needs native compilation of several gems in 2021...

Collapse
 
arafatx profile image
ArafatX

I don't think this is related to file system at all, this is a bug that WSL 2 has. With the same windows folder mounted on virtualbox with Ubuntu, I can say the speed is very fast like using the pure linux. This is actually a bug from Microsoft Kernel. WSL 2 does not use pure linux Kernel.

Collapse
 
anodynos profile image
Angelos Pikoulas • Edited

I reverted back to WSL1, cause WSL2 is simply unusable! Around 10-20 times slower build times for my nodejs project. Like most people, I want to have access to my files residing on different NTFS disks, so I can edit them with editors & other tools. How else are you supposed to work if you stick your files in the native ext4 virtual disk?

Everything just works, just a small workaround for docker desktop & docker-compose.

Collapse
 
kleeut profile image
Klee Thomas

From what I read it sounds like you're on the right track. If you want to or need to keep you files on the NTFS disk then WSL1 is a better choice.

Collapse
 
austingil profile image
Austin Gil

How do you access files in the Linux FS using the Windows explorer? Or more specifically, what is the path to the Linux FS?

Collapse
 
kleeut profile image
Klee Thomas

For me the path looks like \\wsl$\Ubuntu-20.04\root when I look at it in the Windows Explorer address bar.

Collapse
 
austingil profile image
Austin Gil

Thanks :)

Collapse
 
kristenkinnearohlmann profile image
Kristen Kinnear-Ohlmann

Thanks for this advice. I will need to create a React project for my bootcamp and this could make a difference for me. I'll look into how to do this right away!

Collapse
 
alg2 profile image
AL G

Yes, I just realized the same thing, that WSL2 is a dog. And I just finished moving over from WSL1 to WSL2 on my main development box and my laptop.

Collapse
 
kleeut profile image
Klee Thomas

A year on I haven't looked back. WSL2 is my main terminal and I'm using it productively, I haven't found a need to go to the Windows file system so it's super fast.

Collapse
 
alancphilpott profile image
Alan Philpott

Having my files on the Linux FS makes absolutely no difference to the compile time. Also under Windows and adding the folder the Windows Deference exclusions makes no difference. It's sad.

Collapse
 
elephantcastle profile image
elephantcastle

Another advantage is hot-reloading actually working for react and vue; I had always had to use workarounds in win10 with WSL2