6 ms·
No free lunch, of course. Faster file access with WSL2 (vs WSL1), if you stay in the Linux world. But if you point it at Windows files (/mnt/c, etc), it's pre
by tyingq 7y ago
No free lunch, of course. Faster file access with WSL2 (vs WSL1), if you stay in the Linux world. But if you point it at Windows files (/mnt/c, etc), it's pretty slow.
WSL2 just moved the slowness from one side to the other. Accessing the Linux FS from Windows (\\wsl$\) is also slow.
That said, I am a fan, and get a lot of use out of WSL1. Since I don't use the Windows interop much, WSL2 should be a performance win for me.
- drey08 7y agoYep. With WSL I can seamlessly access files from both Linux and Windows. I use the Terminal (Windows) and various Unix tools for a lot of stuff (compiling & testing on Posix, objdump, debugging). And I use Windows GUI tools for editing (Sublime), diffing (BeyondCompare), and so on. I get the best of both worlds. But WSL2 file access in `/mnt/c/` is now unbearably slow. So I just stick with WSL1. From what I've read, Microsoft intends to support both WSL1 and WSL2 for the foreseeable future. So that's good.
- tyingq 7y ago"Microsoft intends to support both WSL1 and WSL2" I'm not sure I believe them. Maintaining a whole tricky "fake" kernel/translation shim must be a lot of work.
- frankc 7y agoYou never know but as has been pointed out in different parts of this post, they have two different use cases in a sense. Windows developers who were using WSL1 aren't going to like the changes and i've heard a lot of complaints. However, people using primarily linux with windows as a nice shell with good hardware support and games are going to prefer WSL2. I think if they want to win over the biggest group of devs, and I feel pretty good about that since they were losing traction with them for years, they will maintain both, at least for a good while.
- drewg123 7y agoFreeBSD has a similar syscall translation layer (and has had it for over 20 years). They do it with a team of part-time volunteers. This is enough to maintain basic support, but FreeBSD still lack support for newer Linux syscalls which prevent things like the Linux binary version of Chrome from running on FreeBSD.
- tyingq 7y agoYes, but translating syscalls across two Unix like systems is likely much easier. Big parts of it even just straight mapping one number to another.
- drewg123 7y agoThis is somewhat true, but not entirely. You have to remember that FreeBSD and Linux share no common ancestors, and FreeBSD defines its ABI at the libc level, whereas Linux defines it at the syscall level. There are also subtle differences in how various internal kernel mechanisms work (such as flag definitions for calls). See linux_common_open() for an example of an "easy" straight mapping. https://github.com/freebsd/freebsd/blob/68a4c41e983228d54619ac5a6c170197eacd8c9b/sys/compat/linux/linux_file.c#L88 https://github.com/freebsd/freebsd/blob/68a4c41e983228d54619... This is true even between OSes that share a common ancestor. I was the maintainer of FreeBSD/alpha, and did the compat layer for OSF/1 / DEC UNIX / Tru64 starting with NetBSD's version and adding new calls, etc. The very easiest calls were the simple ones that both inherited from 4.3BSD or earlier (read, write). Medium were things that had diverged in different ways (stat, mmap), and for me the harder things were ABI handlers for the OSF/1 executable format (ecoff). The hardest stuff was things at almost worked, except for maybe one flag was different, and it was hard to notice because an OSF/1 program would run for 5 minutes, and then coredump.
- tyingq 7y agoThat's a great rundown. I didn't mean to oversimplify the effort. Just to say that mapping Linux to Windows is likely much harder. The lseek() call in your link is closer to what I meant by simple.
- mehrdadn 7y ago> I'm not sure I believe them. I'm not sure why anyone should. They literally say "We currently have no plans to deprecate WSL 1" while simultaneously claiming "We are committed to making WSL 2 feel the same as WSL 1". There's no way their goal is to reach a steady state where they feel the same and yet both have to be maintained. Making them feel the same is literally what you do when your goal is to stop support for one of them. They probably just haven't "planned" it yet, unless they don't expect they will actually ever get them to feel the same.
- yebyen 7y agoI watched Aaron Patterson's keynote from RailsConf 2020 (these talks all just came out this week, Couch Edition) and I'm struck when reading your comment that it's absolutely possible to do this, and ultimately you may or may not reach a state where it's possible to "end-of-life" one or the other alternative without making anyone cry about it. He spends most of the second half of the talk explaining (with a profiler) how two query implementations on ActiveRecord which should be doing pretty much about the same thing, actually perform wildly differently, and narrowing it down with data to understand why. The talk is really interesting and I think it's a parallel to the current discussion in a way because, in Aaron's talk there were two implementations and one was obviously better performing (but unfortunately it was the one that is harder to write.) He argued mostly that, unless there is a reason for these two implementations to behave and perform differently, the one that is slower (but easier to write) should become more like the one that is "enhanced with a performance pro-tip" that arguably the ActiveRecord user shouldn't really need to know about. In other words, that the bad performance was actually a bug. (tl;dr: the pro-tip is, to build your own pre-sanitized SQL WHERE clause strings, because you may save something like 38% performance in a pathological case, recovered time that the SQL engine was going to spend traversing AST and compiling.) My point is that, exactly. If there is bad performance over here, it is a bug. Bad performance over there, bug. But bad performance over here, that can only be solved by swapping for bad performance over there? This does not sound like a bug anymore, it starts to sound more decidedly like a trade-off. But given enough time, perhaps they will fix the bugs, and the two can be made to perform similarly, fixing bugs on either side, and the need for two alternatives will go away. So why would that be bad? (And if it can't be done, or can't be done yet, why wouldn't we expect to see both implementations maintained as long as needed to find a solution that pareto-dominates them both?)
- d2161 7y agoWhy not just store files in WSL home directory? It's faster than accessing from mnt/c
- unicornfinder 7y agoWell it depends on your use case. If you're using WSL to develop web apps then storing it all in WSL is fine, but if you want to use Linux tools to process a load of files in your Windows drive then it's not quite as smooth sailing...
- mattwad 7y agoCheck out VS Code. It can now read and edit files inside of WSL remotely [1]. I've been using it on a new project and it works almost seamlessly * . I don't know if other editors will get this functionality, but there's really no need now for me to save files in /mnt/c. [1] https://code.visualstudio.com/docs/remote/wsl https://code.visualstudio.com/docs/remote/wsl * One curious effect is you can't move folders from VS Code due to permissions. So I have to close it and use Windows Terminal for that, but moving folders doesn't happen too often.
- nickjj 7y agoCouldn't you do the reverse now with WSL 2? The files would live in WSL 2 directly, but then you access them over Windows through the WSL network path? I don't have insiders installed so I don't know how slow that would be. Like if you CTRL+p'd in Sublime Text, would it have to grab a list of files from over the network on every call, or does it cache these files locally on a per ST session basis, etc.. There's also maybe the option of running ST natively in WSL 2 and expose its GUI over an X-server. I know latency there is very good (near native) because I've done it in the past. This also gives you the added advantage of ST being able to know about your Linux environment which could be nice for linting and other things that require having your programming runtime installed in the same place as your editor. You can still have shortcuts too in Windows, for pinning stuff to your taskbar or having right click menus. I do this with Vim now with WSL 1, where I have a custom "open with Vim" right click menu in explorer that opens terminal / native Linux Vim that's installed in WSL.
- muststopmyths 7y agoI'm sure I'm missing something but I don't get this problem with filesystem access performance. It seems the obvious way to do this was to have SMB mounts on either side and optimize the hell out of the already existing SMB implementations on both OSes to get the performance close enough to disk. Maybe have a dedicated virtual network interface exposed only to the VMs and not to the LAN to avoid security issues. It probably wouldn't get exactly up to native high-end SSD performance but I'd wager you can get it close enough that people wouldn't care. Meanwhile, try to do a "git status" right now in Linux in WSL2 on a sizable repo in your /mnt/c and feel yourself slowly die inside. It seems like a bunch of people thought it would be a great science project to write custom kernel drivers for Linux and Windows and learn some stuff along the way. So now they're stuck supporting two complicated software implementations for god knows how long, because neither of them does the job on its own. Like I said, I'm probably missing something. I'm a network guy, so maybe to me everything can be solved by the network stack. (edited last line)
- tyingq 7y agoGreat question. They do have an in-depth blog post of how it works for WSL1: https://docs.microsoft.com/en-us/archive/blogs/wsl/wsl-file-system-support https://docs.microsoft.com/en-us/archive/blogs/wsl/wsl-file-... Though it doesn't mention why they didn't try what you suggested. The actual I/O doesn't seem so bad...like writing to a single file. It's things you mention, that create or modify lots of files (git clone, for example) that are really slow. Edit: Apparently, the Windows side \\wsl$\ access does do what you're suggesting, sort of: https://devblogs.microsoft.com/commandline/a-deep-dive-into-how-wsl-allows-windows-to-access-linux-files/ https://devblogs.microsoft.com/commandline/a-deep-dive-into-... It's using a 9P network file server, derived from plan9.
- e12e 7y agoI'm not really using wsl in anger (work laptop runs Linux, with a win 10 vm in virtualbox for the occasional nearly windows program; mostly the odd proprietary vpn; Citrix and occasionally rdp - although remmina on Ubuntu 18.04 mostly works fine) - but I've toyed with the idea of testing smb/cifs and nfs both ways - to see if it isn't good enough for a git checkout the size of the Linux kernel (Ditto a build/compile of same - although I'd normally mount a ramdisk for that, if I really wanted to speed things along). Both windows and Linux should be fine with home on cifs.
- sandGorgon 7y agoexactly this is the problem. As the article says >To get the full benefit of WSL 2, you’ll also want to move your project files from /mnt/c/Users/<username>/ over to your new ~/ Linux home directory on your new VHD. You can see the contents of this drive on the Network by going to \\wsl$\<distro name>\<username>\home or typing the command explorer.exe . from your bash prompt. >This is your Linux filesystem and it acts and behaves as you’d expect. I made a folder called ~/projects that has all my project repos and then I open those projects in VS Code using the code . command. i have accidentally wiped my home directory on Ubuntu VM reinstall. I cant even backup it up easily. WSL engineers need to figure out a way to make the Linux home directory to be persistent. If we are living in the docker world, this is a solved problem - docker volumes live separately to the docker VM itself. WSL2 needs to do something like that.
- httpsterio 7y agoGit? All of my work is backed up to git, even my dot files and config is there. For me, I try to keep my WSL "stateless" and never store anything there unless it's a copy of something.
- sandGorgon 7y agoim running a postgresql database, building docker containers, etc etc. this is a problem that needs a "docker volume" solution. git is just not enough. think in terms of people moving to Windows from Linux.
- e12e 7y ago> i have accidentally wiped my home directory on Ubuntu VM reinstall. I cant even backup it up easily. Normally, it'd live on an nfs mount, or a cifs share. If you're stuck with VMs for some reason, setting up a dedicated storage appliance would probably be the way to go.
- sandGorgon 7y agoOr it will live inside my linux dual boot...where it should. If WSL wants me to migrate to Windows...they should fix this.