Why WSL 2 is 13x Faster Than WSL: Insider Preview Impressions

Microsoft is preparing a release of Windows May 2020 Update (20H1). This update will contain some nice UI improvements, but more important for developers and other initiates is that the new version of Windows will appear WSL 2 (Windows Subsystem for Linux). This is relevant information for those who wanted to switch to Windows, but did not dare.

Dave Rupert installs WSL 2 on its 13-inch Surface laptop and first results
pleasantly surprised:

The second version of WSL is 13 times faster than the first! Not every day you get a 13x productivity boost for free. I felt a chill and uttered a mean male tear when I first saw these results. Why? Well, basically, I mourned the lost time that had accumulated over 5 years of working with the first version of WSL.

And these are not just numbers. In WSL 2, installing npm, building, packing, viewing files, rebooting hot modules, starting servers – almost everything I use daily as a web developer has become much faster. It feels like it’s like sitting down on a Mac again (or maybe better, since Apple has drastically limited its processors in the last few years in favor of increasing battery life).

Why such agility?

How did they achieve 13x productivity growth? Earlier, when I thought about switching to Mac, I also threw up some options, however, purely at the level of assumptions. The fact is that writing to disk and Linux system calls were quite expensive (in terms of time overhead) due to the architecture of the first version of WSL. And now guess what modern web development relies heavily on? Yes. When you put together a bunch of dependencies and snippets of code each time you save a file, you actually do a lot of disk writing and system calls for tens of thousands of files.

As soon as you learn about it through your bitter experience, after that it’s hard to forget everything. You begin to gradually become depressed when you imagine how slowly and sadly it all works. And you understand that your world will no longer be the same and the tool that you liked no longer seems useful and effective.

Fortunately, the WSL team took a risk and completely rewrote the subsystem. In WSL 2, these problems were resolved: developers integrated their own Linux virtual machine into Windows and assigned file operations to the VHD (Virtual Hardware Disk) network drive. The trade-off is that the first time you start, you have to spend time to spin up a virtual machine. This time is calculated in milliseconds and for me personally is barely noticeable. For example, I wait with pleasure, because I know what all this is for.

Where will the files live now?

To take full advantage of WSL 2, you’ll want to move project files from / mnt / c / Users /<имя пользователя>/ to the new home directory ~ / Linux on the new VHD. You can see the contents of this disk on the network by going to \\ wsl $ \ <имя дистрибутива> \ <имя пользователя> \ home or by typing a command explorer.exe from your shell bash.

This is a real Linux file system, and it acts and behaves as you expect. I created a folder ~ / projectswhere all my project repositories live and then I open projects in Visual Studio Code using the code command.

What about VS Code?

Installing WSL-expansion for remote development on VS Code (VS Code Remote – WSL) is the last step to ensure the developer’s comfortable work. The extension allows VS Code to perform all of its operations (git commands, consoles, installing extensions, and so on) by interacting directly with the Linux virtual machine. This makes the whole process very autonomous.

At first, I was a little upset about the need to install this extension, because I needed to reinstall what I installed and configured before. But now I appreciated it because a special visualization layer has appeared that shows in which environment I work and where my files live. This made the web development process on Windows more transparent and greatly simplified the use of the user interface for version control in VS Code.

Tears of happiness and hope for a brighter future

I have a feeling of joy when I think about the next release of the Windows May 2020 Update and the optimized Linux subsystem that just flies on my powerful gaming computer. Perhaps there are some more problems that I do not know about, but after Insider preview I concluded that the WSL team solved most of the problems.

In addition, do not forget that Windows terminal good too! They seemed to hear my complaints about the lack of tabs, JSON Settings and the need to “feel cool” on Windows. It still sounds strange, but Windows Terminal is probably the best terminal for Windows.

After working in Windows for 5 years, I went through a lot: the inability to install Rails, the fight against Cygwin artificial shells. I sat in the front row at the same Build 2016 conference when Microsoft announced the first version of WSL. And then I had the hope that web development on Windows would finally reach a new level. Without a doubt, WSL 2 is the biggest improvement I’ve seen since then, and it looks like we’re on the verge of a new era.

As an advertisement

If you need to work Windows serversthen you definitely to us – automatic installation of Windows Server 2012, 2016 or 2019 at rates with 2 GB of RAM or higher, a license is already included in the price. Total from 21 rub per day! And we also have eternal servers;)

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *