git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git diff too slow for a file

From
SNSungHyun Nam <goweol@gmail.com>
Date
Apr 19, 2010, 00:43 UTC
Message-ID
<4BCBA725.2020307@gmail.com>
In-Reply-To
<4BC9D928.50909@lsrfire.ath.cx>
René Scharfe wrote:
Show 49 quoted lines
> Am 29.03.2010 03:42, schrieb SungHyun Nam:
>> Hello,
>>
>> If I run a attached script for bunzipped attached files, I get:
>> (To reduce size, I removed many lines and bzipped.)
>>
>>      $ ./mk.sh
>>      time diff -u x3 x4>/dev/null 2>&1
>>
>>      real    0m0.011s
>>      user    0m0.000s
>>      sys    0m0.010s
>>
>>      time git diff>/dev/null 2>&1
>>
>>      real    0m0.193s
>>      user    0m0.190s
>>      sys    0m0.000s
>>
>>      $ git version
>>      git version 1.7.0.2.273.gc2413
>>
>>      $ diff --version
>>      diff (GNU diffutils) 2.8.1
>>      ...
>>
>> Well, though the files are ascii file, they includes a random
>> hexa-decimal datas, so that I don't interest the diff result at
>> all.  But the real problem is 'rebasing took so long if the file
>> was changed'.  Because the git tree includes several such a file,
>> if they changed, rebase took some miniutes for every branch.
>> Such a branch includes a few lines of changes for a C source file,
>> though.  Now I'm waiting an hour to finish rebasing all the
>> branches and yet a rebasing script is running... :-(
>
> I can reproduce it; I concatenated your example files five times to get
> meaningful timings (x1 = five times x3, x2 = five times x4).
>
> The difference between GNU diff and git diff is that the latter is trying
> hard to minimize the size of the diff.  Each user of the xdiff library in
> git turns on the XDF_NEED_MINIMAL flag, which makes it very expensive
> (specifically the function xdl_split()).
>
> The following patch is not meant for inclusion, but rather to start a
> dicussion.  Is XDF_NEED_MINIMAL a good default to have?
>
> The patch removes XDF_NEED_MINIMAL and replaces it with XDF_QUICK, with
> reversed meaning.  XDF_QUICK is only set if the new option --quick is
> given, so without it the old behaviour is retained.  Some numbers:
The patch is great for me.  Thanks!

Added 'time git diff --quick' to the mk.sh and ran with a original file (about 180000 lines):

     $ ./mk.sh
     time diff -u x3 x4 >/dev/null 2>&1
     real	0m0.794s
     user	0m0.720s
     sys	0m0.010s
     time git diff >/dev/null 2>&1
     real	0m44.687s
     user	0m44.670s
     sys	0m0.020s
     time git diff --quick >/dev/null 2>&1
     real	0m1.853s
     user	0m1.840s
     sys	0m0.010s

Thanks! namsh

Previous: Junio C Hamano
Message 12 of 12 in “git diff too slow for a file”
  1. SungHyun NamMar 29, 2010
  2. René ScharfeApr 17, 2010
  3. Junio C HamanoApr 17, 2010
  4. René ScharfeApr 18, 2010
  5. Junio C HamanoApr 20, 2010
  6. René ScharfeApr 20, 2010
  7. Junio C HamanoApr 21, 2010
  8. René ScharfeMay 2, 2010
  9. Junio C HamanoMay 2, 2010
  10. René ScharfeMay 4, 2010
  11. Junio C HamanoMay 4, 2010
  12. SungHyun NamApr 19, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.