$ time __git_ps1
((v2.6.33.4))
real 0m1.467s
user 0m0.864s
sys 0m0.564s
It's making my prompt unusable; on the other hand, though, it's too useful a feature to give up lightly. Any idea why it runs so slow and what I can do about it?
Setup details:
$ uname -a
Linux martin-laptop 2.6.35-22-generic #35-Ubuntu SMP Sat Oct 16 20:36:48 UTC 2010 i686 GNU/Linux
$ git --version
git version 1.7.1
$ du -sh .
876M .
I suspect something with my machine since on my coworker's box, in the kernel tree I cloned from, the same command returns instantly
$ time __git_ps1
((v2.6.33.4))
real 0m0.039s
user 0m0.008s
sys 0m0.016s
adding hdparm output:
mine
$ sudo hdparm -tT /dev/sda4
/dev/sda4:
Timing cached reads: 1542 MB in 2.00 seconds = 772.35 MB/sec
Timing buffered disk reads: 110 MB in 3.02 seconds = 36.42 MB/sec
coworker's
$ sudo hdparm -Tt /dev/sda6
/dev/sda6:
Timing cached reads: 1850 MB in 2.00 seconds = 926.03 MB/sec
Timing buffered disk reads: 210 MB in 3.02 seconds = 69.53 MB/sec
other differences: coworker is running git 1.6.5, i'm running 1.7.1
It turned out to be a combination of two things:
I was using
export GIT_PS1_SHOWDIRTYSTATE=true
export GIT_PS1_SHOWUNTRACKEDFILES=true
by default. which proved to be unusable on a tree the size of the kernel. Removing these options removes a bit of nice functionality from __git_ps1, but at least it returns instantly now. (Useful lesson - try out stuff from a freshly created user account before anything else.)
Also, the hard disk on my work machine is just plain slow, so that wasn't a git problem per se; it's just the first time it really obtruded itself upon my notice.
to know where exactly this takes time you can do :
bash -x
then
__git_ps1
Mine was taking time for
++ git ls-files --others --exclude-standard
it was listing all the files of my gitted home drectory. even on a fast ssd, it took quite a long time.
To get a full log, you do from a shell
zsh -x 2> zshdebug.log
then you exit that subshell, the debug info is in the zshdebug.log
file
To fix this just add this in your .bashrc
export GIT_PS1_SHOWDIRTYSTATE=
export GIT_PS1_SHOWUNTRACKEDFILES=
Will disable some files look-ups.
Does the repo have submodules? See the remark regarding "git status
is now very slow" (with submodules) in this post, due to a change introduced in 1.7.0:
The fix/work-around is to pass "--ignore-submodules
" to "git status
", as noted in the update below the section: "Update: Thanks to VonC, who points out in the comments below that in git 1.7.2 there is now a “–ignore-submodules” option to git status which can restore the old behaviour and also provides the useful option that only changed files (not untracked files) cause the submodule to be shown as dirty."
could you try my version of git PS1 is it faster or equally slow ?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With