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

git-diff memory/speed/disk impacts (was: being nice to patch(1))

From
David Kastrup <dak@gnu.org>
Date
Jul 6, 2007, 15:22 UTC
Message-ID
<864pkha76p.fsf_-_@lola.quinscape.zz>
In-Reply-To
<86644xd7wr.fsf@lola.quinscape.zz>
Some more experiments:
David Kastrup <dak@gnu.org> writes:
Show 37 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>
>>> > >
>>> > > I guess the second choice generally isn't an option, but dammit, 
>>> > > "git-apply" really is the better program here.
>>> > 
>>> > Why not?  git-apply works outside of a git repo ;-)
>>> 
>>> I was more thinking that people are not necessarily willing to install git 
>>> just to get the "git-apply" program..
>>
>> But maybe they would be willing to install git to get that wonderful
>> git-apply program, and that wonderful rename-and-mode-aware
>> git-diff, and the git-merge-file program, all of which can operate
>> outside of a git repository. (Take that, hg!)
>
> 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.
>
> So the usefulness still seems limited, even now that the output format
> of --name-status has been fixed.
>
> Any idea whether this is a bug, sloppy programming, or an inherent
> restriction/necessity?
>
> Also an idea which of the following scenarios would be best for
> catching all of moves/renames/deletes/adds?  Note: any repository is
> strictly throw-away.
>
> Experiments are somewhat time-consuming, so every hunch helps.
>
> a) diff directories outside of git (works, but fatal memory footprint
>                                     for large cases)
> b) diff index against work directory
fatal memory footprint
> c) diff revision against work directory
fatal memory footprint
> d) diff revision against index
does not detect copies/renames
> e) diff revision against revision (works, but high disk footprint and
>                                    likely slower than alternatives)

So it seems like option e) is the only feasible option. In the total numbers, git-add is by far the slowest operation, followed by git-commit. git-diff on revisions is quite fast and with moderate memory footprint.

Committing itself does not seem to add much disk space: adding into the index seems to be the main disk space allocation.

So while the behavior of d) appears puzzling, doing another commit before the diff is cheap, so the motivation for asking people to find out the problems with d) is low for me.

Somewhat dissatisfactory that rewriting my script for using the repository-less variant of git-diff fails for seriously large use cases due to out-of-memory conditions.

I suppose that's life.
-- 
David Kastrup
Previous: David KastrupNext: Linus Torvalds
Message 24 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.