Skip to content
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

Caching git heights #801

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Commits on Aug 27, 2020

  1. ## Summary

    Adds caching of git heights. As calculating the height of repositories with large volumes of commits is expensive, caching the git heights can save time in the following circumstances:
    - Repetitive invocations of the `GetBuildVersion` msbuild task- e.g. during `dotnet pack`'ing a project, the `GetBuildVersion` task is invoked four times
    - Incremental versioning- in cases where a cached height is available for older commits, this value will be used avoid the cost of recalculating the entire git height (only new commits will need to be traversed)
    
    The caching behavior is enabled by default but can be opted-out by setting the new `NerdbankGitVersioningUseHeightCache` msbuild property to `false`
    
    ## Testing
    ### Automated testing
    - Verified `GitHeightCache` can serialize + deserialize heights correctly
    - Verified caching has a measurable impact on performance for cases when there are many commits to traverse
    - All existing tests pass
    
    ### Manual testing
    Consumed locally-packed version of `Nerdbank.GitVersioning` in a C# project and added ~1500 commits, verifying:
    - Height caching takes effect on second build, dramatically decreasing build time (~10s -> ~1s)
    - Adding an additional single commit can leverage the cached version for the previous ~1500 commits but adds the latest
    - Setting the `NerdbankGitVersioningUseHeightCache` property to `false` bypasses the caching behavior.
    James Luck committed Aug 27, 2020
    Configuration menu
    Copy the full SHA
    86213c2 View commit details
    Browse the repository at this point in the history
  2. Fixing required documentation errors

    James Luck committed Aug 27, 2020
    Configuration menu
    Copy the full SHA
    e82e23a View commit details
    Browse the repository at this point in the history
  3. Constructor must be public

    James Luck committed Aug 27, 2020
    Configuration menu
    Copy the full SHA
    9251308 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    fad06f0 View commit details
    Browse the repository at this point in the history
  5. Simplifying logic around discarding cache height when base version do…

    …esn't match
    James Luck committed Aug 27, 2020
    Configuration menu
    Copy the full SHA
    3fe9ec6 View commit details
    Browse the repository at this point in the history
  6. Fixing doco issue

    James Luck committed Aug 27, 2020
    Configuration menu
    Copy the full SHA
    234625e View commit details
    Browse the repository at this point in the history
  7. Testing adding a reference to compiler.unsafe to see if it will help …

    …the build along
    James Luck committed Aug 27, 2020
    Configuration menu
    Copy the full SHA
    85eef33 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    7202d1b View commit details
    Browse the repository at this point in the history

Commits on Aug 28, 2020

  1. Fixing a bug that meant the incorrect height would be returned for co…

    …mmits with multiple parents (any cached height would be used and could prevent the relevant commit graph being walked)
    James Luck committed Aug 28, 2020
    Configuration menu
    Copy the full SHA
    670f6e7 View commit details
    Browse the repository at this point in the history

Commits on Sep 2, 2020

  1. Adding support for the single version file scenario- git heights are …

    …now cached on disk next to the `version.json`/ `version.txt` file in order that performance improvements can be seen by multiple projects.
    James Luck committed Sep 2, 2020
    Configuration menu
    Copy the full SHA
    2b58c63 View commit details
    Browse the repository at this point in the history