WSL 1 vs WSL 2

I’m curious which you use since Julia only supports WSL 2 (tier 2), but I think works for both.

Note, WSL 1 still supported, and neither is clearly better.

WSL 1 has(?)/had small issues with floating point (I’m don’t think fixed and maybe never will).

Maybe actually both outdated: BUG: float128 loses precision on windows subsystem for linux · Issue #8726 · numpy/numpy · GitHub and Failed to build with musl libc in WSL 1 · Issue #512 · radiator-software/p5-net-ssleay · GitHub

WSL 2 has slow file I/O performance, but WSL 1 as fast as possible to /mnt/c since WSL 2 uses 9P from Plan9 intriguingly… For I/O otherwise WSL 2 is claimed near-native speed, not sure if it reverses for WSL 1 outside of /mnt/c

I’m assuming my info (from AI) is still valid:

Benchmarks consistently show a stark contrast depending on the workload:

Operation Scenario WSL 2 (via 9P to /mnt/c/) WSL 2 (native ext4 filesystem) Performance Difference (approx.)
Small File Write npm install (many small files) Very Slow Very Fast 10x - 50x slower on 9P
Large File Transfer Copying a 1GB ISO file Fast Very Fast ~1.5x - 2x slower on 9P
Small File Read git status on a large repo Slow Fast 5x - 10x slower on 9P
1 Like

A naive question: what is 9P?

AFAIK its an network protocol connecting the Linux VM and the Windows VM.

2 Likes

Good question, since it’s a “chatty” (according to AI conversation, thus slower) non-ideal networking protocol, used by WSL in non-networking (the Linux kernel talking to the Windows kernel in internal to the CPU “networking”), to mount the C drive (maybe more so networking actually useful?), and was likely chosen as non-GPL. It’s strange they didn’t use e.g. SMB/SAMBA or NFS…

I do nearly all of my dev work in WSL2 sind around 2 years now and am quite happy with it. In nearly never access the mounted c drive. Occasionally, I do it the other way around, for looking at images in a git folder with windows tools for example. Therefore, I never had any performance problems and it felt quite stable. From what i‘ve heard, wsl2 is what most people use nowadays and most of the guides you find (for stuff like gui applications, cuda within wsl, …) will explain stuff for wsl2.