Speeding up slower Git operations
emaste at freebsd.org
Tue May 28 13:43:00 UTC 2019
Microsoft has been putting a lot of work into improving git
performance and scalability with large repositories. A recent
development is the addition of the commit-graph feature, which
caches information about the commit graph and speeds up operations
like determining if a commit is on a specified branch, or obtaining
the commit count.
As an example of the performance gain, the feature's developer reports
that a "git branch --contains" on the Linux kernel went from 76.20s to
0.04s. In my FreeBSD tree "git rev-list HEAD --count" went from an
average of 2.77s wall clock to 0.39s. This operation (rev-list
--count) is interesting as it can serve as a replacement for
monotonically increasing version numbers, and with it executing in
under half a second it seems like it'd be reasonable to add it to
newvers.sh (to bake into uname).
To enable the feature, enable the commitGraph option:
% git config core.commitGraph true
Then populate the commit graph:
% git commit-graph write --reachable
If you try it please reply and let us know how it worked for you.
More information about the freebsd-git