akinomyoga / ble.sh

Bash Line Editor―a line editor written in pure Bash with syntax highlighting, auto suggestions, vim modes, etc. for Bash interactive sessions.
BSD 3-Clause "New" or "Revised" License
2.33k stars 77 forks source link

Slow history navigation #457

Open Raffa064 opened 3 weeks ago

Raffa064 commented 3 weeks ago

ble version: 0.4.0-devel4+365101c Bash version: 5.2.26(1)-release

When do I navigate from last commands (with arrow keys) it is very slow.

akinomyoga commented 3 weeks ago

What is your environment? Could you provide the output of the following command?

$ ble/widget/display-shell-version

How slow is it? For example, does it take about 100 milliseconds, a second, a minute, or more?

Raffa064 commented 3 weeks ago

It gets slower and slower, from milliseconds to seconds

akinomyoga commented 3 weeks ago

Q1: What is the result of the following command in a ble.sh session?

$ ble/widget/display-shell-version

It gets slower and slower, from milliseconds to seconds

Q3: Thanks. Is that reset for each command or each terminal session? Or does it persist among different terminal sessions?

Q4: What is the size of your command history? Could you provide the result of the following command?

$ history 1

Q5: Does the problem reproduce in a Bash session started with the following command?

$ HISTFILE=~/a.tmp bash    # <- start a child bash session
$ echo hello
$ echo world      # <-- run a several commands
$ <-- check the behavior
$ exit     # <-- after checking you can exit the child session
$ rm ~/a.tmp    # <-- remove the history file for testing
akinomyoga commented 3 weeks ago

I think you can get a hint by running the profiler of ble.sh. Could you collect the information by the following procedure?

$ ble/debug/profiler/start test    # <-- start profiling
$     # <-- try to navigate through the command history
$ ble/debug/profiler/end    # <-- end profiling and analyze the result

The files named test.line.txt and test.func.txt would be produced. Could you attach those files?

L30Bola commented 1 week ago

I've just started testing ble.sh and I'm getting some performance issues as well. I have a (probably bloated) fairly big bashrc. After I added the ble.sh init, everytime I hit enter, I can see, although real quick, a "loading history..." prompt.

Anyway, here is the result of the above commands (although you asked for a different person, sorry to hijack):

[godoy@rabble-rouser 10:25:10 ~]:$ ble/widget/display-shell-version
GNU bash, version 5.2.26(1)-release (x86_64-pc-linux-gnu) [Arch Linux]
ble.sh, version 0.4.0-devel4+79beebd (noarch) [git 2.45.2, GNU Make 4.4.1, GNU Awk 5.3.0, API 4.0, PMA Avon 8-g1, (GNU MPFR 4.2.1, GNU MP 6.3.0)]
bash-completion, version 2.14.0 (hash:480ffcc6a751e55621ec526eb5dea7a0d86d9e72, 17877 bytes) (noarch)
locale: LC_COLLATE=en_US.UTF-8 LANG=en_US.UTF-8 LC_ADDRESS=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 LC_IDENTIFICATION=en_US.UTF-8 LC_MEASUREMENT=pt_BR.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_MONETARY=pt_BR.UTF-8 LC_NAME=en_US.UTF-8 LC_NUMERIC=en_US.UTF-8 LC_PAPER=pt_BR.UTF-8 LC_TELEPHONE=en_US.UTF-8 LC_TIME=en_US.UTF-8
terminal: TERM=xterm-256color wcwidth=15.0-west/15.1-2+ri, unknown:- (61;7603;1)

After I ran the profiler, I also received this error:

gawk: fatal: cannot open file `/home/godoy/test.xtrace' for reading: No such file or directory

Here is the profiler files: test.func.txt test.line.txt

Oh, just saw that there's another issue which is more like my problem: #447

akinomyoga commented 1 week ago

After I added the ble.sh init, everytime I hit enter, I can see, although real quick, a "loading history..." prompt.

https://github.com/L30Bola/dotfiles/blob/d34af2884bbe59f9be4c8279e79dae13f5945e0f/bashrc#L567

history -r causes a re-loading of the entire history in ble.sh. When ble.sh is activated, you can instead set the config bleopt history_share=1 in ~/.blerc. See e.g. https://github.com/akinomyoga/ble.sh/issues/202#issuecomment-1170791400.

By the way, even for the normal Bash without ble.sh, this should be history -a; history -c; history -r. If you don't clear the history and just load the history from the file using history -r, the actual history size will be multiplied every time you run a command.