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

Re: git status OOM on mmap of large file

From
Jeff King <peff@peff.net>
Date
Jan 24, 2019, 19:28 UTC
Message-ID
<20190124192831.GA14201@sigill.intra.peff.net>
In-Reply-To
<20190124191836.GA31073@sigill.intra.peff.net>
On Thu, Jan 24, 2019 at 02:18:36PM -0500, Jeff King wrote:
Show 10 quoted lines
> > I did some benchmarking, using cat as the clean filter:
> > [...]
> > From this, it looks like the file has to be quite large before the
> > preallocation makes a sizable improvement to runtime, and the
> > smudge/clean filters have to be used for actual content filtering
> > (not for hash generation purposes as git-annex and git-lfs use it).
> > An unusual edge case I think. So hint == 0 seems fine.
> 
> Thanks for these timings! I agree that "hint == 0" is probably
> reasonable, then.

One other minor point to consider: on some systems over-allocating actually isn't that expensive, because pages are actually allocated until we write to them, and malloc() is perfectly happy to overcommit memory. Your case would only run into problems on Linux when malloc() actually refuses the allocation (so limiting ourselves to "too large but still reasonable" is a valid strategy there).

But I doubt that's something we should be relying on in general. There are many systems that don't overcommit.

-Peff
Previous: Jeff KingNext: Joey Hess
Message 9 of 12 in “git status OOM on mmap of large file”
  1. Joey HessJan 22, 2019
  2. brian m. carlsonJan 24, 2019
  3. Jeff KingJan 24, 2019
  4. Joey HessJan 24, 2019
  5. Jeff KingJan 24, 2019
  6. Duy NguyenJan 24, 2019
  7. Joey HessJan 24, 2019
  8. Jeff KingJan 24, 2019
  9. Jeff KingJan 24, 2019
  10. avoid unncessary malloc of whole file sizeJoey Hess, Jan 24, 2019
  11. Junio C HamanoJan 24, 2019
  12. Jeff KingJan 24, 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.