-
Notifications
You must be signed in to change notification settings - Fork 423
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
Slowness with LP_ENABLE_GIT=1
#696
Comments
There have not been many changes to the Git features since v2.0, but if you could, could you please test on the latest Without more details, this won't be possible to debug. Can you run some timings, and post their output? time git --help >/dev/null
time _lp_vcs_details_color
time _lp_git_active
time _lp_git_branch
time _lp_git_commit_id
time _lp_git_head_status
time _lp_git_commits_off_remote
time _lp_git_unstaged_lines For comparison, here are some of my values:
My guess is that your filesystem is slow, and either the |
I'm testing with the latest commit 0447efe. The filesystem shouldn't be particularly slow as it's a decent SSD.
The culprit seems to be I tried to investigate a bit and I noticed that
If I define it as |
Ah, then I bet I know what the problem is. Similar to in #690, do you have the function type command_not_found_handle If so, it probably does some sort of a lookup to see if it is a valid command in some remote package, which is what is taking so long. There isn't a good reason for Liquidprompt to keep the function undefined, so if that is the problem, I can add empty definitions for all not implemented data functions (like you did) which should fix the issue. |
Oh my God you are a Bash wizard! 😄
I already patched my local version of Liquidprompt. If you don't want to add this empty function (and maybe others?) it's fine for me, I can keep patching my local version. Apparently nobody else complained about this somehow. |
I'm not sure why that is, but others are likely to complain in the future. It also just makes sense from a speed perspective even when $ test() {
for ((i = 0; i < 10000; i++)); do
test_fuction_not_real 2>/dev/null
done
}
$ time test
real 0m7.998s
user 0m2.840s
sys 0m5.357s
$ test_fuction_not_real() { :; }
$ time test
real 0m0.169s
user 0m0.128s
sys 0m0.038s So I see no good reason not to add empty functions, and lots of good ones to do it. So thanks for teaching me something new 😄 I'll both patch this on |
Without these functions defined, each prompt invocation would force the shell to check if the command was valid, and generate an error message if it was not. We know that it won't be, so we can shortcut that by setting it as such. More importantly, if the Bash function command_not_found_handle() is set, it will be executed for each function that is not set. For Git or HG, this is only one. But for SVN, it is enough to lock the prompt for a while. Fixes #696
Shell: 5.1.8(1)-release
Liquidprompt version: v2.0.3
Operating system:
Steps to Reproduce
LP_ENABLE_GIT=1
set in.config/liquidpromptrc
cd
to a Git repositoryExpected Behavior
Nothing special, just the prompt promptly appearing.
Current Behavior
The prompt takes around 1 second to display.
For instance, if I
cd ~/.liquidprompt
(which is a Git repo) and just press Enter in the terminal, each of the following lines takes approximately 1 second to appear:Possible Solution
My suspicion is that some of the
_lp_git_*
functions take a long time to execute, but I haven't been able to figure out which.The text was updated successfully, but these errors were encountered: