-
Notifications
You must be signed in to change notification settings - Fork 659
Improves git object cache #4685
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
Conversation
@pvanbuijtene: Thank you for your contribution and the work you have done.
I have following remarks/suggestions:
- The classes Commit, Branch and so on are wrapper classes around the LibGit2Sharp objects. I would say the wrapper classes should not have a reference to GitRepostory. Is it an idea to extract the functionality of caching in a separate class and use this instead?
- Because of the nature of a wrapper class I would expect that the LibGit2Sharp objects are reused as well and the hash code is the same (otherwise we would have still a memory problem). Probably you can use the hash code instead of using an arbitrary string (needs to be tested).
@pvanbuijtene: Thank you for your contribution and the work you have done.
I have following remarks/suggestions:
- The classes Commit, Branch and so on are wrapper classes around the LibGit2Sharp objects. I would say the wrapper classes should not have a reference to GitRepostory. Is it an idea to extract the functionality of caching in a separate class and use this instead?
- Because of the nature of a wrapper class I would expect that the LibGit2Sharp objects are reused as well and the hash code is the same (otherwise we would have still a memory problem). Probably you can use the hash code instead of using an arbitrary string (needs to be tested).
That was my idea to move the functionality from the GitCache class back into the GitRepository as I think the repository wrapper should handle the caching mechanism as it's the abstraction of the database which maintains the collections and the cache, but we can reconsider that
pvanbuijtene
commented
Oct 8, 2025
Happy to help :)
@arturcic as I understand you will implement the suggestions, feel free to ping me in case you want to have some changes tested against a repository causing issues.
@pvanbuijtene thank you, yeah, I implemented the suggestions so far in this PR, but it's a draft for now, I want to test caching the other collections as well before having this merged
7393ace to
ec03709
Compare
e78fba2 to
468ac8d
Compare
Simplifies branch/tag cache keys by including the remote name and SHA.
Renames `GetOrCreate` to `GetOrWrap` to better reflect its caching behavior.
refactors the project to improve code organization and maintainability.
Replaces several internal classes with readonly structs to improve performance by avoiding unnecessary heap allocations. Updates related code to ensure compatibility with the new struct-based implementation.
moves schema and testing projects to misc folder.
Uses lazy initialization to cache references and remotes.
Introduces `GitRepositoryCache` to centralize caching logic for branches, commits, tags, references, and remotes. Updates related classes to use `GitRepositoryCache` instead of directly maintaining individual cache dictionaries.
Replaces `Refs` with `References` across the codebase for better clarity and consistency. Updates all method calls, variable names, and interfaces to reflect this change.
Replaces direct instantiations of Tags, Commits, Remotes, and References with lazy initialization. This avoids redundant object creation and improves performance by deferring instantiation until the collection is accessed.
468ac8d to
ac0e28b
Compare
Quality Gate Passed Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
@pvanbuijtene do you have the time to test this PR on the big repository you have and compare?
pvanbuijtene
commented
Oct 15, 2025
pvanbuijtene
commented
Oct 18, 2025
pvanbuijtene
commented
Oct 18, 2025
I will also do a check with the anonymized repo to see if the object counts are similar, this way there might still be a way to verify things with that repo.
Follow up for #4681