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 my software in Node JS, TypeScript and React and I assumed I would be fine jumping into the projects I had previously been working on in my previous Windows and Power Shell environment. The thing I noticed was that my React projects seemed to be running slowly. I mean really slowly. Unusable slowly. I thought that there was something wrong with my Node and WSL set up and I started looking for Node issues on WSL2.
It turns out that WSL2 can be really fast but... only if you use the Linux file system. When opening files stored on Windows (where all mine are/were) it painfully slow.
How slow? I put on some music and timed it. Running npm start
on my Lenovo Yoga laptop with an i7 processor and 16gb of RAM on a Create React App project freshly set up, It took 4:50, 4 minutes and 50 seconds to render the page when running from the Windows file system. Much too slow for me to think about moving away from PowerShell.
So how fast can it be? Same laptop, same test, but running from the a directory on the Linux file system; 4.9 seconds from hitting enter on npm start
to the standard new project page rendering.
TL;DR;
If you want a fast experience using WSL2 move your projects to the Linux file system.
This means that using WSL2 is much more of an all or nothing break than I would have liked, but I'm still thinking I'll commit to the change, at least for new projects.
Top comments (16)
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.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.
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.
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 issueThis 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...
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.
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.
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.
How do you access files in the Linux FS using the Windows explorer? Or more specifically, what is the path to the Linux FS?
For me the path looks like
\\wsl$\Ubuntu-20.04\root
when I look at it in the Windows Explorer address bar.Thanks :)
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!
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.
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.
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.
Another advantage is hot-reloading actually working for react and vue; I had always had to use workarounds in win10 with WSL2