4

Ever since I installed GitBash on my computer, the prompt has been very unresponsive. I think I have lowered the culprit down to the command __git_ps1.

The timings for this command are as follows, along with the output:

$ time __git_ps1
+ __git_ps1
+ local pcmode=no
+ local detached=no
+ local 'ps1pc_start=\u@\h:\w '
+ local 'ps1pc_end=\$ '
+ local 'printf_format= (%s)'
+ case "$#" in
+ printf_format=' (%s)'
+ local ps1_expanded=yes
+ '[' -z '' ']'
+ '[' -z '3.1.20(4)-release' ']'
+ shopt -q promptvars
+ local repo_info rev_parse_exit_code
++ git rev-parse --git-dir --is-inside-git-dir --is-bare-repository --is-inside-
work-tree --short HEAD
+ repo_info=
+ rev_parse_exit_code=128
+ '[' -z '' ']'
+ '[' no = yes ']'
+ return

real    0m0.541s
user    0m0.000s
sys     0m0.358s

$PS1 is equal to \[\033]0;$MSYSTEM:${PWD//[^[:ascii:]]/?}\007\]\n\[\033[32m\]\u@\h \[\033[33m\]\w$(__git_ps1)\[\033[0m\]\n$

I don't have this issue on any of my other computers either. I've virtualized windows 7 8.1 and 10 and they all don't have this issue. Any insight onto this issue will be helpful

time git rev-parse --git-dir --is-inside-git-dir --is-bare-repository --is-inside-work-tree --short HEAD on my computer:

real    0m0.364s
user    0m0.000s
sys     0m0.186s

Above command in VM:

real    0m0.031s
user    0m0.000s
sys     0m0.015s
mrkirby153
  • 85
  • 2
  • 8
  • 1
    Does your current directory affect the speed? The time is probably all spent in git rev-parse HEAD. I've seen performance issues with git in the status line with large repositories. – lunixbochs Dec 17 '14 at 05:49
  • Can you time the `git rev-parse` command in a couple of repositories on your various VMs? Try to use the same repos/clones for the tests. This should give you an indication on whether it's related to the VM, the repo or maybe the version of Git you're using. – nwinkler Dec 17 '14 at 08:40
  • @lunixbochs The current directory does not affect the speed – mrkirby153 Dec 17 '14 at 23:27
  • @nwinkler Updated to show timings – mrkirby153 Dec 17 '14 at 23:27
  • Run the same `git rev-parse` command with `strace -r` before it. – lunixbochs Dec 18 '14 at 09:20
  • @lunixbochs I'm getting a "Command not found. I'm executing `$ time strace -r git rev-parse --git-dir --is-inside-git-dir --is-bare-repository --is-inside-work-tree --short HEAD` – mrkirby153 Dec 19 '14 at 00:10
  • `strace` only works on Linux. If you're on OS X or BSD, you'll need to use `dtruss` instead. – lunixbochs Dec 20 '14 at 08:17
  • @lunixbochs GitBash doesn't have `dtruss` either – mrkirby153 Dec 21 '14 at 02:20
  • Oh, is GitBash a Windows thing? It's going to be hard for you to debug. Try "Process Monitor" from SysInternals. – lunixbochs Dec 21 '14 at 19:13
  • 1
    Possible duplicate of [Git/Bash is extremely slow in Windows 7 x64](http://stackoverflow.com/questions/4485059/git-bash-is-extremely-slow-in-windows-7-x64) - - try `git config --global core.fscache true`, see if that works. – jthill Dec 11 '15 at 00:25

1 Answers1

0

Check your windows installation for any process trackers. They are corporate installed services/agents that track every process launch for compliance reasons. Example: Altiris. Work with your compliance group to get exclusions for git/bash/cygwin, etc... Get either exclusions, or changes in how these processes get logged (asych vs. sync). Good luck if your firm uses these.