GitVersion icon indicating copy to clipboard operation
GitVersion copied to clipboard

[ISSUE]: GitVersion sometimes takes several hours, seemingly hanging for several minutes between steps

Open ChristoWolf opened this issue 9 months ago • 2 comments

Prerequisites

  • [x] I have written a descriptive issue title
  • [x] I have searched issues to ensure it has not already been reported

GitVersion package

GitVersion.Tool

GitVersion version

6.1.0, something similar but faster (takes about 25 minutes) happens with 5.12.0

Operating system

Windows

What are you seeing?

Hi!

I am executing .\dotnet-gitversion /updateprojectfiles /output json /l console /diag /verbosity Diagnostic /nocache /nofetch on a repository with about 400 branches and 85 tags, containing C# code with about 400 projects.

I already had issues with GitVersion performance when using v5.12.0 where the above execution took about 25 minutes. That got me thinking that it might have been related to #2881, so I updated to v6.1.0. Executing the above command using that version either of these might happen:

  • Either everything works and GitVersion takes about a minute:
    • it takes about 10 seconds for Normalizing git directory for branch
    • Fetching the base versions for version calculation takes about 2 seconds and that specific log output is 33 lines long
    • Using continuous delivery workflow to calculate the incremented version takes 1 second
  • or the issue occurs where in between various steps execution takes several minutes without any log output. The log at the bottom shows this (abbreviations with ...). Execution then takes several hours in total. The log output in Fetching the base versions for version calculation grows to over 6000 lines until the task times out.

So I see 2 issues here:

  • Execution of some steps in GitVersion sometimes takes several minutes for no obvious reason,
  • and there are a lot more lines related to Finding merge base, Getting tagged semantic versions on branch and Found commit then when it runs fast.

I am only able to reproduce this when running GitVersion in a self-hosted Azure DevOps Server agent, not when running it on my machine.

Also, I checked #4409 but I am not sure if this is related.

Here is my GitVersion.yml:

mode: ContinuousDeployment
update-build-number: false
next-version: 0.17.1
assembly-versioning-format: "{Major}.{Minor}.{Patch}"
assembly-file-versioning-format: "{Major}.{Minor}.{Patch}"
assembly-informational-format: "{Major}.{Minor}.{Patch}{PreReleaseTagWithDash}+{env:BUILD_BUILDID ?? 0}"
branches:
  main:
    regex: ^master$|^main$
    is-source-branch-for: ["develop", "release"]
    is-main-branch: true
    label: ""
  develop:
    regex: ^develop$
    mode: ContinuousDeployment
    increment: None
    prevent-increment:
      of-merged-branch: false
    track-merge-target: true
    source-branches: ["main"]
    is-source-branch-for: ["feature"]
    tracks-release-branches: true
    is-release-branch: false
    is-main-branch: false
    pre-release-weight: 0
    label: alpha
  release:
    regex: ^releases?[/-]
    mode: ContinuousDelivery
    source-branches: ["develop", "release"]
    is-release-branch: true
    label: ""
  pull-request:
    regex: ^(pull|pull\-requests|pr)[/-]
    mode: ContinuousDelivery
    increment: Inherit
    # tag-number-pattern: '[/-](?<number>\d+)[-/]'
    source-branches: ["develop", "release", "feature", "pull-request"]
    label: PullRequest
  task:
    regex: ^task[/-]
    mode: ContinuousDelivery
    source-branches: ["develop", "task", "feature"]
    label: beta

Thanks for any help!

What is expected?

.\dotnet-gitversion /updateprojectfiles /output json /l console /diag /verbosity Diagnostic /nocache /nofetch only takes a couple of minutes at most.

Steps to Reproduce

Unclear.

RepositoryFixture Test

No response

Output log or link to your CI build (if appropriate).

Installing GitVersion via dotnet tool install.
You can invoke the tool using the following command: dotnet-gitversion
Tool 'gitversion.tool' (version '6.1.0') was successfully installed.
Will execute command '.\dotnet-gitversion /updateprojectfiles /output json /l console /diag /verbosity Diagnostic /nocache /nofetch /overrideconfig update-build-number=false'.
Running GitVersion to update projects and log results.
INFO [25-02-11 12:02:58:15] Working directory: C:\SP\agent\_work\1284\s
INFO [25-02-11 12:02:58:21] Project root is: C:\SP\agent\_work\1284\s\
INFO [25-02-11 12:02:58:21] DotGit directory is: C:\SP\agent\_work\1284\s\.git
INFO [25-02-11 12:02:58:21] Branch from build environment: refs/pull/14311/merge
INFO [25-02-11 12:02:58:21] -< Begin: Normalizing git directory for branch 'refs/pull/14311/merge' >-
  INFO [25-02-11 12:02:58:26] One remote found (origin -> '<redacted>').
  INFO [25-02-11 12:02:58:27] Skipping fetching, if GitVersion does not calculate your version as expected you might need to allow fetching or use dynamic repositories
  INFO [25-02-11 12:02:58:38] Creating local branch pull/14311/merge pointing at 21b3b8c
... (nothing out of the ordinary here)
  INFO [25-02-11 12:03:54:91] -< End: Finding branches source of 'pull/14311/merge' (Took: 47,523.95ms) >-
  INFO [25-02-11 12:28:05:49] -< Begin: Finding branches source of '<redacted>' >-
... (as you can see, in between these steps it didn't output for almost 25 minutes)
      INFO [25-02-11 12:29:37:13] Found merge base of ''18536b8' - Merged PR 3740: Implement SettingsDbIntegrationTest'
      INFO [25-02-11 12:38:15:21] Merge base of '<redacted>' and 'origin/release/0.7.0' is ''18536b8' - <redacted>'
... (above it took almost 9 minutes)
      INFO [25-02-11 12:38:32:41] -< Begin: Getting tagged semantic versions on branch 'refs/heads/release/0.11.1-alpha.1130'. TagPrefix: [vV]? and Format: Strict >-
      INFO [25-02-11 12:46:56:90] -< End: Getting tagged semantic versions on branch 'refs/heads/release/0.11.1-alpha.1130'. TagPrefix: [vV]? and Format: Strict (Took: 504,439.98ms) >-
... (above took 8 minutes)
      INFO [25-02-11 12:52:12:78] -< Begin: Getting tagged semantic versions on branch 'refs/heads/release/0.13.1'. TagPrefix: [vV]? and Format: Strict >-
      INFO [25-02-11 12:52:14:08] -< End: Getting tagged semantic versions on branch 'refs/heads/release/0.13.1'. TagPrefix: [vV]? and Format: Strict (Took: 1,287.87ms) >-
... (that it takes several minutes in between happens many times for "Getting tagged semantic versions on branch")
        INFO [25-02-11 13:59:19:05] Found merge base of ''dd19d3b' - <redacted>'
        INFO [25-02-11 14:16:49:38] Merge base of 'release/0.11.0-alpha.861' and 'pull/14311/merge' is ''dd19d3b' - <redacted>'
... (another occurrence where the merge base stuff takes several minutes, happens several times following this occurrence)
        INFO [25-02-11 14:54:14:18] Found merge base of ''2a0ef1d' - <redacted>'
        INFO [25-02-11 15:23:55:74] next merge base --> '9f0df83' - <redacted>
... (above is an occurrence where going to the next merge base takes almost 30 minutes)
... (and so on for about 5 hours until the task timed out)

ChristoWolf avatar Feb 13 '25 08:02 ChristoWolf

This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs.

github-actions[bot] avatar May 14 '25 11:05 github-actions[bot]

I moved away from GitVersion, but would still appreciate if someone could take a look.

ChristoWolf avatar May 15 '25 09:05 ChristoWolf

I'm currently experience a similar issue when I tried to switch to gitversion 6. It seems to be caused by a massive RAM consumption of gitversion 6 (more than 24 GB in my case).

ni-jdyffort avatar Jul 15 '25 08:07 ni-jdyffort

Our build server hung and admin found that it was dotnet-gitversion taking 93% of RAM. We have recently upgraded to 6.0.4 from 5.8.2.

sungam3r avatar Aug 04 '25 10:08 sungam3r

This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs.

github-actions[bot] avatar Nov 02 '25 11:11 github-actions[bot]

I'm having similar issues with gitversion 6.3.x - 6.5.x. Runs fine locally but when running via an Azure DevOps agent against the same repo it quickly uses all memory on the agent and then the gitversion process is OOM killed. I've been able to do some tracing and hopefully it may be helpful in determining root cause. I'm not a C# developer but I'd be happy to troubleshoot further if anyone can provide guidance.

Capture trace

I used dotnet-trace collect to capture memory usage details while gitversion was running

dotnet-trace collect --providers Microsoft-Windows-DotNETRuntime:0x1:5 --output /agent/_work/1/a/traces/gitversion-20251121-223818.nettrace -- dotnet-gitversion --roll-forward Major /agent/_work/1/s /output json /l console

This results in an incomplete trace since the OOM killer basically cuts it off without letting it complete normally. Also, here is what the memory situation on the Agent VM looks like right before the OOM kill. I have the same amount of ram on my local machine ~16GB and similar CPU specs.

=== 2025-11-21T22:40:53Z ===
Memory usage:
               total        used        free      shared  buff/cache   available
Mem:            15Gi        15Gi       181Mi        42Mi       326Mi       146Mi
Swap:          4.0Gi       1.8Gi       2.2Gi

Process info:
AzDevOps    4865  0.5  0.1 274266124 31508 ?     Sl   22:38   0:00 dotnet-trace collect --providers Microsoft-Windows-DotNETRuntime:0x1:5 --output /agent/_work/1/a/traces/gitversion-20251121-223818.nettrace -- dotnet-gitversion --roll-forward Major /agent/_work/1/s /output json /l console
AzDevOps    4892 23.5 94.1 274080680 15422388 ?  Rl   22:38   0:36 dotnet-gitversion --roll-forward Major /agent/_work/1/s /output json /l console

Top memory consumers:
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
AzDevOps    4892 23.5 94.1 274080680 15417268 ?  Rl   22:38   0:36 dotnet-gitversion --roll-forward Major /agent/_work/1/s /output json /l console
AzDevOps    4601  4.2  0.6 274699596 103052 ?    Sl   22:37   0:08 /agent/bin/Agent.Worker spawnclient 170 173
AzDevOps    3290  0.2  0.5 274352504 88644 ?     Sl   22:12   0:04 /agent/bin/Agent.Listener run --once
root         196  0.0  0.2 371268 43904 ?        SLsl 22:11   0:00 /sbin/multipathd -d -s
AzDevOps    4865  0.5  0.1 274266124 31508 ?     Sl   22:38   0:00 dotnet-trace collect --providers Microsoft-Windows-DotNETRuntime:0x1:5 --output /agent/_work/1/a/traces/gitversion-20251121-223818.nettrace -- dotnet-gitversion --roll-forward Major /agent/_work/1/s /output json /l console

Analyze trace in PerfView

I then used PerfView to open the trace for analysis. I was able to read the incomplete trace by providing the /continueOnError option

perfview /continueOnError .\gitversion-20251121-223818.nettrace

Navigate to Events

Image

Then select Microsoft-Windows-DotNETRuntime/GC/AllocationTick type events and add a column display filter of AllocationAmount64 TypeName

Image

If I scroll to the end of the trace, I can see where the memory usage explodes during branch analysis.

Image

I've attached a CSV of the full allocation tick dump. Please let me know if there is any other debugging information I can grab to help troubleshoot. Thanks!

gitversion-trace-20251121-223818.csv

sanelson avatar Nov 23 '25 15:11 sanelson