-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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 Tab Completion Slow on Larger repositories for certain commands #1533
Comments
I can confirm your observation on Windows 10 64-bit with Msys2 mingw64 git version 2.15.1.windows.2:
Most of the time is spent in the
Here's the change: diff --git a/.git-completion.bash b/.git-completion-mod.bash
index a54cc2c..f20945f 100644
--- a/.git-completion.bash
+++ b/.git-completion-mod.bash
@@ -351,12 +351,7 @@ __git_index_files ()
local root="${2-.}" file
__git_ls_files_helper "$root" "$1" |
- while read -r file; do
- case "$file" in
- ?*/*) echo "${file%%/*}" ;;
- *) echo "$file" ;;
- esac
- done | sort | uniq
+ sed -e '/^\//! s#/.*##' | sort | uniq
}
# Lists branches from the local repository. I cannot reproduce the issue in WSL. Maybe the mingw64 version of bash has a performance issue with |
I have prepared a branch with the changes here https://github.com/drizzd/git/tree/completion-optimize-ls-files-filter. Still need to setup an email client to contribute this to the git mailing list. |
@drizzd if you want, I can contribute this for you. Or you can follow @derrickstolee's excellent guide and set up |
FWIW this is very likely... |
I modified the git completion script to include that change and the performance difference is quite significant. I will continue to test out the change and and report further findings. |
Thanks. Please note that the patch has been discussed on the mailing list: https://public-inbox.org/git/[email protected]/ The patch removes a sorting operation, which is wrong. I have a prepared a patch with the fix here: |
@drizzd do you think the updated patch is ready to be cherry-picked into Git for Windows? |
My apologies I am not currently following that mailing list. I appreciate the effort and time looking into this bug report :) |
Only start following it if you like drinking from a fire hose... |
@dscho It's working fine for me on Windows. But who knows if there are more comments on the list. I can make a note for you here when the patch is accepted. |
From the output of ls-files, we remove all but the leftmost path component and then we eliminate duplicates. We do this in a while loop, which is a performance bottleneck when the number of iterations is large (e.g. for 60000 files in linux.git). $ COMP_WORDS=(git status -- ar) COMP_CWORD=3; time _git real 0m11.876s user 0m4.685s sys 0m6.808s Replacing the loop with the cut command improves performance significantly: $ COMP_WORDS=(git status -- ar) COMP_CWORD=3; time _git real 0m1.372s user 0m0.263s sys 0m0.167s The measurements were done with Msys2 bash, which is used by Git for Windows. When filtering the ls-files output we take care not to touch absolute paths. This is redundant, because ls-files will never output absolute paths. Remove the unnecessary operations. The issue was reported here: git-for-windows#1533 Signed-off-by: Clemens Buchacher <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
A new snapshot is building right now and should become available in about half an hour: https://wingit.blob.core.windows.net/files/index.html |
(Please test, the easiest way is to install the portable Git, start its |
Tab completion of `git status -- <partial-path>` [is now a lot faster](git-for-windows/git#1533). Signed-off-by: Johannes Schindelin <[email protected]>
Can y'all please test? |
It is working so far. The performance difference is outstanding, the native commands are faster but it is much harder to tell the difference. and they are well within a second of each other. The double tab list is in the same order so I don't know if there is anything else I can really test. Thanks so much for getting a fix for this @drizzd @dscho |
That is really what I was hoping.
Very good. Thank you for verifying, this is really crucial information to have confidence in this improvement. |
From the output of ls-files, we remove all but the leftmost path component and then we eliminate duplicates. We do this in a while loop, which is a performance bottleneck when the number of iterations is large (e.g. for 60000 files in linux.git). $ COMP_WORDS=(git status -- ar) COMP_CWORD=3; time _git real 0m11.876s user 0m4.685s sys 0m6.808s Replacing the loop with the cut command improves performance significantly: $ COMP_WORDS=(git status -- ar) COMP_CWORD=3; time _git real 0m1.372s user 0m0.263s sys 0m0.167s The measurements were done with Msys2 bash, which is used by Git for Windows. When filtering the ls-files output we take care not to touch absolute paths. This is redundant, because ls-files will never output absolute paths. Remove the unnecessary operations. The issue was reported here: #1533 Signed-off-by: Clemens Buchacher <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
Shell completion (in contrib) that gives list of paths have been optimized somewhat. * cb/bash-completion-ls-files-processing: completion: improve ls-files filter performance This fixes #1533 Signed-off-by: Johannes Schindelin <[email protected]>
From the output of ls-files, we remove all but the leftmost path component and then we eliminate duplicates. We do this in a while loop, which is a performance bottleneck when the number of iterations is large (e.g. for 60000 files in linux.git). $ COMP_WORDS=(git status -- ar) COMP_CWORD=3; time _git real 0m11.876s user 0m4.685s sys 0m6.808s Replacing the loop with the cut command improves performance significantly: $ COMP_WORDS=(git status -- ar) COMP_CWORD=3; time _git real 0m1.372s user 0m0.263s sys 0m0.167s The measurements were done with Msys2 bash, which is used by Git for Windows. When filtering the ls-files output we take care not to touch absolute paths. This is redundant, because ls-files will never output absolute paths. Remove the unnecessary operations. The issue was reported here: #1533 Signed-off-by: Clemens Buchacher <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
Shell completion (in contrib) that gives list of paths have been optimized somewhat. * cb/bash-completion-ls-files-processing: completion: improve ls-files filter performance This fixes #1533 Signed-off-by: Johannes Schindelin <[email protected]>
Setup
Windows 10
defaults?
to the issue you're seeing?
This repository is very large. 5gb in size however this is replicatable with linux kernal repository. I am not using a solid state for the repository.
Details
Git Bash
Minimal, Complete, and Verifiable example
this will help us understand the issue.
Or
Tab completed to
What actually happened instead?
After approximately 10-20 seconds it completes
If the problem was occurring with a specific repository, can you provide the
URL to that repository to help us with testing?
Reproduced using: https://github.com/torvalds/linux
h3. Additional investigation:
Enabling
Creates the following log entries
Running the command
Returns 62913 lines. Attached as ls-files-result.txt
ls-files-result.txt
Git status on freshly checkout respository is the file checkoutStatus.txt
checkoutStatus.txt
Some further investigation shows that running set -x to gain some insight into the completion script shows that we spend a lot of time opening the completion script with
being repeated what seems thousands of times.
The text was updated successfully, but these errors were encountered: