-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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 bash startup is slow #193
Comments
Please follow the steps described in https://github.com/msysgit/msysgit/wiki/Diagnosing-why-Git-is-so-slow to diagnose the problem. It does not take 5 seconds here. |
For me starting git-bash.exe takes around 3 seconds (SSD, more than enough RAM). I tried the "set -x" at the mentioned Wiki page and everything is fast after the mintty window is shown. Even if I start mintty.exe directly it takes 2-3 seconds before the window is shown. Then I pulled my network cable. For some minutes mintty.exe started only after more than 10 seconds. Later, while network cable still pulled, it started instantaneously. So I guessed when mintty.exe starts some network lookup is tried. What I found is that mintty opens an LDAP(?) connection (port 389) to one of my company's servers. This is closed after startup. It keeps open a listening UDP port on 127.0.0.1. Note: The delay before mintty.exe window comes up happens only when starting it from Windows Explorer or cmd.exe command line. When I start mintty.exe from Git Bash it starts instantaneously. A similar issue is described here: http://stackoverflow.com/questions/28410852/startup-is-really-slow-for-all-cygwin-applications From first answer, solution 1, I took the two commands
and entered those while running git-bash.exe. Even without the change to nsswitch.conf the issue is solved. I don't see LDAP connections anymore. git-bash.exe starts as fast as any other small Windows program. cmd.exe still starts faster, though. Tip for the user that comes here to read how to speed up git-bash.exe: The fastest way to create another Git Bash window is to press Alt+F2 from the first Git Bash window. |
Interesting... I'll try that out. They talk about it in the cygwin release notes: https://cygwin.com/ml/cygwin-announce/2015-02/msg00009.html |
@calle2010 I tried the fix from your comment + the I bet it's related to ldap somehow because if I'm on the work domain it tends to start up faster. Still this is a change from the latest stable. |
@kjeremy I've got the exact same issue as you. Startup speed is very inconsistent, anywhere from 1s to 5s. The above tip did nothing for me. set -x and git trace do not help either as the delay occurs before either of those start spitting out info. I am using Conemu and the startup delay only seems to happen there, but the delay never happened with 1.9.5. I'm using: "set MSYSTEM=MINGW64 & "%ProgramFiles%\Git\usr\bin\sh.exe" --login -i" as my Conemu task command. |
@mscrivo maybe setting |
@dscho Didn't help. Although, I just noticed in process explorer that when the delay happens, it's trying to connect to our ldap server and that connection hangs for a while occasionally. Which seems in line with what @calle2010 is saying above. Curious why that didn't work. |
I just noticed @calle2010's command has a typo, he references "cpasswd", I changed the filename to "passwd" and that does indeed fix the problem! |
It only fixed it until I disconnected from the domain and then the problem On Tue, Jun 16, 2015 at 11:20 AM, mscrivo notifications@github.com wrote:
|
I changed my comment to fix the typo. |
Thank you all for the analysis. Based on it, I think the best way to fix this would be to introduce a new |
This would be the way to tackle this issue:
Of course, all of this assumes that the problem actually is in that passwd/group handling. Maybe a sensible first step would be to call Bash from a cd <top-level>
usr\bin\strace -o strace.out usr\bin\bash.exe --login -i (maybe running it without |
Hrm. Apparently there is nobody willing to work on this except for me. But I have no way to reproduce because I have no machine that is connected to LDAP. I fear that it will take more enthusiasm from a developer with access to a setup displaying the behavior in question. Alternatively, if anybody would at least provide clear and simple instructions how to reproduce it on my side, that would be helpful. |
My apologies, I've been meaning to dig into a bit more, at least to provide On Sat, Jun 20, 2015, 9:57 AM dscho notifications@github.com wrote:
|
@mscrivo Thanks! |
@dscho I have the strace.out. How can I get the file to you? I'd like to avoid dropping it here as it could have some sensitive info. Don't have time to come through it all. |
I'm experiencing the same problem with RC4 just in exhibits itself in a more weird way: for me, running I've tried exporting Also weird was the behaviour of setting So I was about to file a bug and read through existing bug reports. This one looked fishy, so I've discovered comment from @calle2010 and re-run my tests. The end result is that not only It appers that all these programs link to some library which unconditionally performs those passdb (or whatever) lookups for unknown reason. Hence I think the fix should probably at some deeper level, not just speeding up passwb lookups -- I fail to see what I have finally tried putting |
Can you give me some pointers on what to look for in the strace output? On Thu, Jul 9, 2015, 7:48 AM dscho notifications@github.com wrote:
|
Does the strace output not contain time stamps? The problem is that some call(s) take(s) long. That should be visible from the time stamps. |
yeah the problem is the file is 27k lines and the output is not in a format that is conducive to formatting and sorting. Anyhow, I think I found the main culprit:
The first call is the most expensive and that is the one fetching my domain account. another big one I found further down in the trace:
|
Okay, it seems that the default
According to https://cygwin.com/cygwin-ug-net/ntsec.html#ntsec-mapping-nsswitch
Yeah, unfortunately this is nothing we can do anything about: it is the POSIX emulation layer trying to reinstate the |
Changing it to
with the passwd and group files in place, it's consistently looks like this:
|
Does it still spend such a lot of time at this step:
? If yes, I encourage you to look at the https://cygwin.com/cygwin-ug-net/ntsec.html#ntsec-mapping-nsswitch page yourself and try other |
Something strange happened. I tried Edit: Problem came back (LDAP server was probably just really fast this morning), and none of the values work. The only thing that is consistently fast is making sure group and passwd exist. |
What is the difference between the strace output with and without |
The difference is that with the passwd/group files, this line:
does not appear in the trace. That line is the LDAP user I'm currently logged in with. However, it still does enumerate the other builtin accounts (which takes quite a bit of time but nowhere near as much as the LDAP account), even when I set db_enum to |
Some findings for interested parties: Oh, and @eckes your problem is pretty much unrelated to this ticket. Your problem is the extensive use of shell scripts, incurring a huge accumulated startup cost of Bash. Trying to move this ticket forward: is there anybody able to give me access to an affected machine? |
@dscho, I think I'll be able to put up a Win XP SP3 32-bit virtual instance for you. The problem is that it will have Cyrillic locale. Will you be OK with RDP connection to such a box? Please drop me a mail to kostix at 007spb.ru (in case you have xmpp connectivity, that's also a JID). |
My 2 cents - |
Okay, thanks to @kostix' excellent help, I could investigate a bit further. It appears as if the Everybody with this problem: could you please replace these two lines in your
with these two lines:
and test whether that lets the Git Bash start up quicker? Thanks. |
@dcho, fixes the issue for me on my affected machine. At least, when in Git Bash, its stock
(I'm still on RC4 here as it's a production box, but given the changelog of RC5, I think my testing still applies to RC5 as well.) |
seems to do the trick. I'll report back if I see any issues as I use it today. |
I was not affected that much by the bug, but Unfortunately, I do not have any idea how to track the time well. |
@Dirk1966, the That's not an excellent measurement, of course, (because to have one, you'd have several hundreds/thousands iterations with averaging over them) but is OK for a rough estimation. See my comment above -- the basic idea is that instead of
you run
to get |
Thanks for the reports! I will make that change permanent in a few minutes/hours. |
@dscho, unfortunately, for me, the problem still persists with this fix. Doing an strace, I still see - These two only happen when I'm not connected to the corporate VPN, When connected, everything is fine. (note that with Cygwin I solved a similar problem by installing cygserver as a Windows service). |
@trianglee is it still taking a long time due to querying ActiveDirectory? |
@trianglee or is it just dancing with a non-existing cygserver instance just because, and just continuing the quick route after not finding any? |
@trianglee That's what I was seeing after disconnecting from our corporate network. See: #193 (comment) I have yet to test this particular fix. |
@dscho, I honestly don't know. Looking at an strace output with and without the delay, things appear very similar - aside of the 18 seconds delay. It isn't clear where it is coming from. Here is an execution, with a delay -
And here is another one, attempted right after, without a delay -
And if I try yet another one a minute later, it would again exhibit the delay. All of that only happens when not connected to the corporate network. When connected, there is never a delay. I'm painfully aware of the inaccuracy of these observations... |
One extra note - the nsswitch.conf suggested change does improve things - without it, the observed delay is of 36 seconds, and with it - only 18 seconds. |
@trianglee do you use 32-bit or 64-bit Windows? In case you use 32-bit, would you mind backing up your |
Personally on x64 connected to AD experiencing the same issue. Changed nsswitch.conf to and No noticeable change, first activation takes a long time, subsequent ones are pretty fast (caching as someone noted). Non cached:
Cached:
Actually there are quite a few lines that look like |
@dscho, Unfortunately, I'm on 64-bit Windows 7. |
@johnsolver I think you also want to set
@trianglee please note that you could have just downloaded the 32-bit portable Git and tried with that one. Having said that, I just built and uploaded a 64-bit version (but you will have to change the filename appropriately): https://dscho.cloudapp.net/userContent/dscho/msys-2.0-64.dll |
I tried it and received 3 af one after the other, with a delay before the first appeared.
Doesn't help, as in behaves the same way |
@johnsolver I guess we are at an impasse now... unless you can build and patch |
In git-for-windows/git#193 it has been reported that Git Bash takes an extraordinary time to start up under certain circumstances. One of those situtations is when the computer is in a domain but the domain controller cannot be reached. This developer finally had a chance to reproduce this issue and debugging revealed that the groups are always read from LDAP, in this particular case resulting in 30sec delays or longer. Since Git for Windows does not actually care about groups all that much, let's just skip reading groups from Windows. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
…b' fix In git-for-windows#183, we quickly fixed a performance problem around `git checkout -b` and added a deprecation waning. After submitting that upstream, we found instead the commit 3136776, which just puts a simple performance hack in to `git checkout` to check for exactly `checkout -b <branch>` and then use the `git switch -c <branch>` logic. This PR reverts the commits from git-for-windows#183 as fixups and merges in the commit from upstream instead.
Starting git bash from the start menu (for example) takes about 5 seconds enter a useable state. Doing the same in the git-1.9.5-preview release is virtually instantaneous.
This is a regression from the git-1.9.5-preview release.
The text was updated successfully, but these errors were encountered: