diffcore-rename: compute dir_rename_guess from dir_rename_counts
commit81afdf7a2e625a7ecfb17c00c871b409e853694d
authorElijah Newren <newren@gmail.com>
Sat, 27 Feb 2021 00:30:48 +0000 (27 00:30 +0000)
committerJunio C Hamano <gitster@pobox.com>
Sat, 27 Feb 2021 01:53:12 +0000 (26 17:53 -0800)
tree7dc93e3657d50f38e6a0e8441f46b2ca68015701
parent333899e1e3f15010a85588e67a4ef0f664966c44
diffcore-rename: compute dir_rename_guess from dir_rename_counts

dir_rename_counts has a mapping of a mapping, in particular, it has
   old_dir => { new_dir => count }
We want a simple mapping of
   old_dir => new_dir
based on which new_dir had the highest count for a given old_dir.
Compute this and store it in dir_rename_guess.

This is the final piece of the puzzle needed to make our guesses at
which directory files have been moved to when basenames aren't unique.

For the testcases mentioned in commit 557ac0350d ("merge-ort: begin
performance work; instrument with trace2_region_* calls", 2020-10-28),
this change improves the performance as follows:

                            Before                  After
    no-renames:       12.775 s ±  0.062 s    12.596 s ±  0.061 s
    mega-renames:    188.754 s ±  0.284 s   130.465 s ±  0.259 s
    just-one-mega:     5.599 s ±  0.019 s     3.958 s ±  0.010 s

Reviewed-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diffcore-rename.c