WSL2 is a bit like Firecracker for Linux. It's a lightweight VM, with a lot of optimizations here and there. For faster startup, lower memory footprint and so on.
PS: which means you need a lot of memory, if you use WSL2 extensively (multiple Docker containers for example). 8-16 GB on top of your usual workloads is a good starting point. Docker on WSL2 is not a lot of fun with less than 20 GB system memory.
Any idea how they do this? My WSL2 starts insanely fast, like about 1-2 seconds. I've never seen a linux distro natively boot that fast. Assuming they suppress any sort of BIOS startup screen for starters, but what else?
dmesg looks like the kernel is booting up normally, so I guess they don't use some memory snapshots magic.
I guess they just tweaked the kernel and the hypervisor to start up fast. There is also no BIOS/UEFI delay.
And when you run multiple "distributions" or instances, they all share the same running VM and kernel. So after a one-time startup of the VM+kernel, opening more distributions/instances is like starting new system containers (similar to lxc/lxd or systemd-nspawn, which are also very quick to spawn on Linux) rather than new VMs. The architecture is quite similar to Linux-on-ChromeOS (Crostini).
Also the difference to Apple tax in SSDs and RAM remains, or do you think Apple will let go of their beloved margins on top?
Contrary to Apple, we can still add RAM and SSDs in many models, and chose which brands we buy.
I’m still disappointed to see the days of easy RAM/storage upgrades have largely gone. I was initially suspicious of the reasons offered for why soldering memory directly to the motherboard is necessary, but with a few years of academic engineering experience (I don’t use much of my EE education in my day job), it’s not illogical—as frequency increases, the circuit’s sensitivity to parasitic inductance and capacitance also increases, and connectors/interfaces are a big source of parasitic effects and general nonlinearity. That said, my desktop has traditional DIMM slots, and it’s technically running faster DDR5 than any of my other devices with soldered DDR4 modules.
I charitably assume the difference is laptop’s need for greater efficiencies, but either way it would be nice if the manufacturers hadn’t instantly taken advantage of this new “necessity” to jack up prices on memory and storage quite so aggressively. It’s probably also worth noting that Apple was first to really do this widely, as far as I’m aware, with the M1 chipset. Also worth noting the M1 was groundbreaking, and it’s seemingly magical memory management made it so an Apple M device with ~60% of the memory of its x86 equivalent can perform just as well (if not better). I have an 8GB M1 Mac Mini that’s still quite functional for routine work. 16GB still provides great performance.
But then, my AMD desktop that cost ~$1200 a year ago (with a capable GPU) is sporting 48GB because I could pay a reasonable price for DIMMs that I can plug-in myself. Similar specs on a mass-market machine probably would have run that price up to near $2000.
For example Lenovo US store. Thinkpad X1 carbon has an i5+16gb as base, and i7+32gb for +289$. P15s (2x sodimm) comes with 16gb in base, 32/64gb is +199/399$. Completely reasonable.
How is the graphical app support these days?
Or more step by step: https://gist.github.com/artman41/858450e2c29b239d8692213b684...
I used it for a little bit (got Windows laptop, thought maybe I'll switch but no), and just hated that split brain workspace.
\\wsl$
UNC and you should be able to easily subst a drive letter for the dumb software from eons ago that doesn't support UNC paths.Of course this comes down to whether you care or not about the integrations with Windows.
Is the reverse also true? Does Wine face any similar performance problems?
They made it much better with Dev Drives, that use ReFS instead of NTFS and disables most of the filters in the filesystem stack.
Listing large directories is slow. But it is what it is.
But the filesystem performance really put a huge spoke in this. I thought everything was better with WSL2, but I was surprised to see that MS hasn't engineered some driver or something that would make this much more performant or pass-thru so that you can have a directory on windows but also have it perform really well in the VM.
But also pnpm has quite decent performance on NTFS, it uses symlinks
You can put everything inside Linux, but then it's better to switch to Linux completely. Doesn't make sense to do everything inside the wsl vm.
Node/js development works really well on native windows. Some things are a bit slower, but it's not horrible.
1. WSL2 mounts Windows drives under /mnt/ . You can just cp things
2. WSL2 Distros are exposed as Network shares. WSL installs a virtual "Linux" shell folder to Desktop and explorer navigation bar. It is hard to miss. Moreover a simple search query would show you \\wsl$ share
This was the top result for me:
https://askubuntu.com/questions/1439131/access-root-user-dir...
So to provide more detail, things were slowed down further because this was one of those teams meetings where you can't just take over, but have to tell someone to type another command and wait for them to type it. The second thing was that the user didn't tell me that they were switching to another user when escalating to admin (cuz I couldn't see that elevated system dialog in the screen share). So it turned out they had installed WSL as a different admin user, so when they went to \\WSL$ (as their original user), it wasn't showing any shares. That set off a lot of googling and claude'ing that went nowhere.
Suffice to say I was ready to end the day after that meeting :-)
A red flag early on was when a bun install took 8 mins when trying to run it on /mnt/c, when it took 200ms on my machine. So I knew there had to be some weird filesystem overhead stuff going on. So then when we got it working beautifully by just using the VM's filesystem, I was personally happy with it but the person on the other end felt this was all too cumbersome and was soured on WSL, even though I tried to explain the differences.
I kept thinking that WSL was the greatest thing since sliced bread and got the message that MS had found a way to make them work beautifully together (especially in WSL2). I'm sure I could've figured this all out on my machine in probably 10 mins.
Wine probably isn't something you'd want to use if you're concerned about actually enforcing full Windows security rules. Even if you were able to enforce access to files when executing within Wine itself, the wine prefix will still usually just be a bunch of 644-permissioned files sitting on a Linux filesystem that can get used like any other; the entire wine prefix is just a regular directory with regular files from the external perspective of the wider system, and nothing stops anyone from doing whatever they want that they could do to any other file with the same permissions.
Here is the tracking issue:
https://github.com/microsoft/WSL/issues/12103
And if nothing works you can still manually optimize.
https://superuser.com/questions/1827953/reclaim-wsl2-disk-sp...
"The Linux Kernel Hidden Inside Windows 10"
https://youtu.be/_p3RtkwstNk?si=V9vhvrdDOLu2Durr
WSL Pico Process Overview
https://learn.microsoft.com/de-de/archive/blogs/wsl/pico-pro...
The same Drawbridge technology is used to run SQL Server on Linux.
https://arstechnica.com/information-technology/2016/12/how-a...
We're using a lot of WSL in CI - we're mostly Linux based, but for some stuff toolchains came up which didn't work nicely with wine (like MSVC). So for us we want a Linux system that seamlessly can execute Windows stuff in a Linux based build process. WSL1 can do that, WSL2 can be kicked into working somewhat, but needs quite a few ugly workaround as they're not sharing a process namespace or file descriptors. While the faster IO would be nice that's pretty much the only thing we'd care about - and wouldn't work here, as we need shared access to the files. And while we could access the WSL2 files from Windows side that's even slower than just using WSL1.
I’m sure you’ve encountered a very niche problem that requires it, but I cannot think of any scenario where that kind of behaviour would be desirable vs splitting those workflows up.
Are you not able to have separate Windows and Linux hosts (eg VMs or containers) that are instigated to run in parallel as part of the same pipeline, but don’t rely on the same processes running in the same host?
Or at the very worst, use a TCP/IP based RPC to share state between the different hosts?
https://clang.llvm.org/docs/MSVCCompatibility.html
https://llvm.org/devmtg/2014-04/PDFs/Talks/clang-cl.pdf
XWin for the CRT/SDK:
https://github.com/Jake-Shadle/xwin
https://jake-shadle.github.io/xwin/
A while ago I got some Python C extension modules building using this approach, but didn't push it any further.
(Shout-out to IAR, though. I still think they're overpriced and you don't really need them - but if you're stuck with them their support is excellent. When an update broke license handling in our setup they didn't tell us to go away like any other vendor would've done for that kind of wildly unsupported use case, but actually made it work again in the next release. They also got us access to native Linux binaries way before they even were talking in public about working on that to play around with for our CI)
WSL2 is more capable, but it's not Windows anymore. I might as well run a proper Linux VM or dual boot. Better yet, I'd rather run a Windows VM in a bare metal Linux OS. Why even bother with WSL2? What's the value add?
GPU access. Actual graphics use is so so, but essential for doing CUDA/AI stuff
Faster file system access on the Linux side (for Linux compiles etc). Ironically, accessing Windows filesystem is slower than WSL1.
Better Linux compatibility.
Vs a Linux VM:
GPU access!
Easier testing for localhost stuff, Linux ports get autoforwarded to Windows (if your test http server is running in WSL2 at port 8080, you can browse to http://localhost:8080 in your Windows browser)
Easy Windows filesystem interaction. Windows local drives show up in /mnt automatically.
Mix Windows commands with Linux commands. I use this for example to pipe strings.exe, which is UTF-16 aware, with Linux text utils.
I think WSL2 tends to be better at sharing memory (releasing unused memory) with the rest of the system than a dedicated VM.
You can mimic some of this stuff to a degree with a VM, but the built in convenience facetor can't be overlooked, and if you are doing CUDA stuff there isn't a good alternative that I am aware of. You could do PCI passthrough using datacenter class GPUs and Windows Server, but $$$.
You can call windows programs from linux (e.g. explorer.exe .)
Obviously you don't do the thing you're writing about. A "proper" Linux VM would incur more work for you and would be less useful. Dual boot would remove your ability to use the computer for activities that need a Windows OS. Running a Windows VM on Linux would take you down a rabbit hole of pain and annoyances, unless your use case for Windows is extremely limited.
If I'm running Windows, it means that the files and projects that I care about are on the Windows file system. And they need to be there, because my IDE and other GUI apps needs files to be on a real file system to work optimally. (A network share to a WSL2 file system would not let the IDE watch for changes, for instance.)
WSL1 was a great way to get a UNIX-style command line, with git, bash, latex etc., for the Windows file system. WSL2 was just too slow for this purpose; commands like "git status" would take multiple seconds on a large codebase.
Now I switched back to MacOS, and the proper UNIX terminal is a great advantage.
LOL, this made my day :P
LBW is a Linux system call translator for Windows. It allows you to run unmodified Linux applications on top of Windows.
It is not virtualisation; only one operating system is running, which is Windows. It is not emulation; Linux applications run directly on the processor, resulting in (theoretically) full native performance.
Consider it as being like WINE, but in reverse.
https://cowlark.com/lbw/index.html https://github.com/davidgiven/LBW
LINE Is Not an Emulator. LINE executes unmodified Linux applications on Windows 98/2000 by intercepting Linux system calls. The Linux applications themselves are not emulated. They run directly on the CPU like all other Windows applications.
LINE runs best on Windows 2000
https://web.archive.org/web/20010803130404/http://line.sourc...
Call me crazy, but I've wanted to run a linux binary natively under windows for a while now; kinda like wine, but in reverse.
Well, the other day I was browsing through the MSDN docs (as you do) and discovered that it is possible to install a "vectored" exception handler. A quick bit of test code later, and I discovered that I can trap "int 0x80" instructions using this technique--those are used by linux binaries to initiate syscalls
https://web.archive.org/web/20100409222341/http://netevil.or...
As an example, I can run KiCAD just fine under X11 with the modesetting driver, including the 3D board view.
How does VMware implement OpenGL and Vulkan acceleration in the VM?
On the linux side, the vmwgfx kernel driver and DRM drivers are used. For X11 you use modesetting, and for Wayland whatever it auto-selects. I don't use KDE but I can confirm Debian's Gnome works out-of-the-box with the default Wayland backend (to be fair, the only other compositor I tried was Sway, which is known for being picky about the GPU used). Copy/paste works properly, as do general acceleration.
I use those VMs daily, fullscreen on a 1440p monitor, so acceleration is not optional :)
You need to ensure that DirectX driver is used with tools like eglinfo. Most of the time, the main culprit is LLVMpipe software driver being used due to wrong detection.
I find WSL2 pretty much useless. When I want Linux inside a VM I use VMware which is just better. VMware has tree of snapshots to rollback disk state, hardware accelerated 3D graphics (limited though, I think only GL is there no Vulkan, but it’s better than nothing), can attach complete USB devices to the guest OS, can setup proper virtual networks with multiple VMs, and the GUI to do all that is decent, no command line required.
mindcrash•2mo ago
However, there's some interesting things going on in WSL 2 versus a "normal" Hyper-V virtual machine. For example, a Linux distro running on WSL can (and will) use GPU partitioning (aka PCI/GPU passthrough) and a special implementation of DirectX enabling the installed video card to accelerate graphics within X and/or Wayland.
Although this feature can be enabled with a lot of hacking in both the Linux guest and vanilla Hyper-V on the host (the latter through Powershell) it is officially unsupported on Windows 10 and Windows 11, and is only supported on Windows Server.
sedatk•2mo ago
DiabloD3•2mo ago
Using GPU passthrough, however, is allowed. WSL2 does this by using the existing Mesa/DRI/DRM open source stack, but instead of a GPU-specific DRM driver, it is one that speaks WDDM (the DRM equivalent in the Windows driver stack), and only requires a GPU-specific ennoblement package (provided by the vendor, and matches the Windows driver it is talking to; AMD, Nvidia, and Intel all ship one inside of WSL2).
sedatk•2mo ago
toast0•2mo ago
If it was enabled on Pro, I would use PCI passthrough. I use hyper-v for a Linux dev environment on a windows workstation. My NIC supports virtual functions, so if I could passthrough one to the dev VM, I wouldn't need software bridging and that might be nice. (OTOH, I don't know if my motherboard has reasonable passthrough groups and all the other stuff that makes passthrough never work for me)
Zardoz84•2mo ago
Spivak•2mo ago
If there was software that made Windows as seamless on Linux I bet it would get a lot of use.
toast0•2mo ago
pjmlp•2mo ago
https://techcommunity.microsoft.com/blog/windowsosplatform/a...
my123•2mo ago
The keyword to search for: "GPU-P"
https://learn.microsoft.com/en-us/windows-server/virtualizat...
evanjrowley•2mo ago
It relies upon SR-IOV and only several server-specific Nvidia GPUs are listed as supported.
Intel's Flex dGPUs and Arc iGPUs have supported SR-IOV for years now, but they aren't listed there. It would be super awesome if Microsoft could add it for Intel Arc iGPUs, desktop versions of Windows, and WSL2! Intel's GPU SR-IOV already works with KVM on Linux!
rusk•2mo ago
danjl•2mo ago
user34283•2mo ago
As an end user, the out of the box experience of getting a blurry window with the wrong content size isn't very useful. And I've never tried to actually configure it properly.
I wonder if it's a decent experience even when configured properly. In that case, why do all the IDEs come with remote development / WSL integrations that involve running the client on the Windows side?
nine_k•2mo ago
p_ing•2mo ago
bogwog•2mo ago
Imagine licensing and installing Windows Server to run Linux software through WSL
someguy101010•2mo ago
lukeschlather•2mo ago
pjmlp•2mo ago
https://learn.microsoft.com/en-us/azure/iot-edge/tutorial-de...
CoolCold•2mo ago
arghwhat•2mo ago
That is still just a normal VM, but it's nice that it's automated.
> enabling the installed video card to accelerate graphics within X and/or Wayland.
nit: X and/or Wayland is not involved in application rendering at all - its applications themselves that use the GPU and its acceleration directly.
Wayland and/or X is only involved when the apps are all done rendering[0], and the display servers own rendering is the comparatively simple task of stitching windows together[1], and sometimes not even that.
0: You can send buffers early over Wayland if you also send a sync fence, but this is just forwarded as a render dependency that the GPU scheduler will patiently wait for.
1: well also dealing with stuff like color transforms which can be complex to understand, but are computationally cheap and for fullscreen content possibly entirely free.
kiddico•2mo ago
arghwhat•2mo ago
Also https://wayland.app to see the current Wayland protocols (the Wayland core protocol is mainly some common primitives, most stuff is across the other protocols). For example, the sync object stuff is in https://wayland.app/protocols/linux-drm-syncobj-v1 (in many cases handled by your toolkit or WSI of choice).