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

Re: [RFC PATCH 0/4] name-rev: improve memory usage

From
Jeff King <peff@peff.net>
Date
Mar 1, 2019, 19:39 UTC
Message-ID
<20190301193912.GA28195@sigill.intra.peff.net>
In-Reply-To
<c496ca1a-d493-64cf-9e9d-d1aa189bd33d@gmail.com>
On Fri, Mar 01, 2019 at 08:14:26PM +0100, Alban Gruin wrote:
Show 19 quoted lines
> > diff --git a/builtin/name-rev.c b/builtin/name-rev.c
> > index f1cb45c227..7aaa86f1c0 100644
> > --- a/builtin/name-rev.c
> > +++ b/builtin/name-rev.c
> > @@ -431,6 +431,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
> >  		OPT_END(),
> >  	};
> >  
> > +	save_commit_buffer = 0;
> > +
> [...]
> 
> Unfortunately this does not work in all cases, apparently.  On my git
> copy, I have 3 origins.  If I run this:
> 
> 	git log --graph --oneline --abbrev=-1 -5 | git name-rev --stdin
> 
> With or without your change, it uses 3GB of RAM.  With this series, it
> uses 25MB of RAM.

Sorry if I was unclear. I meant to try that _in addition_ to your changes. It helps by avoiding keeping the useless commit-object buffers in RAM as we traverse. But the most it can save is the total uncompressed bytes of all commit objects. I.e., in git.git:

  $ git cat-file --batch-check='%(objectsize) %(objecttype)' --batch-all-objects |
    grep commit |
    perl -alne '$total += $F[0]; END { print $total }'
  74678114
or around 70MB. In linux.git, it's more like 700MB.

But in your examples, the problem is the inefficiencies in name-rev's algorithm, and you're not actually traversing that many commits. So I think you'd want to turn off save_commit_buffer as an extra patch in your series. It may or not be a big win for any given case, but it's quite easy to do.

-Peff
Previous: Alban Gruin
Message 18 of 18 in “name-rev: improve memory usage”
  1. 0/4 name-rev: improve memory usageAlban Gruin, Mar 1, 2019
  2. 1/4 name-rev: improve name_rev() memory usageAlban Gruin, Mar 1, 2019
  3. Eric SunshineMar 1, 2019
  4. Jeff KingMar 1, 2019
  5. Johannes SchindelinMar 2, 2019
  6. 3/4 name-rev: check if a commit should be named before naming itAlban Gruin, Mar 1, 2019
  7. Eric SunshineMar 1, 2019
  8. Alban GruinMar 1, 2019
  9. Jeff KingMar 1, 2019
  10. 2/4 commit-list: add a function to check if a commit is in a listAlban Gruin, Mar 1, 2019
  11. 4/4 name-rev: avoid naming from a ref if it’s not a descendant of any commitAlban Gruin, Mar 1, 2019
  12. Eric SunshineMar 1, 2019
  13. Christian CouderMar 3, 2019
  14. Christian CouderMar 3, 2019
  15. Alban GruinMar 3, 2019
  16. Jeff KingMar 1, 2019
  17. Alban GruinMar 1, 2019
  18. Jeff KingMar 1, 2019

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.