-
Notifications
You must be signed in to change notification settings - Fork 2k
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
git path completions are slow #4117
Comments
Which command exactly are you trying? The git completions are rather smart, and e.g. for That pretty much requires calling I'm writing the rest assuming it's about After you've tried to complete any git command (which loads the completions), can you try __fish_git_add_files
echo $CMD_DURATION ? Note that on linux (where git is faster in general IIRC), this will benefit massively from caching, so you might want to invalidate the cache between runs (e.g. the first call might actually take a second, the next one will take 12ms). It is also possible that this just isn't fixable - I've just tested the performance of |
Okay, sorry, of course there's a nicer way to profile this! # Note: The arguments to `complete -C` are weird - they pretty much need to be given in that exact form
fish --profile /tmp/some_file -c 'complete -C"git add "'
sort -nk 2 /tmp/some_file |
FWIW, I was having the same problem on OS X. Using the profiling above, I found the issue was shelling out to I worked-around this be removing the alias support in |
@bennoleslie: Obviously that's a bit slow, but on my system it's essentially not an issue. However, I have 3 aliases. I'm guessing you have a bunch more.
Yes, that'll do it. The thing is to complete aliases like the commands they are aliasing (which isn't ideal - they should be completed like they were given in full, but that requires #1976), we need to somehow map the string that is currently in command position to the command. I have a solution that should be a bit faster (one I'll make a PR later. |
@faho no, I only have 3 (which is why disabling was not a big deal). The number of shell outs doesn't seem to be related to the number of aliases though. I tested this with all my aliases removed. I mentioned on the mailing list a solution would be something along the lines of calling I'm surprised how 62 shell outs can be so quick for you though. I'm interested, if you do:
Do you see 62 executions? Or is calling out to git that much faster on Linux for some reason? (I'd be surprised). |
Thanks for the speedy input. This is what it came back with: |
I had the same idea - that's pretty much what #4118 does 😄.
Yes, 62 executions totalling about 58ms ( @mqudsi, @bennoleslie: Please try #4118. |
@mqudsi FWIW, that profile looks very similar to mine. 982ms total, 858ms resolving 64 aliases. I don't think this is a WSL specific issue. |
@faho that branch exhibits the same delays. |
@mqudsi: That's surprising. Have you started a new shell? If so, can you upload a new profile? |
whoops, I kind of forgot to |
@mqudsi: It's a script-only change, so you don't actually need to |
Yeah, that's much faster. |
Okay. I'll let the PR sit for a week or so to figure out any issues, then I'll merge. @mqudsi: It would still be nice to get a new profile - maybe there's some low-hanging fruit there. |
Here's the latest: |
@faho Yeah, that fixes it. I'm still a bit surprised that my sub-shell takes 80ms, and yours less than 1ms! |
Okay, the good news is that there's no more low-hanging fruit in that path - the only way to get it faster would be to refactor the entire completions script to go like this: function __fish_complete_git
if set -l cmd (__fish_git_command) #hypothetical function that returns the current de-aliased command
switch $cmd
case add
__fish_git_add_files
case checkout
__fish_git_reflog
__fish_git_branches
# and so on....
end
end
end
complete -c git -a '(__fish_complete_git)` which works around much of our completion system (option completion would have to be done manually etc), but avoids checking the command more than once. I don't really want to do that. |
I'm actually not surprised that git is fastest on linux, considering the author.
Note to myself: Dude, your configuration only loads test/completions if the shell is interactive! |
I'm closing this since it seems #4118 is enough. I still have a few more ideas to speed the git completions up, but all of them would make the code uglier, and there doesn't seem to be a great need to do so. |
New fish user, 2.7.1 on MacOS, assuming the fixes mentioned here are in and probably improved upon. Yet, git completions are very slow, exact same problem as OP described ( "The git completions are rather smart" — maybe that's not a good thing? One of the first things I had to do to make it bearable to use was to change
I.e., just the branch name is good enough, I'm not too lazy to type Why is Sorry for the rant/frustration report from the field. Still having problems with git completions and having to fall back to |
I find this rather confusing. First of all, the git prompt is different from the git completions. It can be slow or fast, and the completions can be slow or fast. And by default, the git prompt does two
and
These are pretty much the cheapest possible - the first one is necessary to figure out if we should even do anything else. On my system these take about 5ms each. That's about as long as your If it does anything more, then that's because you've enabled more! The git-prompt has a whole bunch of configuration variables - e.g. Okay, now on to the completions.
Not just these, but a bunch more - see e.g #4673.
Because it mostly just falls back on completing files. E.g.
Sure. Create a file called "git.fish" somewhere in |
@faho, thank you for a balanced response to an unbalanced rant. The prompt mention is indeed not related to completions, that was more to add weight to the suspicion that by default the git machinery tries to do too much. Then again, I simply selected the "Informative Vcs" prompt (which, I'm guessing, uses different defaults) and didn't know to look at FWIW, I don't see bash-completion completing unmodified files. Also, it only searches in the current directory and does not descend into subdirectories, whereas fish completion seems to make a full traversal from the root (where, in my example, I currently have 27487 untracked files I don't really care about). This is not to say that one behavior is wrong and the other is right, but to present a use case where the default behavior is boldly inefficient (over 10s on my machine in this case) and to challenge the design assumptions while suggesting for an easier way to opt out than "write your own git.fish". Yours is 1000+ LoC, of which ~120 is FWIW, this new user is enjoying fish immensely and appreciates the work that went into it. |
Hi, I'm just trying out fish (thanks!) and it's all nice, apart from typing Here is the output with the current master git.fish: some_file.txt - hopefully that might be helpful in finding out what is making it so slow? It looks like a It looks like it is this line of git.fish: fish-shell/share/completions/git.fish Line 755 in 0f4126c
A |
@dracos: Not quite true - going by your output, that is running something before f3f2d2d - which should speed just that case up. Please check your $fish_complete_path for another git.fish.
There's something seriously wrong. Please check |
Thanks for the really quick response! Two separate things:
|
Either you have an absurd number of branches - thousands of them (I'm regularly testing this with 1600 branches), or, more likely, you're not actually running fish from git master, meaning you don't have 2de38ef. That should speed this up by a factor of 4 or so (i.e. reduce the time taken to 25% of what it was). |
That's already included in `__fish_git_ranges`, so we don't need to do it again. Mentioned in #4117.
No, I was only using the master |
I can confirm it is much quicker on the current master of fish, yes. |
just wanted to provide some level setting here. I work with ~40 developers. I have 26 of them set up as remotes on my repo, because over the years it has been prudent to check out the topic branch of 26 coworkers and collaborate with them. We follow a pretty standard process of making a topic branch for each pull request. People tend to not delete their topic braches after merge, because ...why bother? Branches are a teeeeny little file with nothing but a treeish in it.
so I don't think "1600" is anywhere near a valid upper bound for testing. 26 people asking you to comment on their code / help with their work over the course of a single employment is not a lot. I've been using fish for years now and the slowness of tab completion in git repos is so painful that i'm seriously considering uninstalling fish and going back to bash. I keep having to remind myself to use arrow instead of tab then delete and retype the end because otherwise i've got literally about 10 seconds worth of delay every time i accidentally hit it to tab complete file paths. I'm working through debugging it based on the stuff above but a) i've got better things to do b) i had some pretty sweet git integration going in bash and it was never painful. |
Path completions when completing
git
commands under WSL are very slow (the shell hangs when I<tab>
to complete a local path; I'm not sure why since normal path completions autocomplete just fine andgit
commands execute quickly with no apparent issues.Any hints on how I can help debug this issue?
The text was updated successfully, but these errors were encountered: