<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/xdiff, branch v2.20.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.20.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.20.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2018-11-02T11:43:02Z</updated>
<entry>
<title>xdiff: provide a separate emit callback for hunks</title>
<updated>2018-11-02T11:43:02Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2018-11-02T06:35:01Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=611e42a5980a3a9f8bb3b1b49c1abde63c7a191e'/>
<id>urn:sha1:611e42a5980a3a9f8bb3b1b49c1abde63c7a191e</id>
<content type='text'>
The xdiff library always emits hunk header lines to our callbacks as
formatted strings like "@@ -a,b +c,d @@\n". This is convenient if we're
going to output a diff, but less so if we actually need to compute using
those numbers, which requires re-parsing the line.

In preparation for moving away from this, let's teach xdiff a new
callback function which gets the broken-out hunk information. To help
callers that don't want to use this new callback, if it's NULL we'll
continue to format the hunk header into a string.

Note that this function renames the "outf" callback to "out_line", as
well. This isn't strictly necessary, but helps in two ways:

  1. Now that there are two callbacks, it's nice to use more descriptive
     names.

  2. Many callers did not zero the emit_callback_data struct, and needed
     to be modified to set ecb.out_hunk to NULL. By changing the name of
     the existing struct member, that guarantees that any new callers
     from in-flight topics will break the build and be examined
     manually.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'sb/indent-heuristic-optim'</title>
<updated>2018-08-17T20:09:57Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2018-08-17T20:09:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=791ad494835ac544d9e91573f3a65aeb97d126ed'/>
<id>urn:sha1:791ad494835ac544d9e91573f3a65aeb97d126ed</id>
<content type='text'>
"git diff --indent-heuristic" had a bad corner case performance.

* sb/indent-heuristic-optim:
  xdiff: reduce indent heuristic overhead
</content>
</entry>
<entry>
<title>Merge branch 'sb/histogram-less-memory'</title>
<updated>2018-08-15T22:08:25Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2018-08-15T22:08:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=57fbd8efb0ac6d85bde612eb06b9ff4415e21503'/>
<id>urn:sha1:57fbd8efb0ac6d85bde612eb06b9ff4415e21503</id>
<content type='text'>
"git diff --histogram" had a bad memory usage pattern, which has
been rearranged to reduce the peak usage.

* sb/histogram-less-memory:
  xdiff/histogram: remove tail recursion
  xdiff/xhistogram: move index allocation into find_lcs
  xdiff/xhistogram: factor out memory cleanup into free_index()
  xdiff/xhistogram: pass arguments directly to fall_back_to_classic_diff
</content>
</entry>
<entry>
<title>xdiff: reduce indent heuristic overhead</title>
<updated>2018-08-01T20:36:22Z</updated>
<author>
<name>Stefan Beller</name>
<email>sbeller@google.com</email>
</author>
<published>2018-07-27T22:23:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=301ef8540155316cb87c896866dd1cab3108807b'/>
<id>urn:sha1:301ef8540155316cb87c896866dd1cab3108807b</id>
<content type='text'>
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 &lt;quark@fb.com&gt;
Analysis-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Signed-off-by: Stefan Beller &lt;sbeller@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>xdiff/histogram: remove tail recursion</title>
<updated>2018-07-23T17:12:16Z</updated>
<author>
<name>Stefan Beller</name>
<email>sbeller@google.com</email>
</author>
<published>2018-07-19T22:19:42Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=79cb2ebb92c18af11edf5eea238425d86eef173d'/>
<id>urn:sha1:79cb2ebb92c18af11edf5eea238425d86eef173d</id>
<content type='text'>
When running the same reproduction script as the previous patch,
it turns out the stack is too small, which can be easily avoided.

Signed-off-by: Stefan Beller &lt;sbeller@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>xdiff/xhistogram: move index allocation into find_lcs</title>
<updated>2018-07-19T19:46:03Z</updated>
<author>
<name>Stefan Beller</name>
<email>sbeller@google.com</email>
</author>
<published>2018-07-19T18:56:20Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=64c4e8bccde9d357f6b7adf5277c3157b2bd0d42'/>
<id>urn:sha1:64c4e8bccde9d357f6b7adf5277c3157b2bd0d42</id>
<content type='text'>
This fixes a memory issue when recursing a lot, which can be reproduced as

    seq 1   100000 &gt;one
    seq 1 4 100000 &gt;two
    git diff --no-index --histogram one two

Before this patch, histogram_diff would call itself recursively before
calling free_index, which would mean a lot of memory is allocated during
the recursion and only freed afterwards. By moving the memory allocation
(and its free call) into find_lcs, the memory is free'd before we recurse,
such that memory is reused in the next step of the recursion instead of
using new memory.

This addresses only the memory pressure, not the run time complexity,
that is also awful for the corner case outlined above.

Helpful in understanding the code (in addition to the sparse history of
this file), was https://stackoverflow.com/a/32367597 which reproduces
most of the code comments of the JGit implementation.

Signed-off-by: Stefan Beller &lt;sbeller@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>xdiff/xhistogram: factor out memory cleanup into free_index()</title>
<updated>2018-07-19T19:46:01Z</updated>
<author>
<name>Stefan Beller</name>
<email>sbeller@google.com</email>
</author>
<published>2018-07-19T18:56:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c671d4b5990f07ca40b0914ca9be65c626608fca'/>
<id>urn:sha1:c671d4b5990f07ca40b0914ca9be65c626608fca</id>
<content type='text'>
This will be useful in the next patch as we'll introduce multiple
callers.

Signed-off-by: Stefan Beller &lt;sbeller@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>xdiff/xhistogram: pass arguments directly to fall_back_to_classic_diff</title>
<updated>2018-07-19T19:46:00Z</updated>
<author>
<name>Stefan Beller</name>
<email>sbeller@google.com</email>
</author>
<published>2018-07-19T18:56:18Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=282098506ffb42d151a3c8d324b6b5393a4342a4'/>
<id>urn:sha1:282098506ffb42d151a3c8d324b6b5393a4342a4</id>
<content type='text'>
By passing the 'xpp' and 'env' argument directly to the function
'fall_back_to_classic_diff', we eliminate an occurrence of the 'index'
in histogram_diff, which will prove useful in a bit.

While at it, move it up in the file. This will make the diff of
one of the next patches more legible.

Signed-off-by: Stefan Beller &lt;sbeller@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>xdiff/xdiffi.c: remove unneeded function declarations</title>
<updated>2018-07-17T18:25:31Z</updated>
<author>
<name>Stefan Beller</name>
<email>sbeller@google.com</email>
</author>
<published>2018-07-16T23:05:35Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=21c770b63ea7ddcb6e52527d82089068b33eb9f3'/>
<id>urn:sha1:21c770b63ea7ddcb6e52527d82089068b33eb9f3</id>
<content type='text'>
There is no need to forward-declare these functions, as they are used
after their implementation only.

Signed-off-by: Stefan Beller &lt;sbeller@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>xdiff/xdiff.h: remove unused flags</title>
<updated>2018-07-17T18:25:31Z</updated>
<author>
<name>Stefan Beller</name>
<email>sbeller@google.com</email>
</author>
<published>2018-07-16T23:05:34Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=25790be634afc3eb28a2ba8d0f6579aaab10bc27'/>
<id>urn:sha1:25790be634afc3eb28a2ba8d0f6579aaab10bc27</id>
<content type='text'>
These flags were there since the beginning (3443546f6e (Use a *real*
built-in diff generator, 2006-03-24), but were never used. Remove them.

Signed-off-by: Stefan Beller &lt;sbeller@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
