-
Notifications
You must be signed in to change notification settings - Fork 654
GitVersion Performance Issues #734
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
GitVersion Performance Issues #734
Conversation
It looks like this requires having 'git' available on the command line? Based on my (possibly incorrect) understanding, GitVersion is currently independent and doesn't require that? |
If git is not there it will use the original code. |
Perhaps @nulltoken knows how to do this in |
The (untested) following code may be what you're after: repo.Refs.ReachableFrom(new[] { commit })
.Where(r => r.IsLocalBranch || r.IsTag) |
OK, all tests passed.
Don't know how to deal with the
|
This is a breaking change, and I think it's better to handle this in a separate issue!
|
Ok, breaking change removed. |
@EbenZhang could you try @nulltoken's code? It would be great to get the perf boost without having to have git installed. |
@JakeGinnivan, testing it now. Already 10 minutes passed. |
@nulltoken any ideas on the perf side of things? Seems odd we should have to drop to the command line. I wonder if the newer versions of libgit2sharp are quicker in this regard though. I have this arvo blocked out to close out as many issues and investigate stuff as I can |
It takes 41m:50s for gitversion to finish. |
@nulltoken, the code i used was copied from the libgit2sharp's Uncyclo page to get the branches for commit/tag (roughly 79 branches, 5666 commits results from private IEnumerable<Branch> ListBranchesContainingCommit(Repository repo, string commitSha)
{
var localHeads = repo.Refs.Where(r => r.IsLocalBranch());
var commit = repo.Lookup<Commit>(commitSha);
var localHeadsContainingTheCommit = repo.Refs.ReachableFrom(localHeads, new[] { commit });
return localHeadsContainingTheCommit
.Select(branchRef => repo.Branches[branchRef.CanonicalName]);
} |
@EbenZhang Can you please share the following information:
Thanks in advance. |
Hi @nulltoken and @JakeGinnivan , I can't share the private repo with you guys, but fortunately it seems not hard to reproduce. After some more tests, I've found something really interesting, hope someone can explain. Env:
Code:I tested 3 different ways to get the branches for a commit.
private static void Main(string[] args)
{
Repository repo = new Repository(@"MyGitextensionsRepoPath");
var w = new Stopwatch();
w.Start();
var x = ListBranchesContainingCommit(repo, "9fe628226c51f2087e3a9ac0218595fee154b258").ToList();
w.Stop();
using(var test = new StreamWriter("test.log"))
{
test.Write(w.ElapsedMilliseconds);
}
}
var w = new Stopwatch();
w.Start();
var k = ListBranchesContainingCommit(repository, "9fe628226c51f2087e3a9ac0218595fee154b258").ToList();
w.Stop();
using (var test = new StreamWriter("test1.log"))
{
test.Write(w.ElapsedMilliseconds);
}
Environment.Exit(0); // exit GitVersion as I only want to get the time for the commit.
ResultA took 838ms, B took 19994ms, C took 423ms Provide that I'm not wrong about GitVersion that it will look for branches all tags and also branches for some commits, B will take at least On a 8GB memory Windows10 64-bit PC, B took 16843ms. Question
|
Profiling Result:
|
@EbenZhang can you give me more info how you are hitting these perf issues? I am trying to replicate against the git extensions repo without issues |
You may want to remove the GitVersion doesn't really have a problem to get the version for GitExtensions repo. I used it to profile the performance of the
|
@EbenZhang I am more interested in how you get GitVersion.exe to perform badly. Optimising a function may not be the way to go, most of the perf improvements have come from re-thinking the problem and coming up with a better solution. |
@EbenZhangEmbed I am keen to work with you on this, should I just cherry pick the non git command line stuff out of here? |
Tried again today on the problematic pull request, unfortunately, I'm not able to reproduce it now (probably because some branches were deleted or pull requests closed, or maybe new tags created). I'll config one of the build agent to use the official GitVersion and keep an eye on its performance. Maybe you can have a look of the log to see if there's any clue. Here is the log with confidential stuff removed.
I'll extract them and create another pull request because without the git command line improvement I should remove the duplicate code between |
0_o, that is some bad perf! If the changes you have made (without the cmd line stuff) improves the perf or simplifies things then I would love to pull it in. I will also have a bit of a look into possible causes for the timing you have seen. |
Done |
@EbenZhang #765 has been merged. Could you please update this PR? :) |
Id like to remove the calling of the git exe. The library shouldn't be faster. Gonna close this one out, then if we can provide a example repo which causes the perf issues we can investigate. |
Create a pull request, so people may help test or improve. It's not done yet, at least have to fix the unit tests.
This pull request uses git command line to replace the libgit2sharp to find the branches for a commit/tag. Will be happy to see if someone knows how to do the same thing in libgit2sharp.