olivierverdier / zsh-git-prompt

Informative git prompt for zsh
MIT License
1.72k stars 395 forks source link

Long delay back to prompt for large repositories #74

Open ZviRackover opened 8 years ago

ZviRackover commented 8 years ago

I am working with a large repository containing tens of thousands of directories. As long as the cwd is located in that directory the prompt will return after a delay of ~10 seconds. With other git repositories this does not happen.

I tried running the same git command the plugin seems to be running:

time git status --porcelain --branch

and i see that the reported elpased time is ~10 seconds, which convinced me that the root cause of the slowness is git and not the plugin.

Next, i tried running the original command with '-uno' which will not report untracked files:

time git status --porcelain --branch -uno

And the elapsed time for that experiment was less than one second.

As a user i would like to have an option to ignore untracked information to allow better performance.

olivierverdier commented 8 years ago

Thanks for that, that's a very interesting idea indeed. We should definitely consider not giving information about untracked files as an option.

Do you know what explains that enormous difference? Are there many untracked files in your case?

ZviRackover commented 8 years ago

I took a look at my working copy where this issue was reproduced and there were less than 400 untracked files, which seems to be negligible compared to the tens of thousands of tracked directories and files. So i am guessing that the cost here is walking the filesystem and looking for untracked files, rather than processing the untracked files which were discovered.

olivierverdier commented 8 years ago

What happens if you use git status --porcelain --untracked-files=no --branch? Is it significantly faster? If it is, we should add an option to use that instead.

casimir commented 8 years ago

Isn't it the same command? From the man page -u[<mode>], --untracked-files[=<mode>].

olivierverdier commented 8 years ago

The essential part is --untracked-files=no

casimir commented 8 years ago

That's what I meant. Although --untracked-files=no is more logical given that the other options are in long form too, -uno is the short form and has exactly the same effect.

I'm interested in this option for git-super-status and I was just trying to spare you 2 some time by pointing the fact that what you ask is the same thing as the first test. :smiley:

olivierverdier commented 8 years ago

Oooooh! I see, sorry, now I understand.

Brilliant, so the solution to get a faster git-status is to use this -uno option. Thanks for the clarification.

casimir commented 8 years ago

Can't wait to see an update with this!

olivierverdier commented 8 years ago

In 045d5a5deff183dbe131867b67f744b177e0997c, the call to git is now in the zshrc file, only for the Haskell version for now. So if you install the Haskell version (should be easy with stack), and add the -uno flag to zshrc, this should speed up the display of the prompt.

Let me know if any of you has a nicer solution, which would activate -uno only on certain directories...

tbarbette commented 5 years ago

Would it be possible to avoid using the prompt on some repositories? Eg with a ".nogitzsh" file? Every time I enter my Kernel source tree on NFS, I've got to press CTRL+C to be able to do anything...