[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
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 48/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- csharp, git
- Área
- cli, performance
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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).
- Lenguaje dominante
- C#
- Estrellas
- 3.1k
- Forks
- 661
- Merge medio
- 7 h 4 min
- PR fusionados (30 d)
- 77
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de GitTools/GitVersion
-
[ISSUE]: Mainline: version on main falls back to 0.0.x when a branch named in a merge message still existsPosiblemente ocupada @arturcic la tomó hace 39 días. Abiertobug
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
GitTools/GitVersion#5405 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
feature
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
GitTools/GitVersion#5398 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 30/100
GitTools/GitVersion#5188 ·
Los mantenedores suelen responder en 1 día
-
breaking change pinned
Dificultad 5/5 Más de una semana Aptitud para principiantes 20/100
GitTools/GitVersion#5137 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
breaking change configuration
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
GitTools/GitVersion#5136 ·
Los mantenedores suelen responder en 1 día
Todos los issues de GitTools/GitVersion
Issues similares
-
documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
area/backend type/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
umbraco/Umbraco-CMS#24668 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Pri3
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
MicrosoftDocs/windows-dev-docs#6205 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día