]> git.ipfire.org Git - thirdparty/git.git/commit - revision.h
revision.c: use Bloom filters to speed up path based revision walks
authorGarima Singh <garima.singh@microsoft.com>
Mon, 6 Apr 2020 16:59:52 +0000 (16:59 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 6 Apr 2020 18:08:37 +0000 (11:08 -0700)
commita56b9464cd0a49317fafde080ae4e73c5430ac9b
tree73a69c869e0dc5dabc5655940479510fafe09426
parentd38e07b8c44ffdb73e7eba1b7f6a73eb7eb0d5f9
revision.c: use Bloom filters to speed up path based revision walks

Revision walk will now use Bloom filters for commits to speed up
revision walks for a particular path (for computing history for
that path), if they are present in the commit-graph file.

We load the Bloom filters during the prepare_revision_walk step,
currently only when dealing with a single pathspec. Extending
it to work with multiple pathspecs can be explored and built on
top of this series in the future.

While comparing trees in rev_compare_trees(), if the Bloom filter
says that the file is not different between the two trees, we don't
need to compute the expensive diff. This is where we get our
performance gains. The other response of the Bloom filter is '`:maybe',
in which case we fall back to the full diff calculation to determine
if the path was changed in the commit.

We do not try to use Bloom filters when the '--walk-reflogs' option
is specified. The '--walk-reflogs' option does not walk the commit
ancestry chain like the rest of the options. Incorporating the
performance gains when walking reflog entries would add more
complexity, and can be explored in a later series.

Performance Gains:
We tested the performance of `git log -- <path>` on the git repo, the linux
and some internal large repos, with a variety of paths of varying depths.

On the git and linux repos:
- we observed a 2x to 5x speed up.

On a large internal repo with files seated 6-10 levels deep in the tree:
- we observed 10x to 20x speed ups, with some paths going up to 28 times
  faster.

Helped-by: Derrick Stolee <dstolee@microsoft.com
Helped-by: SZEDER Gábor <szeder.dev@gmail.com>
Helped-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Garima Singh <garima.singh@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
bloom.c
bloom.h
revision.c
revision.h