[ISSUE]: 6.7.0 spends ~7s per candidate in "Finding branches source" (~9 min total) on repos with many branches, and every candidate is then skipped as orphaned
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- csharp, git
- Lĩnh vực
- cli, performance
Hướng nghiên cứu
Start at the version-calculation path that logs “Fetching the base versions for version calculation” and “Finding branches source,” focusing on candidate branches and the source-branches configuration. Compare the unknown configuration with source-branches: [main] using a repository with many remote branches. Done means equivalent FullSemVer, BranchName, and Sha output without the excessive per-candidate delay.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Prerequisites
- I have written a descriptive issue title
- I have searched issues to ensure it has not already been reported
GitVersion package
GitVersion.Tool
GitVersion version
6.7.0 (6.7.0+Branch.main.Sha.00e59b5f45fe97e2e610a480a860b3a009db9602)
Operating system
Linux
What are you seeing?
On a TeamCity agent that fetches all heads (teamcity.git.fetchAllHeads=true), version calculation takes 8.5–9+ minutes on every non-main build. Almost all of that time is spent inside Fetching the base versions for version calculation, in one Finding branches source of '<branch>' block per candidate source branch.
In one diagnostic run of a build for a branch that matches the unknown config:
Things that stand out:
- The cost is not the merge-base work. The nested merge-base lookups take milliseconds. For example,
merge-requests/5735/headspends 6.8 s betweenBegin: Finding branches sourceand its onlyFinding merge basecall, which takes 1.81 ms. Nearly all of the ~7 s per candidate happens before any merge base is computed. It looks like each candidate triggers a scan over all ~1,650 local and remote refs, or over the full history. - Every candidate is evaluated twice, once as the local branch created by normalization and once as
origin/<same branch>. For example,feature/Xandorigin/feature/Xtake ~9.5 s each. - Almost all of that work is thrown away. 79 of 81 candidates (all
feature/*andpull-requestbranches) end up skipped as "orphaned". The version comes frommaineither way. - The time grows linearly with the number of
feature/*andpull-requestbranches on the remote, so builds get slower as the branch count grows.
Setting source-branches: [main] on the unknown and pull-request configs brings it down to ~25–40 s with identical output (FullSemVer, BranchName, Sha, and so on). So the expensive work does not change the result here.
The same slowdown affects pull-request builds (merge-requests/<n>/head, GitLab refs on TeamCity): 8.5–9 min with the default pull-request source branches, and 25–35 s with source-branches: [main], same version.
What is expected?
- Checking a candidate source branch should cost roughly what its merge base costs (milliseconds), not ~7 s.
- A branch and its remote-tracking twin (feature/X and origin/feature/X) should be evaluated once, not twice.
- Ideally, candidates that will end up discarded as orphaned should be detected cheaply before the expensive part.
A 42k-commit repository with ~800 branches should compute a version in seconds on a build server, the same as it does with source-branches: [main].
Steps to Reproduce
A repository with ~42k commits on master, ~680 tags and ~825 remote branches. Of those, ~33 match the default feature regex, ~7 are merge-requests//head, and the rest (~785) match the unknown config.
GitVersion.yml:
branches:
main:
regex: ^master$|^main$
mode: ContinuousDelivery
label: ci
feature:
mode: ContinuousDelivery
pull-request:
regex: ^(pull|pull\-requests|pr|merge|merge\-requests)[/-](?<PRNumber>\d+)
mode: ContinuousDelivery
label: PullRequest{PRNumber}
ignore:
sha: []
A build-server checkout with all heads fetched and a single origin remote. Environment: TEAMCITY_VERSION set, Git_Branch=refs/heads/ (a branch matching unknown, e.g. renovate/patch-nodejs-packages), HEAD detached at that branch's tip.
Run:
dotnet-gitversion -nocache -nofetch -verbosity Diagnostic -l gitversion.log
Observe ~81 Finding branches source blocks at ~7 s each, and the orphaned ... skipped=True lines after them.
Workaround that brings it to ~30 s with identical output:
pull-request:
# ...
source-branches:
- main
unknown:
source-branches:
- main
Environment for the numbers above: Linux x64 (kernel 6.8), .NET SDK 10.0.401. The TeamCity agents (Linux) show the same timings: SetVersionInfo 9m05s–9m13s with the defaults, 35 s with the workaround.
RepositoryFixture Test
No response
Output log or link to your CI build (if appropriate).
- Ngôn ngữ chính
- C#
- Star
- 3.1k
- Fork
- 661
- Merge trung bình
- 7 giờ 4 phút
- Pull request đã merge (30 ngày)
- 77
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của GitTools/GitVersion
-
[ISSUE]: Mainline: version on main falls back to 0.0.x when a branch named in a merge message still existsCó thể đã có người làm @arturcic đã nhận 39 ngày trước. Đang mởbug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
GitTools/GitVersion#5405 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
feature
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
GitTools/GitVersion#5398 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
GitTools/GitVersion#5188 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
breaking change pinned
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
GitTools/GitVersion#5137 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
breaking change configuration
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
GitTools/GitVersion#5136 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của GitTools/GitVersion
Issue tương tự
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
area/backend type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
umbraco/Umbraco-CMS#24668 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Pri3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
MicrosoftDocs/windows-dev-docs#6205 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày