bash-git-prompt icon indicating copy to clipboard operation
bash-git-prompt copied to clipboard

my prompt is slow with bash-git-prompt

Open retif opened this issue 5 years ago • 10 comments

I am using bash-git-prompt: stable 2.7.1 and it is slow, but only when i open directory with git repository in it. The lag is around 2 seconds after any command, for example 'ls'. How to debug what causes this lag? Not every repository affected, but some does.

retif avatar Jan 06 '20 17:01 retif

I'm seeing this behavior too. I've got GIT_PROMPT_ONLY_IN_REPO=1 and the terminal is still slow in all directories.

This is an intermittent problem and restarting my computer (not just restarting terminal) resolves it.

mute-civilian avatar Jan 10 '20 17:01 mute-civilian

Seems like it becomes slower if there is a lot of files in the git folder, or if the .git metadata is big. I'm running this in WSL2, and on a windows drive (that is mapped into the Linux VM) it can take 5-10 seconds to return to the prompt after the file listing. Doing the same with an identical copy of the git folder in the Linux filesystem takes 1-2 seconds, still slow.

Makes me think that every time the prompt renders, it must use massive disk IO. Not sure if that could be improved, but feels like it should be improvable, at least with some caching.

jishi avatar Jan 14 '20 12:01 jishi

I have this issue as well. In particular on a repo with a large amount of files (~80K) over nfs, it can take more than 90 seconds just to return to the prompt after any command.

I've tried setting various options to ignore untracked files and using update-index but I don't really see any improvement.

chbfg avatar Feb 06 '20 23:02 chbfg

Have you tried these suggestions in the README

"If you have a repository with many untracked files, the git prompt can become very slow. You can disable the display of untracked files on a per repository basis by setting GIT_PROMPT_SHOW_UNTRACKED_FILES=no in your .bash-git-rc in the repository or by disabling it globally in your .bashrc

If you have a repository with a deep submodule hierarchy, this can also affect performance. You can disable searching for changes in submodules on a per repository basis by setting GIT_PROMPT_IGNORE_SUBMODULES=1 in your .bash-git-rc"

Regards ian

ijf8090 avatar Feb 24 '20 04:02 ijf8090

I'm seeing this behavior too.

HendrikFagel avatar Apr 15 '20 11:04 HendrikFagel

Same problem here under WSL2

matheusmb avatar Apr 21 '20 19:04 matheusmb

Same under Fedora.

valleedelisle avatar Oct 07 '20 03:10 valleedelisle

When this happens in WSL2, the most likely cause seems to be the filesystem performance in mounted directories. In /mnt, the Windows filesystem is accessed from within a Linux VM, and the process is dead slow, as explained here. Even git status takes forever in some repos. And if git status is slow, bash-git-prompt will be, too.

hashchange avatar Dec 19 '20 17:12 hashchange

I was having a similar issue with a git-lfs repo with only a few hundred files, albeit large ones. Manually running git status solved the problem (not sure how often that needs to be done).

taranu avatar May 20 '21 21:05 taranu

https://github.com/magicmonty/bash-git-prompt/pull/491 is merged now. @retif Could you confirm that this solves your issue?

guenhter avatar Oct 10 '22 07:10 guenhter