-
Notifications
You must be signed in to change notification settings - Fork 652
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
Fix TaggedCommitVersionStrategy performance problems #2800
Conversation
The problem was a branch commits x version tags nested loop that quickly grew into the millions of iterations as the number of commits and/or tags in a repo increased, even modestly. Each iteration performed Git tag-to-commit resolution and GitVersion commit object-to-object comparison, both of which take a little bit of time and aren't particularly slow in isolation but which add up fast when performed millions of times. This is solved by doing a single pass over the tags, resolving each to a commit only once; then using that to build a commit-to-tag lookup (hashtable) keyed by commit SHA, eliminating the object comparisons; and finally doing a single pass over the branch commits, looking up associated tags from the hashtable by SHA, eliminating the nested loop. Testing on a repo with ~20,000 commits and ~5,000 tags showed an overall GitVersion run time reduction from over 2 minutes down to around 5 seconds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great!
src/GitVersion.Core/VersionCalculation/BaseVersionCalculators/TaggedCommitVersionStrategy.cs
Outdated
Show resolved
Hide resolved
…TaggedCommitVersionStrategy.cs Co-authored-by: Asbjørn Ulsberg <[email protected]>
Can you please run |
Sorry, my mistake: I hadn't pulled the PR feedback change. |
Head branch was pushed to by a user without write access
Thank you @ron-macneil-youi for your contribution! |
🎉 This issue has been resolved in version 5.7.0 🎉 Your GitReleaseManager bot 📦🚀 |
The problem was a branch commits x version tags nested loop that quickly
grew into the millions of iterations as the number of commits and/or
tags in a repo increased, even modestly.
Each iteration performed Git tag-to-commit resolution and GitVersion
commit object-to-object comparison, both of which take a little bit of
time and aren't particularly slow in isolation but which add up fast
when performed millions of times.
This is solved by doing a single pass over the tags, resolving each to a
commit only once; then using that to build a commit-to-tag lookup
(hashtable) keyed by commit SHA, eliminating the object comparisons; and
finally doing a single pass over the branch commits, looking up
associated tags from the hashtable by SHA, eliminating the nested loop.
Testing on a repo with ~20,000 commits and ~5,000 tags showed an overall
GitVersion run time reduction from over 2 minutes down to around 5
seconds.
Description
Related Issue
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Checklist: