-
-
Notifications
You must be signed in to change notification settings - Fork 171
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
Consider using a managed Git backend #505
Comments
Thanks for giving this a try. In fact I was planning to prototype this myself so you saved me quite a bit of time. I'll likely get to try it early next week and I'll report back the results. |
Thanks for your investment and willingness to contribute more. I would love to switch to a managed git implementation to finally put all the linux distro compat issues behind me. Of course, libgit2sharp is on the cusp of fixing that by replacing their native https implementation with a managed one, but they've been on the cusp for probably over a year now. As you say, their investment is really light right now. I do have some concerns/responses to some of your points however: Some Via libgit2sharp we also support worktrees in readonly scenarios. The managed git implementation would have to support that too. I'm not sure what other git configs or .git folder states that we should consider here, so I would not likely switch to a managed git implementation unless it was either very mature or had a very responsive developer backing it who was committed to making nbgv work great on it, since I personally do not have time to invest in a managed git implementation. @qmfrederik what are your thoughts on this? Are you committed to reaching parity in at least the read-only git scenarios that nbgv currently requires (without feature cuts)? Or would you recommend one of the several other managed git implementations that you linked to as active and possibly willing?
Path filters was a recent feature which I was only willing to accept by PR after conditions were put in place to avoid perf regressions when they weren't used. I'd be surprised (and disappointed) if they had negative perf impact after all. But certainly walking up a project directory to the git root does add time. There are plenty of repos that do this, so while perf is nice, I believe there are ample ways to improve perf substantially without cutting this or other features. |
Yes, I noticed that. I first tried to refactor nbgv and put the Git API behind an interface. My current thinking is that it'd be worth to make the read-only operations (everything required to calculate the Git height) use a managed implementation, and have I at first thought it'd be straightforward to extract an interface for the Git API and have nbgv use both, allowing users perhaps to choose between both with a feature flag. It is not as straightforward as I first thought (but probably doable). nbgv doesn't use DI much / uses statics / ... which does not simplify the process.
For read-only access, it looks like at least @filipnavara and I are willing to invest time in making it work. The format of the git object database and the pack files seems to be very stable over time, which is a bonus. The .NET projects I found on GitHub are all fairly old and seem unmaintained. Calculating the commit height essentially only touches the Git object database & pack files, so worktree support should be fairly trivial. Path filters and other features should be doable (especially since nbgv comes with a good set of unit tests) but I'd say there's be limited incentive to push the performance to its limits when those features are on. Net, I think the next steps are probably something along the lines of:
|
Looking forward to see what perf you can squeeze out of git! PS: I apparently forgot to push a couple of commits to the repo, so you probably want to make sure you pull the latest changes. There were some changes related to working with pack files. |
I found some missing parts in the Frederik's managed GIT implementation. For example, due to the sheer size of our repository some of our developers use In the past I contributed to go-git - a pure Go library for manipulating GIT - and from my experience the read-only implementation is fairly easy to get done right. It gets a little tricky with all the nooks and crannies around reference parsing, config file parsing and features like alternative object stores but once that gets done it requires nearly zero maintenance. My main issue with |
I think this should be fine.
Yes. We might hit snags around interesting niche features like #479 that may represent a good deal of extra work in the managed git library to support it. I'd be hesitant to take feature cuts. But deferring new feature work while the managed git impl catches up to libgit2sharp in those ways is tolerable.
I'd rather be incremental about it, where NBGV takes a hybrid approach that gradually migrates as the managed git implementation becomes more capable and we have time to migrate code.
This work may not address that concern. I think we should plan on having libgit2sharp "in box" as a crutch so we can (continue to) support things that the managed git implementation does not (yet) support. I would only remove libgit2sharp once we're confident we don't and won't need it any more. But in the meantime we can/should avoid loading it until we absolutely need it, with the goal being that simply computing the version as is required in builds should not require it at all.
Are they decent bases though on which to continue work as opposed to starting fresh? |
The open source libraries are fairly old (think NetFx-era), and at first sight it seemed like working with packfiles was not well supported by these libraries. That, paired with the absence of An option could be to fork one of the repositories and evolve it. My main concern there is that it might set expectations of a supported, general-purpose Git library for .NET. I'm not sure who would maintain that project - it's not something I'd take on at the moment. |
https://github.com/qmfrederik/Quamotion.GitVersioning/commit/fbbadbec36f92d91d685018f02f2dbc11dcea275 may help ;-) |
@qmfrederik It sounds like your interest is limited just to NB.GV scenarios. So would we put the managed git implementation directly into this repo? That is probably fine. Another place to look for a good base is SourceLink, which I believe has a readonly managed git implementation already. I haven't yet looked closely at your prototype code @qmfrederik, so I'm certainly not trying to diss your existing prototype. I just want to keep the up front and maintenance cost as low as possible. If we can share code with another project with similar interests, we may help each other. But if that isn't a good fit, and you're willing to put in the work, I'm good with a unique solution in this repo too. |
FYI, I think the perf improvements coming for #114 will be very significant, and are relatively cheap compared to rewriting portions of libgit2sharp. So the long-term value I see in a managed git impl is primarily around working everywhere instead of being limited to where libgit2sharp has native binary support. And if libgit2sharp ever finishes removing their native HTTPS dependency, that would be resolved too. |
That's not exactly it. It should act as a fallback. First try the regular objects directory and only if that fails then try the alternate one. The objects could be present in either one. There could also be more than one alternate directory and the paths can be relative. I'll file any problem I find as an issue on your repository to keep the discussion here cleaner. |
That's what I would suggest at the moment.
Yes, I initially started from the code which is in the SourceLink repository. But it's a very light implementation - it supports reading the URL of the remote repository and the name of the branch you're on, and that's pretty much it. There's no support for reading commits, trees or blobs.
Yes, but there are other issues caused by libgit2sharp:
Here's what the timeline for linux-arm64 looked like:
So, that's 7 months to get it done. You'd get it 'for free' with a managed implementation. Honestly, I never want to go there again. The complexity of having to raise PRs across three repositories with two different owners, the complexity in debugging this (a MSBuild task which runs a managed wrapper around native code, which can execute in .NET, .NET Core or Mono, with all the different loading rules,...). I think that time is better spent building a performant, managed, read-only Git implementation.
It's always good to reach out to libgit2sharp and see what they are up to. libgit2/libgit2sharp.nativebinaries#96 was merged a while ago, but not sure what the impact is. |
You make a strong argument, @qmfrederik. I'm in favor of your continuing your prototyping. Please raise architectural or other significant questions early to avoid lost work. I'm listening for a response to the "managed HTTP stack" PR over at libgit2sharp, but at the moment I'm inclined to go with your proposal. |
TL;DR
I've done some experiments with a managed Git backend (instead of libgit2).
In all scenarios, performance is better with the managed backend. In the best case, throughput increases more than tenfold.
The prototype source code is available here: https://github.com/qmfrederik/quamotion.gitversioning.
There are other managed Git backends (GitNet, GitSharp, NGit) available.
Why
NerdBank.GitVersioning uses LibGit2Sharp as its back-end. It comes with a couple of drawbacks:
What
My goal was to implement a minimal viable Git backend which you can use to calculate the Git height. That's all.
This includes
git gc
or after a fresh Git clone) and deltafied objectsI've also applied some of the suggestions related to performance made by @filipnavara and @djluck, such as
version.json
contentsI've not yet attempted / further exploration
version.json
objects are fully loaded into memory before parsing them; we can probably further improve performance by only reading the data we actually need.Validation & lessons learned
version.json
file in the repository root, no path filters,... . nbgv has a lot of configuration knobs, which may impact performance.What's next
Obviously, that's up to the maintainers of this repository. Personally, I've spent too much time on getting LibGit2Sharp working on the platforms I care about (Visual Studio Code on Ubuntu, to name one) and will want to move to a purely managed build task for calculating Git height. My preference is to keep using nbgv, so I can take this further and open a PR if there's interest in getting it merged.
@filipnavara mentioned he has a repository with a very large git height (> 1500 IIRC). It's be interesting to run the benchmarks on that repository, too, and see how the managed implementation holds up (I'm guessing running benchmarks will uncover some bugs, too), both in an 'unpacked' and a packed state of the repository.
The text was updated successfully, but these errors were encountered: