6 ms·
From https://twitter.com/StriderMyshkin/status/1621418431575896064 https://twitter.com/StriderMyshkin/status/162141843157589606... >A pathway to a blazingly fa
by asicsp 4y ago
From https://twitter.com/StriderMyshkin/status/1621418431575896064 https://twitter.com/StriderMyshkin/status/162141843157589606...
>A pathway to a blazingly fast WSL?
- rcarmo 4y agoWSL2 is already “blazingly fast”, and WSL was no slouch either. They are both impacted by storage overhead, which makes that tweet look kind of misguided.
- olivermuty 4y agoAlso WASM is fast compared to javascript, slow compared to most other things.
- ohgodplsno 4y agoDepending on your benchmarks, WASM can be 5 times slower than C, or equally as fast (sometimes faster). https://programming-language-benchmarks.vercel.app/cpp-vs-wasm https://programming-language-benchmarks.vercel.app/cpp-vs-wa...
- thesz 4y agoWSL2 is not blazingly fast. I use Haskell for my ever continuing self-education and compiling and linking times with ghc under WSL2 is at least twice as slow as the same operations under native Linux on a much less capable machine. It is not just me, it is acknowledged WSL2 is very slow in I/O: https://www.phoronix.com/review/windows10-okt-wsl/2 https://www.phoronix.com/review/windows10-okt-wsl/2 I use WSL2 for reasons but I think I will be much better off with Linux.
- cercatrova 4y agoWSL2 with code inside the Linux file system? Because if you're doing Linux work on the Windows file system, it will be bad. It is at native speeds inside the Linux file system though.
- thesz 4y agoYes, the file system appears to be Windows one. I remember no questions being asked when I set up WSL2. I really doubt that WSL2 will be at native speed with the Linux file system, because reads and writes still have to go through Windows kernel to be mapped into actual hardware reads/writes.
- Kipters 4y agoThey will go through Hyper-V, not Windows
- sz4kerto 4y ago> I really doubt that WSL2 will be at native speed with the Linux file system, because reads and writes still have to go through Windows kernel to be mapped into actual hardware reads/writes. No, Linux is running alongside Windows, not under it. Windows itself is virtualized when WSL2 is turned on, and both Linux and Windows run under Hyper-V. It's quite fancy actually.
- madeofpalk 4y ago> Windows itself is virtualized when WSL2 is turned on Is there documentation/explainer for this? I've been trying to understand more about this (was this a change in Windows 11? Is it only when WSL2 is installed?) for a while now, but not found anything apart from stray HN comments every now and then.
- wongarsu 4y agoIt's the fundamental difference between WSL1 and WSL2. As designed in the 90s, the Windows NT kernel can have different subsystems that offer different userspace APIs to different software. Originally there were the Win32 subsystem, the Security subsystem, the Posix subsystem and the OS/2 subsystem. The latter two fizzled out, but WLS1 is basically just another subsystem that provides a linux-compatible API to the Windows kernel. As it turns out providing full compatability is really hard though, so WSL2 is a complete rewrite, ignoring the subsystem concept. It basically just runs linux in Hyper-V, and adds some UI/UX to make that convinient. That Windows is then running virtualized is just how Hyper-V works, as soon as you turn on Hyper-V the host Windows runs as a guest in Hyper-V, though with special privileges [1] https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/about/#limitations https://learn.microsoft.com/en-us/virtualization/hyper-v-on-...
- actionfromafar 4y agoI wonder how VirtualBox would fare in your use case then. Especially since one can tweak I/O settings easily inside Linux too.
- jart 4y agoVMWare is a must for Windows. Code compiles 10x faster in a virtual machine on Windows than it does if you compile on Windows natively. Or 100x faster if you forgot to disable Windows Defender. I've always found that amusing.
- cassepipe 4y agoAny idea of why this is?
- ohgodplsno 4y agoMost compilation processes create a lot of very small files. Or a metric ton of them if you're unlucky enough to do js. NTFS is awful at doing lots of small accesses on very small files, at least compared to Ext4. Add to that the fact that if you're on WSL, it needs to write POSIX attributes (which NTFS has no support for and therefore WSL must emulate), and that's a recipe for builds being slowed massively by IO. As for Defender, well, Defender sees new files and halts everything while it scans them. You can see how that can be a problem for a process that pops out tens of thousands of temporary files, which it will all go and scan, locking them while it does so.
- jart 4y agoAnother thing that makes Windows builds go slow is the lack of vfork(). On Linux, vfork() lets you create and teardown a new process in ~30 microseconds. On Windows it takes about 6000 microseconds to do the same thing, which is in large part due to the lack of copy-on-write memory (which Windows won't support, due to Microsoft corporate culture being heavily biased against overcommit models).
- csdvrx 4y ago
- meibo 4y agoIf you cross the IO boundary to the Windows FS, yes, it is slow and your compilation will be slow. You need to have the project in the WSL FS, it's always been this way and I get pretty much native performance this way. Your editor can navigate to the WSL filesystem instead.
- csdvrx 4y ago> If you cross the IO boundary to the Windows FS, yes, it is slow and your compilation will be slow If you need good IO performance, WSL1 is still a valid option. I need good IO performance, and it's not clear how much of the overhead is due to NTFS, and how much is due to 9p (to pass the VHDX file on the NTFS partition to WSL2) So I'm planning some experiments with OpenZFS for windows and NTFS3 (https://old.reddit.com/r/zfs/comments/10lcnpk/zfs_raw_passthrough_on_wsl_what_do_you_think_of/ https://old.reddit.com/r/zfs/comments/10lcnpk/zfs_raw_passth...), first using a WSL2 kernel with the option enabled (https://github.com/microsoft/WSL/issues/8564 https://github.com/microsoft/WSL/issues/8564 and https://github.com/bioluks/WSL2-Linux-Kernel-NTFS https://github.com/bioluks/WSL2-Linux-Kernel-NTFS) then WSL1. I have a dual NVMe setup and W11 for Workstations, so it should be possible to run a passthrough of both partitions to the kernel. However, it's not clear yet how to do that with a VHD on VHDX: most of the documentation I've read about VHD (or VHDX) refers to a passthrough as an "old" option: https://www.altaro.com/hyper-v/hyper-v-pass-through-disks/ https://www.altaro.com/hyper-v/hyper-v-pass-through-disks/
- 2fast4you 4y agoHave you considered swapping Windows and Linux? Depending on your use case, you can still get pretty good performance out of virtualized Windows if you use PCI-E passthrough
- csdvrx 4y agoI have: I generally prefer Windows, but depending on the test results, this option is definitely on the table! As the computer has 2x NVMe and 2x GPU, it should be easy to do a GPU passthrough (with one GPU for Linux native, the other in passthough to Windows) but this brings a little extra complexity I'd rather avoid if I can.
- peoplefromibiza 4y agorelevant bits from the comment you're replying to > They are both impacted by storage overhead
- sz4kerto 4y agoWSL2 is actually just a Linux VM running directly on Hyper-V (not under Windows). It provides 99.5% native performance. If you're accessing files through SMB or something then sure, it'll be slow.
- smartmic 4y agoI agree. If I would stay solely inside the WSL2 VM, it might be fast but my problem is that I need a tight integration between the Windows and the WSL2 file systems. In effect, this is a real pain, especially when it comes to I/O. But WSL2 also constantly loads one or more CPU cores to 100%+. My whole system feels handicapped. I probably have additional problems due to MS Defender, all known measures (that I can implement at all in a corporate-managed environment) have hardly remedied it.
- denzil 4y agoNot sure if it helps in your case, but you also can access wsl disk from windows side. This could give better performance for some uses.
- csdvrx 4y agoHaving to use both msys2 and WSL2 is a bummer :(
- csdvrx 4y agoIt's probably due to hooks on NTFS file open. It shouldn't happen for files inside the ext4.vhdx (the / partition)
- drowsspa 4y agoI hate how low are our expectations of "blazingly fast" these days.
- saagarjha 4y agoNope, this won't really be an improvement.