git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Jan Christoph Uhde <Jan@UhdeJc.com>
Cc: git@vger.kernel.org
Subject: Re: mmap failure in master 1aa69c73577df21f5e37e47cc40cf44fc049121e
Date: Mon, 1 Jun 2020 00:45:11 -0400	[thread overview]
Message-ID: <20200601044511.GA2529317@coredump.intra.peff.net> (raw)
In-Reply-To: <54a3a798-0387-64df-be20-af69db124042@UhdeJc.com>

On Sun, May 31, 2020 at 12:46:30PM +0200, Jan Christoph Uhde wrote:

> lstat("gcc/testsuite/gdc.test/fail_compilation/b3841.d", {st_mode=S_IFREG|0644, st_size=2643, ...}) = 0
> openat(AT_FDCWD, "gcc/testsuite/gdc.test/fail_compilation/b3841.d", O_RDONLY) = 3
> mmap(NULL, 2643, PROT_READ, MAP_PRIVATE, 3, 0) = -1 ENOMEM (Cannot allocate memory)
> openat(AT_FDCWD, "/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
> openat(AT_FDCWD, "/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
> write(2, "fatal: mmap failed: Cannot alloc"..., 43fatal: mmap failed: Cannot allocate memory
> ) = 43

So we open a file in the working tree, and that mmap fails. I guess this
is probably the call to xmmap() in diff_populate_filespec(). That file
isn't particularly large.

Is it possible that your local repository has large number of packs? Git
will leave open maps to each pack's index file, plus some packs
themselves (ones we're accessing, plus we map+close small ones), plus
whatever maps are used by libc to malloc.  The kernel default limit for
the number of maps is 65530. If you have on the order of 30,000 packs
you might run into this limit.

You can check the number of packs with "git count-objects -v", and the
map limit with "sysctl vm.max_map_count".

If that's the problem, the solution is to repack (which should also
generally improve performance). If you have trouble repacking due to the
limits, you can overcome the chicken and egg with:

  sysctl -w vm.max_map_count=131060

-Peff

  reply	other threads:[~2020-06-01  4:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-31 10:46 mmap failure in master 1aa69c73577df21f5e37e47cc40cf44fc049121e Jan Christoph Uhde
2020-06-01  4:45 ` Jeff King [this message]
     [not found]   ` <cfc79aec-ec85-dbec-e37b-6b7035b4c5a4@UhdeJc.com>
2020-06-01 16:54     ` Jeff King
2020-06-01 20:22       ` [PATCH] diff: discard blob data from stat-unmatched pairs Jeff King
2020-06-01 20:53         ` Eric Sunshine
2020-06-02 16:49         ` Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200601044511.GA2529317@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=Jan@UhdeJc.com \
    --cc=git@vger.kernel.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).