Skip to content

Performance improvements - profiling and simple caching #1838

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

Merged
merged 2 commits into from
Oct 2, 2019
Merged

Performance improvements - profiling and simple caching #1838

merged 2 commits into from
Oct 2, 2019

Conversation

erikbra
Copy link
Contributor

@erikbra erikbra commented Oct 2, 2019

Used the profiler to find hotspots, most were in Regex matching of
commit messages. Added simple static cache to IncrementStrategyFinder.

Runtime halved on medium-sized git codebase (~3 years of history). Same on GitVersion's own codebase.

There are several issues raised concerning performance issues, e.g. #1208, #1066, and more. I am also experiencing issues with a large-ish codebase, so I started looking into it. This one is a low-hanging fruit. Hopefully more to come (e.g. I also suspect that #360 has introduced rather heavy performance issues, but I'll look further into this in a separate PR)

Medium-sized codebase:

before:

       61.21 real        58.71 user         2.26 sys

after:

       29.75 real        29.63 user         0.18 sys

GitVersion codebase:

before:

real	0m2.364s
user	0m2.113s
sys	0m0.262s

after:

real	0m0.968s
user	0m0.869s
sys	0m0.097s

Used the profiler to find hotspots, most were in Regex matching of
commit messages. Added simple static cache to IncrementStrategyFinder.

Runtime halved on medium-sized git codebase (~3 years of history).
@asbjornu
Copy link
Member

asbjornu commented Oct 2, 2019

@erikbra, thank you so much for your time and effort looking into this! Highly appreciated! The AZDO build is failing, though – would you care to look into why?

@erikbra
Copy link
Contributor Author

erikbra commented Oct 2, 2019

Really strange. The build fails only on Linux, and the error is not anywhere near where I've touched:

Mocks/MockRepository.cs(214,16): error CS0104: 'Index' is an ambiguous reference between 'LibGit2Sharp.Index' and 'System.Index' [/home/vsts/work/1/s/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj]
Mocks/MockRepository.cs(7,35): error CS0738: 'MockRepository' does not implement interface member 'IRepository.Index'. 'MockRepository.Index' cannot implement 'IRepository.Index' because it does not have the matching return type of 'Index'. [/home/vsts/work/1/s/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj]

I did try to fix it, even though it's unrelated. Don't have a linux box available right here, and it built on my Mac even before the change. Buut let's see if I nailed it anyway ;)

@erikbra
Copy link
Contributor Author

erikbra commented Oct 2, 2019

Looks like the build error was introduced in master a couple of commits before my PR. But, nevermind, I fixed it in the PR :)

Copy link
Member

@asbjornu asbjornu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic! Thank you so much! 🙏

@asbjornu asbjornu merged commit d8baaa6 into GitTools:master Oct 2, 2019
@erikbra
Copy link
Contributor Author

erikbra commented Oct 2, 2019

Nice build pipeline in Azure DevOps btw... where does the "Release" task put stuff? Is it possible for me to use a pre-release of the GitVersion task in our own DevOps builds? Or is that a manual process? I'm thinking of using something like this in my .yml?

    - task: [email protected]+77
      displayName: Get nuget version
      inputs:
        runtime: 'core'

@erikbra erikbra deleted the feature/performance-improvements branch October 2, 2019 22:08
@arturcic
Copy link
Member

arturcic commented Oct 2, 2019

You have to install https://marketplace.visualstudio.com/items?itemName=gittools.gitversion-preview into your organization in order to use it. This is the preview version we publish on non release version, basically on every not tagged commit

@erikbra
Copy link
Contributor Author

erikbra commented Oct 3, 2019

Thanks, @arturcic . Worked like a charm. And run time on all our builds' GitVersion step is now down from 60-70s to ~20s. Happy, happy!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants