-
-
Notifications
You must be signed in to change notification settings - Fork 85
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
[WSL2] input delay #96
Comments
Thank you. OK, I have set up WSL2 with Ubuntu 20.04 LTS and could reproduce the small delay even after disabling I'll take a look later, but I'm busy recently so would appreciate it if you could narrow down the bottleneck. Thank you! |
I kind of narrowed it down. It turns out the delay only happens (or at at least is most noticeable) when I type the very first character after starting my terminal session, subsequent keystrokes appear to behave normal. In addition this only happens when I override some settings in the blerc file. Particularly I'm changing the syntax highlight colors, so my blerc file only contains a bunch of calls to |
I'm not sure, but this is possibly related to $ bleopt complete_auto_complete= If it is the delay by # blerc
bleopt complete_auto_delay=300
Ah, OK. |
Oh I see. If ble.sh defers the initialization of faces until it is first required, then that would explain the problem. There are a lot of calls to |
Hi @akinomyoga! I was about to open an issue related to performance in WSL2, but I saw that this is already open. I'm facing issues too. I'll try to elaborate. While auto-complete and auto-suggestions work fine, there's a very perceptible lag on input (delay between typing and characters appearing). I'm on a laptop, so power consumption might be interfering with how snappy the input is. Therefore I've tried to record on both battery-mode and plugged-in mode. Both these have very perceptible lag, but the typing is slightly more responsive in plugged-in mode. I have only 3 lines in my blerc
Note that this lag doesn't appear in WSL2 at all (whether on battery or plugged-in) in zsh, pwsh or vanilla bash. |
@rashil2000 Thank you for the information! First, I need to note that In your case, I'm not sure if there is any bottleneck that significantly worsens the performance, or just the entire processing takes a long time in the battery mode, but I might do something in the former case. I implemented
$ ble-measure -a 50 'ble/util/msleep 10
$ bleopt complete_auto_complete=
$ bleopt complete_menu_filter=
$ bleopt complete_auto_menu=
$ bleopt highlight_filename=
$ bleopt highlight_variable= |
I have a gaming laptop [Specs: i7-8750H, 6 cores (12 threads), 16GB RAM, GTX 1060 GB graphics]. I don't think the system is a slow one. In any case, to completely eliminate any possibility of doubt, I conducted an elaborate experiment. I created 2 virtual machines, both running Ubuntu:
In both these VMs,
No effect
Very slight improvement |
Thanks for the information and answers. From these answers, it seems that the delay is caused by somewhere not related to the auto-complete or syntax-highlighting based on the filenames. Another possibility that causes the delay is the access to
$ ble-measure -a 5 'ble/util/assign a "echo $((b++))"' I have also tested with WSL2 in my environment. It seems that I also have a very small delay with WSL2 (though I'm not sure if this is the same issue as the one that you observe). I tried to figure out the cause of the small delay, but I found some strange behavior: While I observe the delay when I open the WLS2 through the "Ubuntu 20.04 LTS" icon in the Windows start menu, it seems that I don't have the delay if I connect to the WSL2 through The terminal that opens up by the start menu icon seems to be actually the command prompt (at least the property window which can be opened from the shortcut menu of the window icon is that of the command prompt). Maybe the delay is related to the terminal or some interface of the connection between the WSL2 subsystem and the Windows subsystem.
|
I start it using the
I don't have Cygwin set up on my machine, but I could install It's definitely an issue with the
They are particularly useful for detecting if you're on WSL for generic linux apps/scripts. When using |
Needless to say, the disparity between Do you think I should report this in the official WSL repo (citing this issue as source)? |
OK, thank you for your information. As you have experienced the zero delay with
Currently, the issue is not so clear, and I think they are so busy that they don't have time to investigate such an obscure issue that "some specific application is slow in some specific situation". I'd think the issue would be just ignored at best (unless there are reports from many different people on the same issue with ble.sh which is not likely). We may report it only after we have identified what specific operation causes the delay of |
Okay, I understand that. Thank you for your help so far and the |
Okay, I somehow missed this, but I changed my default shell in WSL2 to zsh, and I can observe the same input delay in zsh, when launched through the Though I could observe the difference only in battery mode, there's definitely something wrong with the |
Hmm, that's interesting. In spite of that, Readline still doesn't have the delay? |
No, both vanilla bash (Readline) and surprisingly, pwsh, respond exactly the same irrespective of whether they were started through |
I think I now found the reason for the delay in my environment. When we log into the WSL2 system through $ (IFS=:; printf '%s\n' $PATH)
/home/murase/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/mnt/c/Program Files (x86)/Intel/iCLS Client/
/mnt/c/Program Files/Intel/iCLS Client/
/mnt/c/WINDOWS/system32
/mnt/c/WINDOWS
/mnt/c/WINDOWS/System32/Wbem
/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/
/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL
/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/DAL
/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/IPT
/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/IPT
/mnt/c/Program Files (x86)/Symantec/VIP Access Client/
/mnt/c/Program Files/Intel/WiFi/bin/
/mnt/c/Program Files/Common Files/Intel/WirelessCommon/
/mnt/c/WINDOWS/System32/OpenSSH/
/mnt/c/Program Files/nodejs/
/mnt/c/Users/murase/AppData/Local/Microsoft/WindowsApps
/mnt/c/Users/murase/AppData/Roaming/npm
/mnt/c/Users/murase/AppData/Local/GitHubDesktop/bin
/mnt/c/Users/murase/AppData/Local/Programs/Microsoft VS Code/bin
/snap/bin On the other hand, when we log into WSL2 through $ (IFS=:; printf '%s\n' $PATH)
/home/murase/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/snap/bin It seems like the access to the Windows directories is very slow. For example, you can list the command names available in # From ssh
$ time compgen -c | wc
5102 5102 91918
real 0m0.088s
user 0m0.058s
sys 0m0.038s
# From wsl
$ time compgen -c | wc
10017 10019 173085
real 0m30.123s
user 0m0.546s
sys 0m4.682s It's 300 times slower (30.123/0.088 = 342) with |
I'm not sure if we can work around this problem. If you are fine with removing all the Windows paths from ble/path#remove-glob PATH '/mnt/*' |
Oh, so the input delay is because the shell is trying to complete command names (which are slower to lookup in Your fix of trimming the PATH to exclude Windows mounts solves the issue, even in zsh. |
You can also create a file called [interop]
appendWindowsPath = false More info can be found in WSL's docs here. |
Oh, thank you for the information! |
I have probably a hard to work environment. I am using WSL2 with sbp (simple bash prompt) inside of genie. I also have many hooks inside my Removing the windows mounts from PATH and adding aliases for the two windows programs I use, already improved the performance by a lot. I am still facing around a second of delay when doing Ctrl+C with an empty prompt. How can I assist to fix that? |
There are various possibilities, so I don't know what actually causes the problem. You could actually turn off/on these settings one by one to identify what is the bottleneck.
It depends on the exact setup in your script, but a typical setting will cause the reloading of the entire history. If that is the case, it will causes also the initialization of history data used by
bash-preexec also uses a fragile hack using DEBUG trap. Again, ble.sh provides proper supports for
I'm not sure what those projects do in
Have you checked if that delay is only present with |
I didn't expect that you magically know the solution but could give me some general hints for what to look at.
I tried a few things and it definitely comes from my
that works and improves things slightly. Only downside I found is that it does not work when aborting a command with Ctrl+C and the reloading history prompt is a bit more annoying than silently doing it in the background.
Sounds awesome but that will be a bit more tricky for me since I am using bash-preexec embedded into wezterm. I think I need to add proper support for blesh into it but that shouldn't be a problem.
direnv changes enviroment variables based on config files. That could be tricky to move to hooks. zoxide records PWD changes and provides quick jumps to them. That can certainly be moved to the CHPWD hook.
I have a very slight delay without blesh and a bigger one with blesh. It improves by a lot when I clear my Thanks for all the pointers. I hope when I cleaned up my BASH_PROMPT everything runs a bit smoother. If not I reach out for help again. |
Thanks for the report. This is stuff that I can easily fix. I have fixed it 8dbefe0.
OK, but I guess there are still multiple plugins that hook to
I sometimes think that maybe I could submit to the upstream
Thank you for the information. Then, I guess some interaction between ble.sh and the other plugins cause the delay. Thank you. |
@SuperSandro2000 I have created a patch to Then, we actually don't need to modify the codes that use |
Now integration with bash-preexec implemented@SuperSandro2000 I have implemented the integration with Actually, I want several stable public API of The original In this integration, the Maybe @NoahGorny, @cornfeedhobo, and @gaelicWizard might also be interested in it. In |
I think most of the delay came from
wezterm needed to be modified anyway since it always loads bash-preexec and vendors it. |
Hmm, didn't it work without the modification? In the above integration, I intended to make I have now checked
Edit: I now tried It is unrelated to the wezterm shell-integration, but I faced another problem with |
So far it seems to work but I think it would be easier if I keep the patches for atuin and wezterm to remove a whole bunch of fragile bash code. I could imagine that the removal functions break which would be a bit of a pain to debug.
I was referring that the patch is still required when I want to use the hooks without the preexec compatibility stuff.
I must admit I wasn't using wezterm terminal in the last weeks but only the shell functions. I intent to use it again in the future especially because Windows Terminal breaks tmux panes and splits. |
Ah, I see your point. Then let's keep the special treatment in Actually, what I have implemented in the integration is the switching between the DEBUG trap and the blehook in either direction. This is needed for
I have fixed the issue of DECSTBM in 4b1601d. Digression: Some detailed story of DECSTBMThis above problem is related to the supported terminal sequence for clearing I recognize another layout issue with *Edit: This was easier than I though. I fixed it in e199bee. In order to use it with # blerc
bleopt prompt_command_changes_layout=1 |
I need to do it from time to time because nix-shell is still not working like it should. I will write you another comment into the other thread. |
OK, thank you for the information! Please feel free to open a thread. |
Hello. On the problem with |
@refparo @mgastonportillo @heathprovost I've been believing that the issue of the slow filesystem should be fixed in the upstream WSL2 system, but it doesn't seem to be fixed there. I decided to accept a workaround contributed by @musou1500. Now, in the |
Thank you a lot! But actually, I believe that even on native Linux, if the PATH contains a FUSE-based filesystem, there would likely be a performance issue as well. It would be even better if a customizable option is added. |
ble version: 0.4.0-devel3+0506df2
Bash version: 5.0.17(1)-release, x86_64-pc-linux-gnu
Hi. This project is great.
Basically I'm having performance issues, there is a perceptible delay between my key strokes and the letter appearing on the screen. Is this something that should be expected ? I'm currently under Ubuntu 20.04 on WSL2. I'm coming from zsh and I would really love to use bash, but syntax-hightlight and autocomplete features like the ones you provide are a must have. However performance issues are a deal breaker.
I see there are other open issues related to performance, but I saw they were more specifically related to autocomplete or some other features. Please let me know if I should close this and continue the discussion in those open issues.
Summary
(Edited by @akinomyoga)
Here I summarize the discussions made here. There can be various causes that slows down the response in WSL2. Depending on the actual bottleneck in your environment, maybe you can take the following workarounds.
Remove slow Windows filesystems on
/mnt
fromPATH
It is known that the Windows filesystems mounted on
/mnt
is very slow microsoft/WSL#4197. WhenPATH
contains directories under/mnt
, the completion becomes slow. One solution is to remove/mnt/*
from the environment variablePATH
:Another solution is to configure
wsl
so that it doesn't include Windows paths in the environment variable on the startup of the shell:Integration with bash-preexec to remove the overhead of DEBUG trap
This has been solved by introducing a proper support for the integration of ble.sh and bash-preexec. When
bash-preexec
is loaded, ble.sh automatically detects it and properly communicate with the loadedbash-preexec
. Please just updateble.sh
to the latestmaster
. See also #96 (comment).Disable auto-complete
If the above settings does not work, maybe you can turn off auto-complete or set a delay for auto-complete.
The text was updated successfully, but these errors were encountered: