• Home
  • Blog

Optimizing WSL

Updated on May 31, 2019

Note: According to Microsoft's Richard Turner's tweet, it is NOT recommended to exclude WSL from Windows Defender's scanning.

As I've said before, I absolutely love the Windows Subsystem for Linux. No more dual booting or fussing with VMs. However, it can get sluggish when running read/write-intensive tasks.

According to this Github issue, one major cause of this is Windows Defender's real-time scanning. I am definitely not comfortable completely disabling it, but one of the solutions further down in the comments suggests adding exclusions to Windows Defender instead - specifically the folders in which most executables are stored.

The WSL filesystem directory in Windows is something like:

C:\Users\USERNAME\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs

Note: This is for Ubuntu.

The paths to the Linux executables will then be at:

bin\*
sbin\*
usr\bin\*
usr\sbin\*
usr\local\bin\*
usr\local\sbin\*

I also added the folders where I save source code as exclusions.

Running npx create-react-app test on my laptop before adding the exclusions took 719 seconds - about 12 minutes. After adding the exclusions, the command only took 139 seconds. That's almost 10 minutes less! I didn't time my other tasks, but switching between and installing different node versions felt much faster also.

This is a dramatic improvement and resolves the issue for me. I'm feeling as productive as ever in WSL.