diffcore-rename: reduce jumpiness in progress counters

Inexact rename detection works by comparing all sources to all destinations, computing similarities, and then finding the best matches among those that are sufficiently similar. However, it is preceded by exact rename detection that works by checking if there are files with identical hashes. If exact renames are found, we can exclude some files from inexact rename detection. The inexact rename detection loops over the full set of files, but immediately skips those for which rename_dst[i].is_rename is true and thus doesn't compare any sources to that destination. As such, these paths shouldn't be included in the progress counter. For the eagle eyed, this change hints at an actual optimization -- the first one I presented at Git Merge 2020. I'll be submitting that optimization later, once the basic merge-ort algorithm has merged. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Dec 11, 2020 at 09:08 UTC 81c4bf02964e51d0cde79304794d51da86d23b09
1 file changed +3 -2
diffcore-rename.c
+3 -2
@@ -593,7 +593,7 @@ void diffcore_rename(struct diff_options *options)
593 if (options->show_rename_progress) {
594 progress = start_delayed_progress(
595 _("Performing inexact rename detection"),
596 - (uint64_t)rename_dst_nr * (uint64_t)rename_src_nr);
596 + (uint64_t)num_destinations * (uint64_t)rename_src_nr);
597 }
598
599 mx = xcalloc(st_mult(NUM_CANDIDATE_PER_DST, num_destinations),
@@ -633,7 +633,8 @@ void diffcore_rename(struct diff_options *options)
633 diff_free_filespec_blob(two);
634 }
635 dst_cnt++;
636 - display_progress(progress, (uint64_t)(i+1)*(uint64_t)rename_src_nr);
636 + display_progress(progress,
637 + (uint64_t)dst_cnt * (uint64_t)rename_src_nr);
638 }
639 stop_progress(&progress);
640