git-commit-vandalism/xdiff
Stefan Beller 301ef85401 xdiff: reduce indent heuristic overhead
Skip searching for better indentation heuristics if we'd slide a hunk more
than its size. This is the easiest fix proposed in the analysis[1] in
response to a patch that mercurial took for xdiff to limit searching
by a constant. Using a performance test as:

     #!python
     open('a', 'w').write(" \n" * 1000000)
     open('b', 'w').write(" \n" * 1000001)

This patch reduces the execution of "git diff --no-index a b" from
0.70s to 0.31s. However limiting the sliding to the size of the diff hunk,
which was proposed as a solution (that I found easiest to implement for
now) is not optimal for cases like

     open('a', 'w').write(" \n" * 1000000)
     open('b', 'w').write(" \n" * 2000000)

as then we'd still slide 1000000 times.

In addition to limiting the sliding to size of the hunk, also limit by a
constant. Choose 100 lines as the constant as that fits more than a screen,
which really means that the diff sliding is probably not providing a lot
of benefit anyway.

[1] https://public-inbox.org/git/72ac1ac2-f567-f241-41d6-d0f83072e0b3@alum.mit.edu/

Reported-by: Jun Wu <quark@fb.com>
Analysis-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-08-01 13:36:22 -07:00
..
xdiff.h diff: support anchoring line(s) 2017-11-28 10:40:04 +09:00
xdiffi.c xdiff: reduce indent heuristic overhead 2018-08-01 13:36:22 -07:00
xdiffi.h Replace Free Software Foundation address in license notices 2017-11-09 13:21:21 +09:00
xemit.c xdiff: show non-empty lines before functions with -W 2017-11-21 09:36:06 +09:00
xemit.h Replace Free Software Foundation address in license notices 2017-11-09 13:21:21 +09:00
xhistogram.c
xinclude.h Replace Free Software Foundation address in license notices 2017-11-09 13:21:21 +09:00
xmacros.h Replace Free Software Foundation address in license notices 2017-11-09 13:21:21 +09:00
xmerge.c Replace Free Software Foundation address in license notices 2017-11-09 13:21:21 +09:00
xpatience.c diff: support anchoring line(s) 2017-11-28 10:40:04 +09:00
xprepare.c Replace Free Software Foundation address in license notices 2017-11-09 13:21:21 +09:00
xprepare.h Replace Free Software Foundation address in license notices 2017-11-09 13:21:21 +09:00
xtypes.h Replace Free Software Foundation address in license notices 2017-11-09 13:21:21 +09:00
xutils.c Merge branch 'jc/ignore-cr-at-eol' 2017-11-27 11:06:31 +09:00
xutils.h Replace Free Software Foundation address in license notices 2017-11-09 13:21:21 +09:00