]> git.ipfire.org Git - thirdparty/git.git/commit
diffcore-rename: filter rename_src list when possible
authorElijah Newren <newren@gmail.com>
Sun, 14 Feb 2021 07:35:01 +0000 (07:35 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 16 Feb 2021 02:02:16 +0000 (18:02 -0800)
commit829514c5151deee1b37cdeaf451bf28219602126
tree4c1db09856638b1192df2903d19b20c0e57dfeeb
parentf15eb7c1cf2674df69c1ff8aebdc5536a580c65e
diffcore-rename: filter rename_src list when possible

We have to look at each entry in rename_src a total of rename_dst_nr
times.  When we're not detecting copies, any exact renames or ignorable
rename paths will just be skipped over.  While checking that these can
be skipped over is a relatively cheap check, it's still a waste of time
to do that check more than once, let alone rename_dst_nr times.  When
rename_src_nr is a few thousand times bigger than the number of relevant
sources (such as when cherry-picking a commit that only touched a
handful of files, but from a side of history that has different names
for some high level directories), this time can add up.

First make an initial pass over the rename_src array and move all the
relevant entries to the front, so that we can iterate over just those
relevant entries.

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:       14.119 s ±  0.101 s    13.815 s ±  0.062 s
    mega-renames:   1802.044 s ±  0.828 s  1799.937 s ±  0.493 s
    just-one-mega:    51.391 s ±  0.028 s    51.289 s ±  0.019 s

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