The most common cause of performance issues in WSL2 is when attempting to access files on the Windows drive (e.g. through /mnt/c/...
). If the project you are working with is on the Windows drive, that would most likely explain the root issue. See my answer to, Why is WSL extremely slow when compared with native Windows NPM/Yarn processing? for details.
As one example from that post, Git actions on the Windows drive when running through WSL2 can take nearly two orders of magnitude longer than when on the Ext4 filesystem. The "normal" hit to performance from running on the Ext4 filesystem under WSL2 varies depending on the type of files being access, but typically runs between 10-50%. For day-to-day development use, you really shouldn't "notice" it. "Painstakingly slow" sounds like the "Windows drive" issue.
However, I'm not totally convinced this is the problem in your case. You mentioned you were able to open your project through VSCode (presumably through WSL), and it should have displayed a warning toast about the performance when you/if you opened a project on a Windows drive. It's possible that you missed it, of course, or possibly habitually clicked-to-dismiss (we all do!).
VSCode can operate in two different "modes" when it comes to WSL:
- "Windows" (normal) mode
- "WSL" (extension/remote) mode
Assuming you have the WSL extension installed, VSCode will detect when you started it under WSL and automatically switch to Remote mode. It will also automatically switch into Remote when re-opening a project that was originally Remote.
The general rule is:
- Open projects in normal/Windows mode when using Windows tools. Store these projects on a Windows drive.
- Open projects in WSL/Remote mode when you are using Linux tools (processes, filesystems, etc.). Store these projects in the virtual SDD Ext4 filesystem that WSL2 provides (e.g., under your Linux
$HOME
directory).
You can tell which mode you are in in VSCode by looking at the bottom left corner of the VSCode window. There is a toolbar option on the far left that looks like ><
, slightly offset. If you are in "Normal" mode, it will simply be the ><
. If you are running under WSL, you'll see the name of the WLS distribution there as well. Hovering will provide more detail.