Why is my shell slow after a while when I use git aware prompt and run git commands?

6,835

You can debug why git is being slow.

There are some ways to improve git performance:

  • Enable git parallel index preload. git config --global core.preloadindex true
  • Minimize the number of files in .git folder. git config --global gc.auto 256
  • Run git garbage collector git gc.
  • Remove untracked files git clean -xf. Use git clean -xfn for a dry-run to check that everything is ok.
Share:
6,835

Related videos on Youtube

simbabque
Author by

simbabque

I'm a software developer and mentor working mostly in perl with the occasional mysql, html and javascript thrown in. I currently work with moose and catalyst. I'm active in both the German and London Perl communities. I train software development apprentices in the Perl programming language. I also volunteer at Codebar in London. When I speak at conferences, it's usually about training and mentoring. My favourite Perl modules currently include Data::Printer, Test::Class::Moose and LWP::ConsoleLogger. Former favourites: HTTP::XSHeaders. Here are some answers I gave that like a lot: How do Perl modules “work”? DBIx::Class - get all relationship that was used as a condition using prefetch? We might have already met at one of these Perl events: German Perl/Raku Workshop 2021 (Speaker) German Perl/Raku Workshop 2020 (Speaker) Barcelona Perl & Friends 2019 (Speaker) London Perl Workshop 2019 (Organiser) PerlCon 2019 Riga (Speaker) German Perl Workshop 2019 (Speaker) London Perl Workshop 2018 (Organiser, Speaker) Swiss Perl Workshop 2018 (Speaker) TPCiG 2018 (Speaker) German Perl Workshop 2018 (Speaker) London Perl Workshop 2017 (Speaker) TPCiA 2017 (Speaker) German Perl Workshop 2017 (Speaker) YAPC::EU 2016 German Perl Workshop 2016 (Speaker) German Perl Workshop 2015 YAPC::Europe 2014 Dutch Perl Workshop 2014 German Perl Workshop 2014 (Organiser) London Perl Workshop 2013 German Perl Workshop 2013 YAPC::Europe 2012 Hannover Perl Mongers, Berlin Perl Mongers, London.pm I am #SOreadytohelp.

Updated on September 18, 2022

Comments

  • simbabque
    simbabque over 1 year

    I am using git-aware-prompt in my .bash_profile on Ubuntu 15.4 like this:

    export GITAWAREPROMPT=~/.bash/git-aware-prompt
    source $GITAWAREPROMPT/main.sh
    

    When I am in one of my main repository directories this nicely shows the git branch in my prompt. However, after a few days (I do not restart my box often) it takes a long time after I run a command until the prompt comes back.

    Especially when I run commands like git add foo or similar. It takes over a second for the next line of prompt to show up. Even if I open a new terminal window it is still slow.

    If I navigate to a different git repo this does not happen. In directories without git it's also fine.

    I don't think it's related to the git-aware-prompt, but rather to the repository. There might be some weird cache that I do not know about.

    What can I do to make this go fast again?

    • choroba
      choroba over 8 years
      Does it happen in a new terminal, too? Whould running git gc in the repo help?
    • simbabque
      simbabque over 8 years
      @choroba: In a new terminal window it happens too. What does git gc do?
    • simbabque
      simbabque over 8 years
      I ran the garbage collection. That helped a bit. Let's say it gave me a 50% performance boost, but I can still feel the difference between being in a git directory and for example my homedir.
    • Malte Skoruppa
      Malte Skoruppa over 8 years
      You say you don't think that this is related to git-aware-prompt, and that it doesn't happen in another repository. Do you see this behavior even when you don't source the git-aware-prompt script? If yes, it probably has nothing to do with git-aware-prompt at all. If no, it may be related to a combination of that particular repo and git-aware-prompt (as git-aware-prompt makes a few gitcalls before you are returned to the prompt.)