#[1]Atom 2.0

    * [2]Home
    * [3]Archive
    * [4]About
    *

Initial Impressions of WSL 2

  13× Faster than WSL 1

  May 04, 2020

  Soon the Windows May 2020 Update (20H1) will be released upon the
  world. This update will contain some nice UI improvements, but most
  relevant to me it allows Web Developers on Windows to [5]upgrade to WSL
  2. This is a significant milestone in the #davegoeswindows saga and
  it’s worth posting about what it means going forward.

  I’ve been running WSL 2 on my 13” Surface Laptop 2 for nearly a year
  now and the initial results are jaw dropping:

    Got [6]#WSL2 running on my laptop. Compiling my blog with `bundle
    exec jekyll build`...
    WSL1: 7.853 seconds
    WSL2: 0.567 seconds
    😱😱😱
    — Dave Rupert (@davatron5000) [7]June 18, 2019

  That’s 13x faster! It’s not every day you get a 13x productivity boost
  for free. I got chills and a bit misty-eyed when I saw the results
  myself for the first time. Why was I weeping? Well, I was mostly
  mourning all the lost time I’ve accrued over the last ~5 years.

  It’s not just blog compilations either. This improves npm installs,
  webpacking, file-watching, hot module reloading, server startups;
  nearly everything you do on a daily basis as a Web Developer is
  dramatically faster. It’s like owning a Mac again (or possibly better
  since Apple has been thermal throttling their CPUs in favor of battery
  life for the last few years).

Why is it so fast?

  How could it possibly be a 13x delta? I wrote about it some before when
  [8]I considered switching back to Mac, but the tl;dr is that disk
  writes and Linux stat calls were expensive operations to make due to
  the WSL 1 architecture. And guess what modern web development heavily
  relies on? Yup. When you compile the whole gotdanged planet on every
  file save, you do a lot of disk writes and stat calls on tens of
  thousands of files.

  Once you learn about this bottleneck, it’s hard to un-see. Depressing
  psychology takes over when you hear something’s slow and then finally
  experience it for yourself. Your world caves in a bit and the tool you
  like doesn’t seem practical anymore.

  Thankfully, the WSL team made a big bet and overhauled the whole WSL
  system. Those pain points were solved in WSL 2 by embedding a whole
  first-party Linux VM inside Windows and moving the file operations over
  to a VHD (Virtual Hardware Disk) network drive. The tradeoff is that
  you pay a first-time startup hit to spin up the VM, which is in the
  order of milliseconds and hardly noticeable to me, e.g. nothing like
  spinning up a docker, it’s actually fast.

Wait. Where do my files live?

  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.

Smoother web development

  Installing the [9]Remote Development Extension for VS Code is the final
  step in having a smooth developer experience. The Remote extension acts
  as a bridge for WSL and forces VS Code to do all its operations (git,
  command line, extension installations, etc) straight into your Linux
  distro. It makes it all very self-contained.

  At first I was a little upset by this extension, because it kept
  nagging me to re-install stuff I already had installed. But now I
  appreciate it because it adds a layer of visualization as to which
  environment I’m running and where files exist. It takes some of the
  mystery out of the Windows web development process and using the
  version control UI in Code is a lot smoother.

A new era ahead

  The excitement to install the next Windows Update and to get a proper,
  functioning, fast Linux environment up and running on my beefy gaming
  computer is palpable. There’s probably some problems lurking that I
  don’t know about yet, but following the development on the Insider
  Preview I know the WSL team has solved most of the initial gotchas.

  And [10]Windows Terminal is good now too! It solves [11]all my previous
  gripes about lack of tabs, JSON configurability, and the ephemeral
  problem of “feeling cool” on Windows. It’s still weird to say it, but
  Windows Terminal is hands-down the best terminal on Windows.

  Having been developing on Windows for 5 years, I’ve been through a lot.
  From not being able to install Rails, struggling with faux-bash Cygwin
  shells, and then sitting [12]in the front row at Build 2016 when they
  announced the first version of WSL; that’s when there was a glimmer of
  hope that Web Development on Windows would be viable. Without a doubt,
  WSL 2 is the biggest improvement I’ve seen since then and it feels like
  a new era for Web Development on Windows.

  [13]Home • [14]About • [15]Archive • [16]Likes • [17]Bookshelf •
  [18]RSS

  © 2020 Dave Rupert • [19]Twitter • [20]Github

References

  Visible links
  1. https://daverupert.com/atom.xml
  2. https://daverupert.com/
  3. https://daverupert.com/archive/
  4. https://daverupert.com/about/
  5. http://aka.ms/wsl2
  6. https://twitter.com/hashtag/WSL2?src=hash&ref_src=twsrc^tfw
  7. https://twitter.com/davatron5000/status/1140783242922070016?ref_src=twsrc^tfw
  8. https://daverupert.com/2019/01/things-i-miss-about-mac/
  9. https://code.visualstudio.com/docs/remote/wsl
 10. https://www.microsoft.com/en-us/p/windows-terminal-preview/9n0dx20hk701
 11. https://daverupert.com/2017/03/my-bash-on-windows-developer-environment/#hyper
 12. https://daverupert.com/2016/06/dave-goes-build/
 13. https://daverupert.com/
 14. https://daverupert.com/about
 15. https://daverupert.com/archive
 16. https://daverupert.com/likes
 17. https://daverupert.com/bookshelf
 18. https://daverupert.com/atom.xml
 19. http://twitter.com/davatron5000
 20. http://github.com/davatron5000/

  Hidden links:
 22. https://daverupert.com/
 23. https://daverupert.com/atom.xml