-
-
Notifications
You must be signed in to change notification settings - Fork 26k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
git_prompt_status is slow on cygwin #5486
Comments
Feel free to make a PR, I'm all for using all zsh builtins. Thanks! |
Was this ever PR'ed / merged? |
I made a PR, but it was never merged. There's also a sed-based version in that linked repo. It's even faster (another multiple) because it only counts unique status lines. But I never got around to testing it on BSD platforms, and it doesn't use ZSH builtins. |
Ok, thanks. Bit of a side question: how did you track down the cause of the slow prompt? Even after using your sed-based version, my prompt it still slow and I suspect it's the damn corporate anti-virus. But I need a way to verify that. |
I started out by looking at the outputs of If you're on Cygwin, I'd give it an 98% chance of being extra subshells or commands (especially grep) being executed. Forking and running commands (including subshells) is extremely slow on cygwin, because it's not really forking, it's creating a process and then cloning the previous command's entire data segment, stack, heap, etc. manually into the new process. The Windows kernel itself does support forking, but that functionality isn't exposed to the win32 subsystem. If you're on another environment, the only real things I've seen used that killed performance in a prompt was a plugin function that scanned and parsed the history file and rewrote it after every command and one that was trying to do a git fetch after every one. |
@TheDauthi Yes, I'm on babun (cygwin + extras). Turns out it was the anti-virus. It does a real-time scan for every fork, which exacerbates the issue. Thanks for your help. |
That's interesting. I'd suspect that with the extra work with the anti-virus, the pure-shell-parser version would be the faster one. That means that the sed one should be faster in some cases, but the pure shell one would be a more consistent improvement. Too bad we need the 'stashed' status, or we could cut the number of forks in half. On Cygwin, it might actually be better iterating up the directory tree for that status, looking for .git/refs/stash, since we don't care about anything other than whether there is a stash or not. But that change would be better served by a plugin, since it's a Cygwin-only hack. EDIT: @igitur the other issue you linked to is exactly what caused me to write this. I also use babun and had switched to the theme I normally use from Linux. |
@TheDauthi could you link to your PR for me? |
It also provides more data for someone to use if someone wanted (the count of each type of modification), and would be trivially easy to change the order. There's no extra work being done, it's just a side-effect of how it's being counted now. I'll be happy to fix any problems found. It's been tested somewhat (linked repo), but that's no guarantee that I didn't miss anything. |
Also checkout https://gist.github.com/sindresorhus/3898739. |
|
Actually, my shell was freezing because of Russel's theme of zsh on function |
It's different code and does a different thing, but possibly the same underlying problem. We're a bit off topic here, but your point is valid and should be noted for anyone coming across the problem: for a large codebase (or a very slow filesystem), anything calling git status underneath may be slow. I've seen several attempt to fix that, from trying to kill the git status process after a timeout to caching the output. I don't think any of them have been successful yet. I think the current suggestion is to use |
I have the same proplem here - Win10, Ubuntu Subsystem, Oh-My-Zsh: This is on an i7 with an ssd, however the git repo resides in /mnt/d/..., so this is on an NTFS device, not the virtual extfs used by the bash. Any ideas except hide-status? |
My current work-around: Comment the line "prompt_git" at the very end of the agnoster theme (~/.oh-my-zsh/themes/agnoster.zsh-theme) - Snappy as hell, but no branch info any more. :-/ |
I've solved the problem quiet easy:
Et voilá: without any change to any theme |
I wanted to ask if there's any possibility to have a fix here anytime, or this is just not possible on windows because of technical borders? I have made a change to my agnoster file according to @iegik suggestion, that i have a git light.
So all I left active would be this:
|
Hey there, I'm doing a bit of housekeeping on the project. Thanks for raising this issue—we always love a good edge case! 😄 However, it's not gathering much community interest, so I will close it for now. Don't let this discourage you! We're all for hearing about the weird things. We can't commit to spending too much time tracking each weird thing down ourselves. |
git_prompt_status is rather slow on cygwin, and on other platforms where spawning a subshell is slow.
Two cases:
(first, just calling the function, second is inside a fresh linux kernel tree. )
(Not much we can do about the second one, it's due to the slowness of the git status itself)
Identical setup on linux:
Tracking this down, it's the spawning of the greps (which is no shock; cygwin emulation of fork is well-known, and grep is somehow particularly slow). I rewrote this function to use zsh builtins and an ugly bit of sed instead of spawning greps:
Cygwin:
It's faster on linux, too, but linux was already fast:
Linux:
https://github.com/TheDauthi/git-prompt-status
I didn't make a pull request; this is in a frequently-used lib so I didn't want to touch it without testing, if there's even interest in using a modified version. I wrote a FEW tests (they're in the test directory), but will try to add more. I also would like to know if/how you typically integrate tests, as what's there is just something I hacked up in a couple of hours.
Not sure how the command works on OSX yet, don't have a machine to test on until Monday. I suspect that the sed statements will need to be re-quoted. Wanted to gauge interest and get feedback before continuing.
The text was updated successfully, but these errors were encountered: