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

absurdly slow git-diff

From
AMAbhijit Menon-Sen <ams@toroid.org>
Date
Nov 7, 2008, 20:01 UTC
Message-ID
<20081107200126.GA20284@toroid.org>

I have a 240k-line file, and I change one character on every sixth line. The resulting diff gives git serious indigestion:

$ git --version git version 1.6.0.3.640.g6331a $ mkdir a; cd a; git init Initialized empty Git repository in /home/ams/a/.git/ $ cp ../1 .; git add 1; git commit -q -m 1 $ cp ../2 1; git add 1; git commit -q -m 2 $ time git show HEAD > x git show HEAD > x 309.88s user 0.46s system 97% cpu 5:17.06 total

(I use commit -q above not only for brevity; for the second commit, calculating the diffstat takes the same five minutes that git show, git log -p, git log --stat etc. all take.)

Note that diff(1) can handle the patch fine:

$ time diff -u ../1 ../2 >/dev/null diff -u ../1 ../2 > /dev/null 0.30s user 0.06s system 69% cpu 0.519 total

If anyone's interested, the files are http://toroid.org/misc/1 and http://toroid.org/misc/2

Does anyone understand why this slowdown might happen or have suggestions about where I should look for it?

Thanks.
-- ams
Next: Mike Hommey
Message 1 of 13 in “absurdly slow git-diff”
  1. Abhijit Menon-SenNov 7, 2008
  2. Mike HommeyNov 7, 2008
  3. Linus TorvaldsNov 7, 2008
  4. Davide LibenziNov 7, 2008
  5. Davide LibenziNov 7, 2008
  6. Linus TorvaldsNov 7, 2008
  7. Davide LibenziNov 7, 2008
  8. Linus TorvaldsNov 7, 2008
  9. Abhijit Menon-SenNov 8, 2008
  10. Junio C HamanoNov 8, 2008
  11. Junio C HamanoNov 8, 2008
  12. Davide LibenziNov 8, 2008
  13. Pierre HabouzitNov 8, 2008

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.