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

Re: [PATCH] git-svn: make batch mode optional for git-cat-file

From
EWEric Wong <normalperson@yhbt.net>
Date
Sep 23, 2015, 00:13 UTC
Message-ID
<20150923001350.GA22266@dcvr.yhbt.net>
In-Reply-To
<6AE1604EE3EC5F4296C096518C6B77EE5D0FDAB9D6@mail.accesssoftek.com>
Victor Leschuk <vleschuk@accesssoftek.com> wrote:
Show 6 quoted lines
> The thing is that git-cat-file keeps growing during work when running
> in "batch" mode. See the figure attached: it is for cloning a rather
> small repo (1 hour to clone about ~14000 revisions). However the clone
> of a large repo (~280000 revisions) took about 2 weeks and
> git-cat-file has outgrown the parent perl process several times
> (git-cat-file - ~3-4Gb, perl - 400Mb).

Ugh, that sucks. Even the 400Mb size of Perl annoys me greatly and I'd work on fixing it if I had more time.

But I'm completely against adding this parameter to git-svn. git-svn is not the only "cat-file --batch" user, so this option is only hiding problems.

The best choice is to figure out why cat-file is wasting memory.
Disclaimer: I'm no expert on parts of git written in C,
but perhaps the alloc.c interface is why memory keeps growing.
> What was done:
>  * I have run it under valgrind and mtrace and haven't found any memory leaks
>  * Found the source of most number of memory reallocations (batch_object_write() function (strbuf_expand -> realloc)) - tried to make the streambuf object static and avoid reallocs - didn't help
>  * Tried preloading other allocators than standard glibc - no significant difference
A few more questions:
* What is the largest file that existed in that repo?
* Did you try "MALLOC_MMAP_THRESHOLD_" with glibc?
  Perhaps setting that to 131072 will help, that'll force releasing
  larger chunks than that; but it might be moot if alloc.c is
  getting in the way.

If alloc.c is the culprit, I would consider to transparently restart "cat-file --batch" once it grows to a certain size or after a certain number of requests are made to it.

We can probably do this inside "git cat-file" itself without changing any callers by calling execve.

Previous: Junio C HamanoNext: Eric Wong
Message 6 of 10 in “git-svn: make batch mode optional for git-cat-file”
  1. git-svn: make batch mode optional for git-cat-fileVictor Leschuk, Sep 21, 2015
  2. Junio C HamanoSep 21, 2015
  3. Victor LeschukSep 21, 2015
  4. Victor LeschukSep 22, 2015
  5. Junio C HamanoSep 22, 2015
  6. Eric WongSep 23, 2015
  7. Eric WongSep 23, 2015
  8. Victor LeschukSep 23, 2015
  9. Eric WongSep 23, 2015
  10. Victor LeschukOct 11, 2015

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.