Comparing performance of native Windows vs. WSL2 for various cargo tasks
Lately I've been tinkering with my Windows 11 desktop and WSL2, and decided to compare the performance of Windows 11 (using the new Dev Drive feature) and WSL2 Ubuntu for various cargo tasks. I cloned https://github.com/casey/just locally and ran benchmarks using hyperfine. I was surprised by the results, and just wanted to share them in case anyone else is in a similar position wondering if using WSL2 is worth it on Windows. Note: I used a --prepare 'cargo clean' in the hyperfine commands so things were cleaned up before runs.
System Specifications
Windows 11 Environment:
- OS: Windows 11 Home x86\_64 (Kernel: WIN32\_NT 10.0.22631.4391)
- Shell: PowerShell 7.4.5
- CPU: AMD Ryzen 3 3200G with Radeon Vega Graphics (4 cores) @ 4.00 GHz
- Memory: 48 GiB
- Disk (F:\\): ReFS Dev Drive
WSL2 Ubuntu Environment:
- OS: Ubuntu 24.04 x86\_64 (Kernel: Linux 5.15.146.1-microsoft-standard-WSL2)
- Shell: Bash
- CPU: AMD Ryzen 3 3200G with Radeon Vega Graphics (4 cores) @ 3.60 GHz
- Memory: Allocated 22.45 GiB
- Disk (/): ext4
Benchmark Results
I tested fd, rg, and various cargo commands.
| Task | Windows 11 (Dev Drive ReFS) | WSL2 Ubuntu |
|------------------------|-----------------------------|--------------------|
| fd test | 52.1 ms ± 3.2 ms | 8.5 ms ± 2.1 ms |
| rg --ignore-case test | 85.7 ms ± 2.8 ms | 5.7 ms ± 0.8 ms |
| cargo clean | 144.9 ms ± 7.4 ms | 54.9 ms ± 1.8 ms |
| cargo fetch | 395.3 ms ± 23.8 ms | 130.2 ms ± 4.6 ms |
| cargo check | 31.145 s ± 0.320 s | 19.053 s ± 0.087 s |
| cargo build | 52.921 s ± 0.812 s | 30.821 s ± 0.774 s |
| cargo build --release | 136.448 s ± 1.406 s | 76.850 s ± 0.410 s |
WSL2 Ubuntu outperformed Windows 11 across all the tasks tested, with WSL2 being nearly twice as fast or better. Even using the Dev Drive, which is supposed to optimize performance for development workloads, Windows 11 falls behind.