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

Re: being nice to patch(1)

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Jul 6, 2007, 18:08 UTC
Message-ID
<alpine.LFD.0.98.0707061102280.9434@woody.linux-foundation.org>
In-Reply-To
<86644xd7wr.fsf@lola.quinscape.zz>
On Fri, 6 Jul 2007, David Kastrup wrote:
Show 6 quoted lines
> 
> Well, hmph!  I just rewrote my git-diff-using script to not check
> stuff into a throw-away git repository, and guess what: with real-life
> use cases (diffing trees of about 500MB size), git-diff runs out of
> memory (the machine probably has something like 1.5GB of virtual memory
> size) when operating outside of a git repository.

Ok, that's probably some huge memory leak that just doesn't show up with any normal git operations, likely simply because all the normal git operations will have thrown out the case of "identical files" without ever even looking at the file.

I'd guess that when using the diff logic on outside files, we'll read them all in, compare them, and keep them all in memory even though they are identical.

Generally, though, "git diff" has a much higher memory footprint than any normal file-by-file recursive diff, exactly because of the rename logic. An external "diff" won't ever have any reason to keep more than two files in memory at a time, but because git diff does rename and copy detection, it wants to keep the file data in memory over much longer times.

But I bet there is some stupid bug where we just make it much much worse for the "no git tree/index" case, and keep the whole tree in memory or something.

(The same is true of "git apply", btw, for a different reason: because git-apply will refuse to write out partial results in case some later patch fails, git-apply will keep the whole result in memory until the very end, and then do the write-out in one go. Again, that obviously means that it will potentially use a lot more memory than the "one patch at a time" approach that regular "patch" does)

			Linus
Previous: David KastrupNext: Andreas Gruenbacher
Message 25 of 32 in “being nice to patch(1)”
  1. Andrew MortonJul 2, 2007
  2. Linus TorvaldsJul 2, 2007
  3. Andrew MortonJul 2, 2007
  4. Linus TorvaldsJul 2, 2007
  5. Andrew MortonJul 2, 2007
  6. Linus TorvaldsJul 3, 2007
  7. Junio C HamanoJul 3, 2007
  8. Linus TorvaldsJul 3, 2007
  9. Johannes SchindelinJul 3, 2007
  10. Paolo CiarrocchiJul 3, 2007
  11. Johannes SchindelinJul 3, 2007
  12. Theodore TsoJul 3, 2007
  13. Linus TorvaldsJul 3, 2007
  14. Paul EggertJul 3, 2007
  15. Linus TorvaldsJul 3, 2007
  16. Linus TorvaldsJul 3, 2007
  17. David KastrupJul 3, 2007
  18. Johannes SchindelinJul 3, 2007
  19. David KastrupJul 3, 2007
  20. diff --no-index: fix --name-status with added filesJohannes Schindelin, Jul 3, 2007
  21. Johannes SchindelinJul 3, 2007
  22. David KastrupJul 3, 2007
  23. David KastrupJul 6, 2007
  24. git-diff memory/speed/disk impacts (was: being nice to patch(1))David Kastrup, Jul 6, 2007
  25. Linus TorvaldsJul 6, 2007
  26. Andreas GruenbacherJul 3, 2007
  27. Andrew MortonJul 3, 2007
  28. Linus TorvaldsJul 3, 2007
  29. Andreas GruenbacherJul 3, 2007
  30. Andrew MortonJul 3, 2007
  31. Andrew MortonJul 3, 2007
  32. Andrew MortonJul 3, 2007

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.