-
-
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
[MSYS2]: Suggestions sometimes don't appear at all #133
Comments
There is an option # blerc
bleopt complete_timeout_auto= |
OK, so the behavior that For the issue that it takes longer time in the battery mode, it is basically the same as I have described in #96 (comment): I try to improve the situation if we can identify the bottleneck, but I cannot ensure that we can solve the problem in slow systems. You have mentioned that your computer is not slow, but that's not my point. I should have written slow systems but not slow computers. No matter how fast your hardware is, some systems---such as WSL2, MSYS2, Cygwin, and Termux---that emulate the Unix behavior on top of different kernel/systems can be slow. If you still think the slow response in MSYS2 in the battery mode is an issue, could you test the same commands in Q1--Q4 in #96 (comment) and #96 (comment)? |
Thanks for the info. I completely understand that MSYS2/Cygwin/Termux can be slow since they're essentially emulating stuff. I ran the commands you mentioned, here are the results:
Won't this turn off the suggestions entirely?
Slight improvement (note that I didn't run the 3 commands in Q3 as they would turned the suggestions off).
|
Thank you!
Oh, you are right. I was forgetting that we want to test the performance of auto-complete in this PR. In these answers, I see there seems to be no bottleneck in the synchronization of background processing and access to the temporary files. I'm not sure how much is the slight improvement in your answer to Q3, but I assume that the highlighting of filenames and variables are not the major factor of the current performance degradation in the battery mode. I have again looked at the animated GIF you provided and noticed that it seems to take time for the auto-complete based on the command history. This might be related to the history size.
$ builtin history | wc
$ wc ~/.bash_history # your history file
|
Yes, I don't notice any difference |
Thanks. Hmm, OK. So the history is small, and the delay is not specific to the history auto-complete.
$ ble-measure -a 50 'ble/util/is-stdin-ready' |
|
OK, this seems to be within the acceptable range. I currently don't have an idea on the other possibility. I will later try to reproduce the problem after I go back home.
|
I use (and love) the Windows Terminal Preview :) But these issues can be reproduced on conhost and mintty too. My .bashrc is here https://github.com/rashil2000/dotfiles/blob/master/bash/.bashrc The MSYS2 kernel version is visible in the GIFs and the bash version is there in the top comment in this thread. Thank you so much for your time so far! |
My bad, it was just a bug of task scheduling that can affect the general environment not specific to MSYS2. I added a fix fea5f5b. Could you check the latest commit by ble.sh uses some clocks for the task scheduling of the background processing. Actually, two different clocks are internally used in the task scheduling, and the times of the two clocks should not be mixed. But, in the scheduling of auto-complete, I have been measuring the time using one clock and scheduled the next processing based on the other clock, which caused the problem. I haven't observed the problem so far in the other environments probably because the inconsistency of two clocks happens rarely, and the problem arises in a race condition. |
Yes! That solved the issue! The suggestions appear almost instantly now. Thank you!! Should I close this? |
Nice! Thank you for checking that the issue has been solved. Then, you can now close the issue. Thank you again for reporting the issue and answering a number of questions! |
Thank you and welcome 😊 On an unrelated note, may I ask why, after the |
To suppress the output from GNU Readline, ble.sh redirects standard streams to temporary files. The end of Do you think there is some situation that one cannot put Edit: If you want to check the redirected output, you may run the following command: $ cat "$_ble_base_run/$$.stdout" |
I haven't come across any problems yet. I'm fine with putting it at the bottom :) I just got to know about this behavior because I was trying to run a little experiment. PowerShell has this really neat feature of displaying how much time it took to initialize and load the shell. I tried to replicate the functionality in bash and zsh (in MSYS2), by putting the following line at the top of the very first initialization file (/etc/profile for bash and /etc/zsh/zshenv for zsh): __shell_start=`/usr/bin/date +%s%3N` and the following line at the end of last files (.bashrc and .zshrc): echo -e "\nLoading personal and system profiles took $(($(date +%s%3N) - __shell_start))ms." Here are the timings (in seconds): plugged-in
battery
(ble.sh seems to add significant overhead to loading time - 2.3 seconds in plugged-in mode and 5.5 seconds in battery mode - but I didn't report this because I think this is due to the MSYS2 emulation as you mentioned - please correct me if I'm wrong 😅) |
FYI, I implemented the above idea (only redirecting the standard error) in commit a30887f, and tested it with different systems. Now the standard output in |
Sorry for the late reply. Actually, after I saw your comment, I have tested the initialization time in my environment and found that the overhead is about one second there. The bottleneck seems to be the cost of fork & exec in the initialization. I wanted to investigate in more details but was busy, so my reply has been delayed. If you are still interested in the delay, you may check the fork speed of your system by the following command: $ while :; do date; done | uniq -c You can terminate the command by pressing C-c several times. The below are the results in my systems. The numbers represent the number of
You may also output the initialization benchmarks (until diff --git a/ble.pp b/ble.pp
index 27989c2..dbc43a1 100644
--- a/ble.pp
+++ b/ble.pp
@@ -1,7 +1,7 @@
#!/bin/bash
#%$> out/ble.sh
#%[release = 0]
-#%[measure_load_time = 0]
+#%[measure_load_time = 1]
#%[debug_keylogger = 1]
#%#----------------------------------------------------------------------------
#%if measure_load_time The example output in my environment is something like this. Normally,
If that is the case, I can look for whether it is possible to reduce the number of forks in the MSYS2 system. |
It looks like the presence of ble.sh decreases how many fork calls can be done in a second (also confirmed in WSL2). |
Thank you! These results are interesting. In your system, there are essentially no differences in speed between Cygwin and MSYS2. Also, it seems that the load time is only a small part of the total overhead of using
This is also observed in Linux. Actually, the footprint (i.e., the memory usage of the process) will directly affect the fork performance. For example, even a single large array affects the speed as follows: # In my Linux, bash-5.0.11 without ble.sh
$ while :; do date; done | uniq -c
810 Sat Sep 18 01:39:19 JST 2021
2201 Sat Sep 18 01:39:20 JST 2021
2086 Sat Sep 18 01:39:21 JST 2021
1849 Sat Sep 18 01:39:22 JST 2021
1718 Sat Sep 18 01:39:23 JST 2021
1648 Sat Sep 18 01:39:24 JST 2021
1587 Sat Sep 18 01:39:25 JST 2021
1558 Sat Sep 18 01:39:26 JST 2021
1406 Sat Sep 18 01:39:27 JST 2021
^C
$ A=({000000..999999}) # <-- create a large array
$ while :; do date; done | uniq -c
96 Sat Sep 18 01:39:41 JST 2021
194 Sat Sep 18 01:39:42 JST 2021
186 Sat Sep 18 01:39:43 JST 2021
188 Sat Sep 18 01:39:44 JST 2021
173 Sat Sep 18 01:39:45 JST 2021
173 Sat Sep 18 01:39:46 JST 2021
169 Sat Sep 18 01:39:47 JST 2021
182 Sat Sep 18 01:39:48 JST 2021
176 Sat Sep 18 01:39:49 JST 2021 |
Oh, that's a very interesting note. Is there any way to benchmark memory usage then (similar to how you did for CPU time)? |
Oh, I had never thought of measuring memory usage, but it should be possible with $ grep RSS /proc/$$/status
VmRSS: 10240 kB This is the summary for my systems.
With |
(both Cygwin and MSYS2 share the same Home folder so history is same) |
ble version: 0.4.0-devel3+92c7b26
Bash version: 5.1.8(1)-release (x86_64-pc-msys)
Hi!
I saw in your comment that MSYS2 support was recently added, so I wanted to report this here.
The issue is that the auto-suggestions are very slow to appear, and sometimes they don't appear at all. 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.
battery
plugged-in
I have noticed that the issue worsens as more and more different applications are open on my laptop.
Is this something that can be rectified?
The text was updated successfully, but these errors were encountered: