Subject: [PATCH v2] bloom: ignore renames when computing changed paths

From: "Derrick Stolee via GitGitGadget" <[email-masked]>
Date: Thu, 09 Apr 2020 13:00:11 +0000

From: Derrick Stolee <[email-masked]>

The changed-path Bloom filters record an entry in the filter for
every path that was changed. This includes every add and delete,
regardless of whether a rename was detected. Detecting renames
causes significant performance issues, but also will trigger
downloading missing blobs in partial clone.

The simple fix is to disable rename detection when computing a
changed-path Bloom filter. This should already be disabled by
default, but it is good to explicitly enforce the intended
behavior.

Signed-off-by: Derrick Stolee <[email-masked]>
---
    bloom: ignore renames when computing changed paths
    
    I promised [1] I would adapt the commit that was dropped from
    gs/commit-graph-path-filter [2] on top of gs/commit-graph-path-filter
    and jt/avoid-prefetch-when-able-in-diff. However, I noticed that the
    change was extremely simple and has value without basing it on
    jt/avoid-prefetch-when-able-in-diff.
    
    This change applied to gs/commit-graph-path-filter has obvious CPU time
    improvements for computing changed-path Bloom filters (that I did not
    measure). The partial clone improvements require
    jt/avoid-prefetch-when-able-in-diff to be included, too, but the code
    does not depend on it at compile time.
    
    Thanks, -Stolee
    
    [1] 
    https://lore.kernel.org/git/[email-masked]/
    [2] 
    https://lore.kernel.org/git/5582[email-masked]/

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-601%2Fderrickstolee%2Fdiff-and-bloom-filters-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-601/derrickstolee/diff-and-bloom-filters-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/601

Range-diff vs v1:

 1:  5fae00adcf0 ! 1:  f4df00a0dd4 bloom: ignore renames when computing changed paths
     @@ Commit message
      
          The changed-path Bloom filters record an entry in the filter for
          every path that was changed. This includes every add and delete,
     -    regardless of whther a rename was detected. Detecting renames
     +    regardless of whether a rename was detected. Detecting renames
          causes significant performance issues, but also will trigger
          downloading missing blobs in partial clone.
      
          The simple fix is to disable rename detection when computing a
     -    changed-path Bloom filter.
     +    changed-path Bloom filter. This should already be disabled by
     +    default, but it is good to explicitly enforce the intended
     +    behavior.
      
          Signed-off-by: Derrick Stolee <[email-masked]>

 bloom.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/bloom.c b/bloom.c
index c5b461d1cfe..dd9bab9bbd6 100644
--- a/bloom.c
+++ b/bloom.c
@@ -189,6 +189,7 @@ struct bloom_filter *get_bloom_filter(struct repository *r,
 
 	repo_diff_setup(r, &diffopt);
 	diffopt.flags.recursive = 1;
+	diffopt.detect_rename = 0;
 	diffopt.max_changes = max_changes;
 	diff_setup_done(&diffopt);

base-commit: d5b873c832d832e44523d1d2a9d29afe2b84c84f
-- 
gitgitgadget