git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Weimer <fw@deneb.enyo.de>
To: git@vger.kernel.org
Subject: Re: comparing file contents in is_exact_match?
Date: Fri, 07 Jul 2006 18:33:13 +0200	[thread overview]
Message-ID: <87k66p8jee.fsf@mid.deneb.enyo.de> (raw)
In-Reply-To: <20060706055729.GA12512@admingilde.org> (Martin Waitz's message of "Thu, 6 Jul 2006 07:57:29 +0200")

* Martin Waitz:

> I created a git repository for my photo collection and then renamed
> some photos (about 600).  Now git status and commit get hit by
> the OOM killer.
>
> The reason for that is that is_exact_match (in diffcore-rename.c) maps
> both the source and destination file into memory and then compares them
> byte for byte.  This is a little bit too much for my little machine.

Uhm, this shouldn't trigger the OOM killer, really.  You already have
physical backing storage for both files, so this shouldn't count
towards the OOM limit.  Ah, diff_populate_filespec has the following:

   s->data = mmap(NULL, s->size, PROT_READ, MAP_PRIVATE, fd, 0);

Perhaps the following patch is in order?  On some systems, MAP_PRIVATE
might guarantee some form of repeatable reads, but I don't think GIT
needs this to guard against concurrent modification.

-- >8 --
diff_populate_filespec: use shared mapping

It seems that on some systems, PROT_READ + MAP_PRIVATE counts towards
the OOM limit, even though no additional backing store is required.
Requesting MAP_SHARED mapping should fix this.

Signed-off-by: Florian Weimer <fw@deneb.enyo.de>
---
 diff.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/diff.c b/diff.c
index 428ff78..2b4367e 100644
--- a/diff.c
+++ b/diff.c
@@ -1007,7 +1007,7 @@ int diff_populate_filespec(struct diff_f
                fd = open(s->path, O_RDONLY);
                if (fd < 0)
                        goto err_empty;
-               s->data = mmap(NULL, s->size, PROT_READ, MAP_PRIVATE, fd, 0);
+               s->data = mmap(NULL, s->size, PROT_READ, MAP_SHARED, fd, 0);
                close(fd);
                if (s->data == MAP_FAILED)
                        goto err_empty;
--
1.4.0

  parent reply	other threads:[~2006-07-07 17:36 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-06  5:57 comparing file contents in is_exact_match? Martin Waitz
2006-07-06  6:20 ` Junio C Hamano
2006-07-06  7:16   ` Martin Waitz
2006-07-06  7:33     ` Junio C Hamano
2006-07-06  7:41       ` Martin Waitz
2006-07-06 17:55       ` Martin Waitz
2006-07-07 16:33 ` Florian Weimer [this message]
2006-07-08  2:50   ` Johannes Schindelin
2006-07-16  9:05     ` Florian Weimer
2006-07-16 14:00       ` Johannes Schindelin
2006-07-16 15:03       ` Yakov Lerner
2006-07-16 22:36         ` Alex Riesen
2006-07-17  5:25           ` Florian Weimer
2006-07-17 12:41             ` Johannes Schindelin
2006-07-17 15:43               ` Linus Torvalds
2006-07-17 16:05                 ` Johannes Schindelin
2006-07-17 17:56                   ` Linus Torvalds
2006-07-17 18:15                     ` Martin Waitz
2006-07-17 20:20                     ` Alex Riesen
2006-07-17 19:37                   ` Geert Bosch
2006-07-17 21:31                     ` Linus Torvalds
2006-07-18  9:38                       ` Yakov Lerner
2006-07-18 10:20                         ` Johannes Schindelin
2006-07-18 15:37                         ` Linus Torvalds
2006-07-18 18:49                           ` Alex Riesen
2006-07-17 16:32               ` Juergen Ruehle
2006-07-17 17:10                 ` Johannes Schindelin
2006-07-17 17:37                   ` Juergen Ruehle
2006-07-17 20:32                 ` Yakov Lerner
2006-07-17 22:43                   ` Juergen Ruehle
2006-07-18  9:15                     ` Yakov Lerner
2006-07-17 12:11           ` Yakov Lerner

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=87k66p8jee.fsf@mid.deneb.enyo.de \
    --to=fw@deneb.enyo.de \
    --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.
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).