I do a lot of projects both for Windows applications and backend web development that runs on Linux. While my Windows projects do not run under Linux, I enjoy using the command line via WSL while working on them.

I set up another distro using WSL2 for my backend projects, and then pondered, should I continue to use my WSL1 configured distro? Let’s find out!

Measuring performance

Here is what I used to measure disk performance. Feel free to try it out on your system. Depending on your machine and which scenario you are attempting it can range from a few seconds to a few minutes.

mkdir test
cd test
dd if=/dev/zero of=testfile bs=1000 count=500
time split -b 10 -a 10 testfile
time rm -rf *

The above command generates 50k files by generating a 500KB file, splitting it into files of 10 bytes, and lastly removing all the files.

Results

Operation WSL2 on VHD WSL2 on NTFS WSL1 on NTFS* Docker (WSL2)
split 50k files 4.22s 3m58.8s 39.95s 5.89s
rm 50k files 1.85s 1m58.2s 18.71s 2.42s

* WSL1 with optimizations, see WSL Disk performance

Benchmarks performed on a 1st generation Surface Pro with 64GB SSD. Your results will see a pronounced improvement with better hardware.

A couple of things pop out from the results. First is the stark difference between WSL2 using the VM drive versus using NTFS mounted drive. You can see WSL2 on NTFS gives the worst performance at nearly 4 minutes, fifty times slower than the same test on the VM drive.

Second, WSL1 is faster on NTFS. Even factoring out the optimizations from WSL Disk performance there is still a 2-3x performance gain by sticking with WSL1 for operations on the NTFS drive. That explains why Microsoft suggests using WSL1 if you need to work with files in the Windows File System.