From: Jeff King <peff@peff.net>
To: Joey Hess <id@joeyh.name>
Cc: git <git@vger.kernel.org>
Subject: Re: git status OOM on mmap of large file
Date: Thu, 24 Jan 2019 14:18:36 -0500 [thread overview]
Message-ID: <20190124191836.GA31073@sigill.intra.peff.net> (raw)
In-Reply-To: <20190124183810.GC29200@kitenet.net>
On Thu, Jan 24, 2019 at 02:38:10PM -0400, Joey Hess wrote:
> > Just off the top of my head, something like:
> >
> > /* guess that the filtered output will be the same size as the original */
> > hint = len;
> >
> > /* allocate 10% extra in case the clean size is slightly larger */
> > hint *= 1.1;
> >
> > /*
> > * in any case, never go higher than half of core.bigfileThreshold.
> > * We'd like to avoid allocating more bytes than that, and that still
> > * gives us room for our strbuf to preemptively double if our guess is
> > * just a little on the low side.
> > */
> > if (hint > big_file_threshold / 2)
> > hint = big_file_threshold / 2;
> >
> > But to be honest, I have no idea if that would even produce measurable
> > benefits over simply growing the strbuf from scratch (i.e., hint==0).
>
> Half of 512 MB is still quite a lot of memory to default to using in
> this situation. Eg smaller VPS's still often only have a GB or two of ram.
I think you'd want to drop core.bigFileThreshold on such a server, just
because Git will happily keep 2*(bigFileThreshold-1) in memory to do a
diff. But that nit aside...
> 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.
I suppose there's no reason not to proceed with a patch around this.
For most cases it's really only half the solution (since smudging is
going to run into the same problem). But fixing that is quite a bit more
involved, and the change itself will be largely orthogonal.
-Peff
next prev parent reply other threads:[~2019-01-24 19:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-22 22:07 git status OOM on mmap of large file Joey Hess
2019-01-24 0:39 ` brian m. carlson
2019-01-24 12:14 ` Jeff King
2019-01-24 17:05 ` Joey Hess
2019-01-24 12:10 ` Jeff King
2019-01-24 12:54 ` Duy Nguyen
2019-01-24 18:38 ` Joey Hess
2019-01-24 19:18 ` Jeff King [this message]
2019-01-24 19:28 ` Jeff King
2019-01-24 20:36 ` [PATCH] avoid unncessary malloc of whole file size Joey Hess
2019-01-24 21:12 ` Junio C Hamano
2019-01-24 21:18 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190124191836.GA31073@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=id@joeyh.name \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).