[PATCH] xdiff: reduce indent heuristic overhead

2018-07-27 Thread Stefan Beller
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(

Re: [PATCH] xdiff: reduce indent heuristic overhead

2018-07-03 Thread Junio C Hamano
Michael Haggerty writes: > So if `N ≫ M`, there is necessarily a lot of repetition among the `N + > M` lines that the hunk could possibly overlay. Specifically, it must > consist of `floor((N + M)/M)` identical copies of the hunk, plus > possibly a few leftover lines constituting the start of ano

Re: [PATCH] xdiff: reduce indent heuristic overhead

2018-07-03 Thread Michael Haggerty
On Mon, Jul 2, 2018 at 7:27 PM Stefan Beller wrote: > On Sun, Jul 1, 2018 at 8:57 AM Michael Haggerty wrote: > [...] > So this suggests to have MAX_BORING to be > "hunk size + some small constant offset" ? That would be my suggestion, yes. There are cases where it will be more expensive than a f

Re: [PATCH] xdiff: reduce indent heuristic overhead

2018-07-02 Thread Stefan Beller
On Sun, Jul 1, 2018 at 8:57 AM Michael Haggerty wrote: > > On 06/29/2018 10:28 PM, Stefan Beller wrote: > > [...] > > Adds some threshold to avoid expensive cases, like: > > > > ``` > > #!python > > open('a', 'w').write(" \n" * 100) > > open('b', 'w').write(" \n" * 101)

Re: [PATCH] xdiff: reduce indent heuristic overhead

2018-07-01 Thread Michael Haggerty
On 06/29/2018 10:28 PM, Stefan Beller wrote: > [...] > Adds some threshold to avoid expensive cases, like: > > ``` > #!python > open('a', 'w').write(" \n" * 100) > open('b', 'w').write(" \n" * 101) > ``` > > The indent heuristic is O(N * 20) (N = 100) for t

Re: [PATCH] xdiff: reduce indent heuristic overhead

2018-06-29 Thread Jun Wu
Excerpts from Stefan Beller's message of 2018-06-29 16:37:41 -0700: > [...] > Jun, Junio > > By changing the authorship we'd want to have a sign off from the original > author, > before applying; in the previous attempt, I was merely taking the code from > mercurial as their copy of xdiff is also

[PATCH] xdiff: reduce indent heuristic overhead

2018-06-29 Thread Stefan Beller
From: Jun Wu This patch was written originally for mercurial at [1], adding a limit on how long we'd be looking for an optimal indent heuristic. Choose the limit high enough to only limit edge cases. Adds some threshold to avoid expensive cases, like: ``` #!python open('a', 'w')

Re: [PATCH] xdiff: reduce indent heuristic overhead

2018-06-29 Thread Junio C Hamano
Stefan Beller writes: > This patch was written originally for mercurial at > https://phab.mercurial-scm.org/rHGc420792217c89622482005c99e959b9071c109c5 > > changeset: 36674:c420792217c8 > user:Jun Wu > date:Sat Mar 03 12:39:11 2018 -0800 > files: mercurial

[PATCH] xdiff: reduce indent heuristic overhead

2018-06-29 Thread Stefan Beller
This patch was written originally for mercurial at https://phab.mercurial-scm.org/rHGc420792217c89622482005c99e959b9071c109c5 changeset: 36674:c420792217c8 user:Jun Wu date:Sat Mar 03 12:39:11 2018 -0800 files: mercurial/thirdparty/xdiff/xdiffi.c descri