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

Long delay back to prompt for large repositories

Open ZviRackover opened this issue 9 years ago • 10 comments

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.

ZviRackover avatar Nov 06 '15 19:11 ZviRackover

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?

olivierverdier avatar Nov 10 '15 09:11 olivierverdier

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.

ZviRackover avatar Nov 11 '15 16:11 ZviRackover

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.

olivierverdier avatar Jan 13 '16 15:01 olivierverdier

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

casimir avatar Jan 13 '16 17:01 casimir

The essential part is --untracked-files=no

olivierverdier avatar Jan 13 '16 18:01 olivierverdier

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:

casimir avatar Jan 13 '16 18:01 casimir

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.

olivierverdier avatar Jan 13 '16 18:01 olivierverdier

Can't wait to see an update with this!

casimir avatar Jan 14 '16 09:01 casimir

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...

olivierverdier avatar Jan 15 '16 11:01 olivierverdier

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...

tbarbette avatar May 26 '19 10:05 tbarbette