Skip to content

Improve GitVersion performance #2885

@candritzky

Description

@candritzky

GitVersion unnecessarily slows down the build process on solutions with many projects.

Detailed Description

GitVersion.exe has a performance problem when used in large solutions with several hundred projects.
Even though it takes less than a second for each project, this sums up to a couple of avoidable minutes for each (re-)build.
This is not so much of a problem on a build agent, but it is annoying during local development when the Git history hasn't changed but larger parts of the application need to be built due to my code changes.

Significant overhead is caused by the YamlDotNet library which is used for gitversion_cache and config file parsing.
The deserialization code is pretty slow on the first call ("cold start") for each deserialized type (here: Dictionary<string,string>, see VersionVariables.FromFileInternal and Config, see ConfigSerializer.Read). (Obviously it needs some internal "warmup" and caches the generated deserializers.)

Here's a performance trace (taken with JetBrains dotTrace) that shows how slow e. g. the gitversion_cache file parsing currently is:

image

And here's how fast it could be with some very simple/naive, hand-crafted parsing logic (that currently works only for the simply structured gitversion_cache file):

image

A similar performance hit (> 100 ms) can be seen when parsing the GitVersion Config file.

An additional performance gain seems to be achievable by streamlining the startup procedure (CreateHostBuilder and friends).

Context

Performance improvements are important because I'm slowed by down GitVersion by additional build times during development.
gitversion.exe is executed thousands of times per day and should be strongly optimized performance.

Possible Implementation

Replace YamlDotNet with a faster YAML parser, or find a way to somehow pre-compile the internal setup of its deserializers (optimized for the required data types).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions