Skip to content
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

Slow history navigation #457

Open
Raffa064 opened this issue Jun 8, 2024 · 8 comments
Open

Slow history navigation #457

Raffa064 opened this issue Jun 8, 2024 · 8 comments

Comments

@Raffa064
Copy link

Raffa064 commented Jun 8, 2024

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
Copy link
Owner

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
Copy link
Author

Raffa064 commented Jun 9, 2024

It gets slower and slower, from milliseconds to seconds

@akinomyoga
Copy link
Owner

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
Copy link
Owner

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
Copy link

L30Bola commented Jun 26, 2024

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
Copy link
Owner

akinomyoga commented Jun 26, 2024

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. #202 (comment).

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.

@akinomyoga akinomyoga added External Problem/Bug Problems/Bugs of other projects Information Needed and removed External Problem/Bug Problems/Bugs of other projects labels Jul 29, 2024
@akinomyoga
Copy link
Owner

@Raffa064 Have you noticed my questions in #457 (comment)? If you still experience the issue, could you check those questions?

@mattmc3
Copy link

mattmc3 commented Aug 15, 2024

For others running across this issue in the future, one other thing you may want check is your $PROMPT_COMMAND variable.

$ echo $PROMPT_COMMAND
__zoxide_hook; history -a; history -c; history -r

I had cargo-culted this snippet into my .bashrc a long time ago to sync history across sessions. bleopt history_share=1 works much better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants