'Bash is slow to start in WSL1, even slower after Windows update [closed]
I'm using WSL1 on a work laptop, which only allows certain Windows updates. This is also why I'm not running WSL2 as there was a networking issue, which was resolved in an update that I wasn't able to install.
I'm using Hyper terminal with C:\\Windows\\System32\\bash.exe as the shell and ['--login', '-c', 'zsh'] as the shellargs to use Oh My Zsh. I have enabled a few OMZ plug-ins, such as autosuggestions, git, npm, and nvm. Everything had been running fine, but opening a new tab/window in Hyper was always slow to be ready. I have some config in my ~/.zshrc, but it's mainly aliases (<10) and an export for nvm. It was tolerable, but now after an update to Windows 10 1909 (build 18363.2094), opening a new tab takes 30+ seconds to be ready to type, running a dev app that used to take a few minutes to start now takes 10-30+ minutes, and cd'ing into a directory with a git repo takes at least 5 seconds to be ready. It also takes a few seconds to be ready after running any command in a directory with a git repo. All of this happens whether I'm in /mnt/c or ~.
Is there anything I can try to speed up the command line? I don't expect it to be as fast as my MBP where bash runs natively with better specs, but it used to be faster here.
Solution 1:[1]
Normally I'd suspect your profile -- That's the type of thing that moved me from Zsh to Fish a few years ago. But given your comment that:
running a dev app that used to take a few minutes to start now takes 10-30+ minutes
... that's obviously not shell related. However, if WSL1 as a whole is slowing down, then anything you can do to optimize your shell config will certainly help with some of the issues you cite. The delays in cd'ing in repos is likely being aggravated by OMZ. But that's clearly symptomatic here, not the root cause.
For comparison, my Ubuntu 20.04 WSL1 startup time on a 12-year old desktop with magnetic storage is about 6 seconds.
As for troubleshooting the slowdown, I've seen significant performance decreases when access-based antivirus checks are enabled on the WSL1 rootfs. Even on my recent, mid-to-high-end desktop with SSD, I still keep any WSL1 directories in the Exclusions list of the antivirus.
Could there have been a new anti-virus update pushed to your system along with the Windows update you mentioned?
Hopefully you have enough access to add your own anti-virus exclusions. You can typically find your WSL1 rootfs under:
%userprofile%\AppData\Local\Packages\<distropackage>\LocalState\rootfs
The <distropackage> will vary -- Ubuntu typically starts with Canonical....
Note that the anti-virus issue is unique to WSL1. Since its filesystem is "visible" to Windows, it gets scanned. WSL2 virtual drives do not get the same treatment.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
