]> git.ipfire.org Git - thirdparty/git.git/commitdiff
rename: bump limit defaults yet again
authorElijah Newren <newren@gmail.com>
Thu, 15 Jul 2021 00:45:24 +0000 (00:45 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 15 Jul 2021 23:54:34 +0000 (16:54 -0700)
These were last bumped in commit 92c57e5c1d29 (bump rename limit
defaults (again), 2011-02-19), and were bumped both because processors
had gotten faster, and because people were getting ugly merges that
caused problems and reporting it to the mailing list (suggesting that
folks were willing to spend more time waiting).

Since that time:
  * Linus has continued recommending kernel folks to set
    diff.renameLimit=0 (maps to 32767, currently)
  * Folks with repositories with lots of renames were happy to set
    merge.renameLimit above 32767, once the code supported that, to
    get correct cherry-picks
  * Processors have gotten faster
  * It has been discovered that the timing methodology used last time
    probably used too large example files.

The last point is probably worth explaining a bit more:

  * The "average" file size used appears to have been average blob size
    in the linux kernel history at the time (probably v2.6.25 or
    something close to it).
  * Since bigger files are modified more frequently, such a computation
    weights towards larger files.
  * Larger files may be more likely to be modified over time, but are
    not more likely to be renamed -- the mean and median blob size
    within a tree are a bit higher than the mean and median of blob
    sizes in the history leading up to that version for the linux
    kernel.
  * The mean blob size in v2.6.25 was half the average blob size in
    history leading to that point
  * The median blob size in v2.6.25 was about 40% of the mean blob size
    in v2.6.25.
  * Since the mean blob size is more than double the median blob size,
    any file as big as the mean will not be compared to any files of
    median size or less (because they'd be more than 50% dissimilar).
  * Since it is the number of files compared that provides the O(n^2)
    behavior, median-sized files should matter more than mean-sized
    ones.

The combined effect of the above is that the file size used in past
calculations was likely about 5x too large.  Combine that with a CPU
performance improvement of ~30%, and we can increase the limits by
a factor of sqrt(5/(1-.3)) = 2.67, while keeping the original stated
time limits.

Keeping the same approximate time limit probably makes sense for
diff.renameLimit (there is no progress feedback in e.g. git log -p),
but the experience above suggests merge.renameLimit could be extended
significantly.  In fact, it probably would make sense to have an
unlimited default setting for merge.renameLimit, but that would
likely need to be coupled with changes to how progress is displayed.
(See https://lore.kernel.org/git/YOx+Ok%2FEYvLqRMzJ@coredump.intra.peff.net/
for details in that area.)  For now, let's just bump the approximate
time limit from 10s to 1m.

(Note: We do not want to use actual time limits, because getting results
that depend on how loaded your system is that day feels bad, and because
we don't discover that we won't get all the renames until after we've
put in a lot of work rather than just upfront telling the user there are
too many files involved.)

Using the original time limit of 2s for diff.renameLimit, and bumping
merge.renameLimit from 10s to 60s, I found the following timings using
the simple script at the end of this commit message (on an AWS c5.xlarge
which reports as "Intel(R) Xeon(R) Platinum 8124M CPU @ 3.00GHz"):

      N   Timing
   1300    1.995s
   7100   59.973s

So let's round down to nice even numbers and bump the limits from
400->1000, and from 1000->7000.

Here is the measure_rename_perf script (adapted from
https://lore.kernel.org/git/20080211113516.GB6344@coredump.intra.peff.net/
in particular to avoid triggering the linear handling from
basename-guided rename detection):

    #!/bin/bash

    n=$1; shift

    rm -rf repo
    mkdir repo && cd repo
    git init -q -b main

    mkdata() {
      mkdir $1
      for i in `seq 1 $2`; do
        (sed "s/^/$i /" <../sample
         echo tag: $1
        ) >$1/$i
      done
    }

    mkdata initial $n
    git add .
    git commit -q -m initial

    mkdata new $n
    git add .
    cd new
    for i in *; do git mv $i $i.renamed; done
    cd ..
    git rm -q -rf initial
    git commit -q -m new

    time git diff-tree -M -l0 --summary HEAD^ HEAD

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/config/diff.txt
Documentation/config/merge.txt
diff.c
merge-ort.c
merge-recursive.c

index d1b5cfa354210883c55ca3fc43e10098f1d3a4a7..32f84838ac1fa7cd54eb0d4a12f280ac4ac6fb87 100644 (file)
@@ -120,7 +120,7 @@ diff.orderFile::
 diff.renameLimit::
        The number of files to consider in the exhaustive portion of
        copy/rename detection; equivalent to the 'git diff' option
-       `-l`.  If not set, the default value is currently 400.  This
+       `-l`.  If not set, the default value is currently 1000.  This
        setting has no effect if rename detection is turned off.
 
 diff.renames::
index 7cd6d7883b6cd0fa6139ce21201fb6e93c444c14..e27cc639447f70b97d911f43dd9e09d11114334a 100644 (file)
@@ -37,7 +37,7 @@ merge.renameLimit::
        rename detection during a merge.  If not specified, defaults
        to the value of diff.renameLimit.  If neither
        merge.renameLimit nor diff.renameLimit are specified,
-       currently defaults to 1000.  This setting has no effect if
+       currently defaults to 7000.  This setting has no effect if
        rename detection is turned off.
 
 merge.renames::
diff --git a/diff.c b/diff.c
index 2454e34cf6db694d8ccf7c36338a014db8fe158e..0244a371d32fe78d9b28b20a01fafa5fba20f238 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -35,7 +35,7 @@
 
 static int diff_detect_rename_default;
 static int diff_indent_heuristic = 1;
-static int diff_rename_limit_default = 400;
+static int diff_rename_limit_default = 1000;
 static int diff_suppress_blank_empty;
 static int diff_use_color_default = -1;
 static int diff_color_moved_default;
index b954f7184a5f56743548326c318773ac487bdc01..8a84375e940aa3710f0c582053d76fafe589d4fe 100644 (file)
@@ -2558,7 +2558,7 @@ static void detect_regular_renames(struct merge_options *opt,
        diff_opts.detect_rename = DIFF_DETECT_RENAME;
        diff_opts.rename_limit = opt->rename_limit;
        if (opt->rename_limit <= 0)
-               diff_opts.rename_limit = 1000;
+               diff_opts.rename_limit = 7000;
        diff_opts.rename_score = opt->rename_score;
        diff_opts.show_rename_progress = opt->show_rename_progress;
        diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;
index 4327e0cfa3314974482005ef22cb2d24f18e5191..f19f8cc37bdf5da04e885a63f251cd3ba85c4a73 100644 (file)
@@ -1879,7 +1879,7 @@ static struct diff_queue_struct *get_diffpairs(struct merge_options *opt,
         */
        if (opts.detect_rename > DIFF_DETECT_RENAME)
                opts.detect_rename = DIFF_DETECT_RENAME;
-       opts.rename_limit = (opt->rename_limit >= 0) ? opt->rename_limit : 1000;
+       opts.rename_limit = (opt->rename_limit >= 0) ? opt->rename_limit : 7000;
        opts.rename_score = opt->rename_score;
        opts.show_rename_progress = opt->show_rename_progress;
        opts.output_format = DIFF_FORMAT_NO_OUTPUT;