-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WSL 2 session takes 40 seconds just to get to prompt #4737
Comments
u Better to use a VM with linux instead wsl2. It's the same thing |
Same issue here using Windows Terminal version 0.7.3291.0 |
@mchassy and @stefankummer thank you both for the videos! To help troubleshoot this, could you both please look at doing these steps:
|
Hi Craig ... done for the week (I'm in the UK), but I will do that on Monday. |
I'm hitting similar issues, originally thought it may have been related to #4498 My symptoms are similar - 30s+ to get a new prompt. I've reset my Ubuntu 18.04 environment several times to troubleshoot. In my case, I've also observed some interesting behavior based on how I launch into wsl, starting from a new Windows PowerShell instance:
The last case seems to rule out it being "my fault" for having an excessively slow bash profile, and is an acceptable workaround for the time being dmesg logs in case it helps: https://gist.github.com/noelbundick/36d20fdf21b01838ce5a97df10c39dc9 Edit: I'm an Insiders slacker and am on |
Hi Craig, dmesg here : https://gist.github.com/stefankummer/0b8645e2fc3ae6d36271a27d32622cf6 I installed a new distro (Debian) and the problem does not arise. Regards |
If I do a fresh install ubuntu starts normally. After |
I can confirm this, after commenting out the checks for pulseaudio and x11, the startuptime is back to normal. |
I can also confirm. Noticed I was having long hanging times after running my update script. |
@nhuse9 Yes. Refer to your approach. The startup time is back to normal. I inserted
The reason may be related to the network. Commands executed cannot return results in a timely manner. 👉 Updated: If I turn off Windows Firewall, The startup time is back to normal. 😅 Further testing (Runs on WSL): # WSL_HOST=192.168.208.1
awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2>/dev/null
# set DISPLAY if there is an X11 server running (Key commend)
$ time env DISPLAY=192.168.208.1:0 xvinfo
# set up audio if pulse server is reachable only via tcp (Key commend)
$ time env PULSE_SERVER=tcp:192.168.208.1 pactl info Result: (using $WSL_HOST and my Lan IP) # WSL_HOST=192.168.208.1
# set DISPLAY if there is an X11 server running (Key commend)
$ time env DISPLAY=192.168.208.1:0 xvinfo
xvinfo: Unable to open display 192.168.208.1:0
real 0m32.391s
user 0m0.001s
sys 0m0.000s
$ time env DISPLAY=<lan ip>:0 xvinfo
xvinfo: Unable to open display <lan ip>:0
real 0m3.147s
user 0m0.002s
sys 0m0.000s
# set up audio if pulse server is reachable only via tcp (Key commend)
$ time env PULSE_SERVER=tcp:192.168.208.1 pactl info
Connection failure: Connection refused
real 0m5.010s
user 0m0.000s
sys 0m0.003s
$ time env PULSE_SERVER=tcp:<lan ip> pactl info
Connection failure: Connection refused
real 0m3.138s
user 0m0.003s
sys 0m0.000s And (using 127.0.0.1) $ time env DISPLAY=127.0.0.1:0 xvinfo
xvinfo: Unable to open display 127.0.0.1:0
real 0m0.003s
user 0m0.002s
sys 0m0.000s
$ time env PULSE_SERVER=tcp:127.0.0.1 pactl info
Connection failure: Connection refused
real 0m0.004s
user 0m0.003s
sys 0m0.000s env: # Microsoft Windows [版本 10.0.19033.1]
# WSL version 2 - Ubuntu 18.04.3 LTS
$ xvinfo -version
xvinfo 1.1.3
$ pactl --version
pactl 11.1
Compiled with libpulse 11.1.0
Linked with libpulse 11.1.0 |
It's because of the network check, I think. [ 0.570791] Adding 2097152k swap on /swap/file. Priority:-2 extents:1 across:2097152k |
I had the same issues, and disabling the firewall removed the issue. Editing /etc/profile.d/wsl-integration.sh, like the image, solved the issues without disabling the firewall. |
I can not access the URL “https://i.imgur.com/hNGrCnF.png”. Could you please copy the content of your "/etc/profile.d/wsl-integration.sh" after modified? |
@rsletta: I followed your advice and commented out the same sections as you did. I even commented out setting |
@craigloewen-msft: Might someone from the team have time to shed some light onto this? |
The "wsl-integration.sh" file was added to WSL2 with the last update to "wslu" to detect if an X11Server or Pulseaudio is running. Here is the bugreport about WSL2 "not" checking for it. Now the question still is whats causing the delay for the prompt to appear when the system is running this checks. |
Thanks @M-Kub. So ...
|
Actually, I just saw that the session tool I'm using (Xmobaterm) give you the IP of the Xserver. This kind of script should not be running every time you run a session, rather it could be run at setup with the possibility to run it again as necessary. |
Yep this seems related to Xserver. https://twitter.com/rsletta/status/1203957912072273921?s=21 |
Ok ... I am closing the issue.
Not the most elegant solution, but I shouldn't have to modify it until we get to WSL 3 ;-) |
This will be fixed soon in the wslu package: https://bugs.launchpad.net/ubuntu/+source/wslu/+bug/1855520 |
The change causing the long delay on WSL2 has been reverted in Ubuntu yesterday thus it can be fixed now with |
Upgrading the The solution as of today is to simply run:
EDIT: oops, too late 😄 |
I'm still getting super slow times. I did the apt update and apt upgrade, rebooted, but nothing seems to work. My Windows 10 Home Single Language is at build 2004 and after I enabled version 2, it got extremely slow. |
While this is tangentially related, the issue for me was ohmyzsh. Uninstalling ohmyzsh fixed the startup time and the prompt return time. Make sure to test your slow times using pure bash or zsh first to see if this is the root problem. I found there was no need to comment out the Xserver and audio portion on EDIT: Slowness is back again. |
Hello guys I found a possible reason for the problem, in my case I have installed NVM (Node Version Manager) in WSL and when I comment the following lines in .zshrc
wsl starts instantly To continue using NVM I found a possible solution here: |
I experienced slow startups again. Commented out my NVM path like you, and got instant startup. Seems like that's the culprit in my setup too. |
For me the key was allow all of my x11 server (vcxsrv) apps through the defender firewall. Massive speedup. |
NVM was the culprit for me. Commenting out the lines you mentioned @rsletta solved my issue
|
The problem for me is the network connection due to "pactl info". I found that by opening another Ubuntu shell and "ps -axf". This problem never existed before I did a "apt dist-upgrade". I avoid the problem by simply "cat /dev/null > /usr/share/wslu/wsl-integration.sh" to set it empty, since I don't see how it can be useful to me. And I set the DISPLAY and PULSE_SERVER in my profile file:
My X apps and music apps run fine. |
commenting the NVM in .bashrc starts my wsl instantly as the @fahds has mentioned |
I found that it will be very slow after I run a X server. If I run it as |
I can confirm that this solved the slowness I just commented the NVM |
Thank you @fabioods! Only commenting out nvm from my .bashrc helped. |
I too have had to start running mc that way. I didn't have to change the firewall (I tested opening firewall for ping, but it didn't help, so deactivated again). |
WSL 2 is a nightmare, I wasted many hours debugging and I thought that my bash script had trouble with linode API call which took more than a minute to call one API. In addition of that, WSL 2 did not display any of my beautiful spinning progress bar in terminal!. I tested the linode online API and I can confirm there was no issue with the API call. Then I tried the script on ubuntu virtualbox, the script ran very fast, with my beutiful spinning progress bar (that did not even show up in WSL2). Maybe WSL 2 is not suitable for bash script more than 15k lines which I tested this. Problem solved using multipass for ubuntu. I had to apologize to the linode team for getting mad with them because I thought there was a problem with their API. |
After trying all of the suggestions in this thread (that comes up as the first result for most of my Google queries regarding WSL2 slowness), I finally found the culprit on my system to be Neofetch; starting any user shell would take upwards of a minute. Commenting out the following lines in
|
i dont have NVM Still having slowness at startup And my windows explorer starts slows too because it tries to resolve shell $wsl/ directories |
In my case, as soon as I remove the |
changing |
For me it was commenting this line:
Inside: In case this doesn't work out for you, go in that file and start commenting things you installed to find the culprit. |
Worked for me too... |
For me, Microsoft Terminal take a while to open but once it open, next few time opening a split window or new tab of WSL works fine. After a while if I try to open split it takes while as if the observer in the beginning. But while using a Wezterm I do not observe such issue, first launch of wsl after fresh reboot is quick, and delayed new tab or split windows are faster as well. looks like ldconfig is the issue, [ 3.198913] EXT4-fs (sdc): mounted filesystem with ordered data mode. Opts: discard,errors=remount-ro,data=ordered. Quota mode: none.
[ 12.934813] /sbin/ldconfig:
[ 12.934815] /usr/lib/wsl/lib/libcuda.so.1 is not a symbolic link |
It is still slow on startup, each time when I spend some time in Windows and then start working on Linux, I forget how much faster it is than Windows. Because with WSL 2 Windows has spin up a virtual machine, and virtual machine started at boot time, I don't see any way WSL developers can decrease the boot time of WSL 2. They tried something really difficult with translating kernel calls from Linux with WSL 1, but it feels like it's abandoned, some posts mention that WSL 1 is not deprecated, but to be honest I never used it since WSL 2 came out just purely because it creates some uncomfortable edge case, so whatever solution you have most likely it will have a trade off that you will have to stick to. Maybe now with the power of AI, they will revisit the WSL 1 project? |
Can anyone point to a good (good=WORKING) solution for this? |
@dhruvinsh Interesting! Did you find any fix? Can you please expand upon how you identified ldconfig as the culprit? I'm also having the issue with WSL2 being slow to spawn new terminal instances (often). |
I simply gave up. I switched to wezterm and it works fine. Launch time is sub second (every time). I do from time to time use he windows terminal and I do have the same lag, sometimes it takes 10 seconds to spawn a window/pane for wsl. There is something different between how wezterm spawn the wsl vs Microsoft terminal. |
@geerteltink great job. I've tried to do the same, but there's nothing on my |
This was the culprit for me too! I believe that it started after installing one of the minor Windows updates. Interestingly, another symptom which may or may not be related is an overall slow DNS resolution when I open a URL in a browser for the first time. |
I too had issues caused by NVM. I'm not very knowledgeable at all about NVM – is this a bug in NVM or why does it cause such a bad effect? Or is it a WSL bug that makes NVM freak out? |
A nice reference to get a working solution might be nice .... |
This worked for me! Thank you! |
This solved it for me, went from over 10s to load to 0s. This thread is so important. |
Windows build number:
Version 2004 (OS Build 19035.1)
withUbuntu 18.04 WSL
What I'm doing and what's happening: open WSL 2 session using MobaXterm (same result when using bash.exe)
What's wrong / what should be happening instead: Using WSL 1, the session took a second or two to open. Now with WSL2, it take 40 seconds. I am attaching a screen recording which is about as exciting as watching paint dry.
MobaXterm 2019-12-06 13-57-23.mp4.zip
The text was updated successfully, but these errors were encountered: