Skip to content

Commit 169914e

Browse files
committed
Merge branch 'en/ort-perf-batch-11'
Optimize out repeated rename detection in a sequence of mergy operations. * en/ort-perf-batch-11: merge-ort, diffcore-rename: employ cached renames when possible merge-ort: handle interactions of caching and rename/rename(1to1) cases merge-ort: add helper functions for using cached renames merge-ort: preserve cached renames for the appropriate side merge-ort: avoid accidental API mis-use merge-ort: add code to check for whether cached renames can be reused merge-ort: populate caches of rename detection results merge-ort: add data structures for in-memory caching of rename detection t6429: testcases for remembering renames fast-rebase: write conflict state to working tree, index, and HEAD fast-rebase: change assert() to BUG() Documentation/technical: describe remembering renames optimization t6423: rename file within directory that other side renamed
2 parents 4dd75a1 + 25e65b6 commit 169914e

8 files changed

+1804
-37
lines changed

Documentation/technical/remembering-renames.txt

Lines changed: 671 additions & 0 deletions
Large diffs are not rendered by default.

diffcore-rename.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,8 @@ static void update_dir_rename_counts(struct dir_rename_info *info,
568568
static void initialize_dir_rename_info(struct dir_rename_info *info,
569569
struct strintmap *relevant_sources,
570570
struct strintmap *dirs_removed,
571-
struct strmap *dir_rename_count)
571+
struct strmap *dir_rename_count,
572+
struct strmap *cached_pairs)
572573
{
573574
struct hashmap_iter iter;
574575
struct strmap_entry *entry;
@@ -633,6 +634,17 @@ static void initialize_dir_rename_info(struct dir_rename_info *info,
633634
rename_dst[i].p->two->path);
634635
}
635636

637+
/* Add cached_pairs to counts */
638+
strmap_for_each_entry(cached_pairs, &iter, entry) {
639+
const char *old_name = entry->key;
640+
const char *new_name = entry->value;
641+
if (!new_name)
642+
/* known delete; ignore it */
643+
continue;
644+
645+
update_dir_rename_counts(info, dirs_removed, old_name, new_name);
646+
}
647+
636648
/*
637649
* Now we collapse
638650
* dir_rename_count: old_directory -> {new_directory -> count}
@@ -1247,7 +1259,8 @@ static void handle_early_known_dir_renames(struct dir_rename_info *info,
12471259
void diffcore_rename_extended(struct diff_options *options,
12481260
struct strintmap *relevant_sources,
12491261
struct strintmap *dirs_removed,
1250-
struct strmap *dir_rename_count)
1262+
struct strmap *dir_rename_count,
1263+
struct strmap *cached_pairs)
12511264
{
12521265
int detect_rename = options->detect_rename;
12531266
int minimum_score = options->rename_score;
@@ -1363,7 +1376,8 @@ void diffcore_rename_extended(struct diff_options *options,
13631376
/* Preparation for basename-driven matching. */
13641377
trace2_region_enter("diff", "dir rename setup", options->repo);
13651378
initialize_dir_rename_info(&info, relevant_sources,
1366-
dirs_removed, dir_rename_count);
1379+
dirs_removed, dir_rename_count,
1380+
cached_pairs);
13671381
trace2_region_leave("diff", "dir rename setup", options->repo);
13681382

13691383
/* Utilize file basenames to quickly find renames. */
@@ -1560,5 +1574,5 @@ void diffcore_rename_extended(struct diff_options *options,
15601574

15611575
void diffcore_rename(struct diff_options *options)
15621576
{
1563-
diffcore_rename_extended(options, NULL, NULL, NULL);
1577+
diffcore_rename_extended(options, NULL, NULL, NULL, NULL);
15641578
}

diffcore.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ void diffcore_rename(struct diff_options *);
181181
void diffcore_rename_extended(struct diff_options *options,
182182
struct strintmap *relevant_sources,
183183
struct strintmap *dirs_removed,
184-
struct strmap *dir_rename_count);
184+
struct strmap *dir_rename_count,
185+
struct strmap *cached_pairs);
185186
void diffcore_merge_broken(void);
186187
void diffcore_pickaxe(struct diff_options *);
187188
void diffcore_order(const char *orderfile);

0 commit comments

Comments
 (0)