Why is WSL2 so slow?

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.