git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Riesen <fork0@users.sourceforge.net>
To: Git Mailing List <git@vger.kernel.org>
Cc: Junio C Hamano <junkio@cox.net>,
	Linus Torvalds <torvalds@osdl.org>,
	Christopher Faylor <me@cgf.cx>, "H. Peter Anvin" <hpa@zytor.com>
Subject: Re: First cut at git port to Cygwin
Date: Fri, 7 Oct 2005 23:22:50 +0200	[thread overview]
Message-ID: <20051007212250.GA1423@steel.home> (raw)
In-Reply-To: <20051007205450.GA14827@steel.home>

Alex Riesen, Fri, Oct 07, 2005 22:54:50 +0200:
> Linus Torvalds, Fri, Oct 07, 2005 17:34:19 +0200:
> > > it suddenly get worse: now I'm stuck on git-pull.
> > > 
> > > git-merge-index (called at some point by git-pull) maps the index
> > > in, and starts git-merge-one-file for each (or the given) entry in
> > > the index.  git-merge-one-file calls git-update-index, which wants
> > > to update the index. Which doesn't work, because it's locked by
> > > that piece of s$%^.
> > 
> > NOTE! git doesn't use mmap() because it _needs_ to use mmap(), but because 
> > it was simple to do that way, and it's a total idiosyncracy of mine that I 
> > often try to mmap the data. I often also tend to do my own allocators 
> > instead of using malloc() (see my "sparse" project in case you're 
> > interested in other idiosyncracies of mine - macros to do list traversal 
> > etc).
> > 
> > The fact is, "mmap()" isn't really any better than "read()": it has some 
> > advantages wrt memory management for the kernel, which is probably one big 
> > reason why I do it, but quite frankly, if you were to change every single 
> > mmap() to be a "map_file()" instead, and made it optional whether it used 
> > mmap() or "malloc + read()", I personally don't think it would be 
> > horrible.
> > 
> > And it might make things much simpler for portability. The "use mmap" 
> > approach is very much a unixism, particularly the way unix people do it 
> > (mmap followed by close, making the file descriptor "go away"). Sure, 
> > other OS's have mmap too, but I think on them it tends to be less commonly 
> > used.
> 
> "Sounds like a thinly veiled threat or a very effective prodding" 8)
> 

Junio C Hamano, Fri, Oct 07, 2005 23:00:02 +0200:
> Huh?  where is your memcpy?

Unbelievable... I actually tested the change! But not _the_ patch.
Thanks. Next time, hit me :)

---

Make read_cache copy the index into memory, to improve portability on
other OS's which have mmap too, tend to use it less commonly.

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>

diff --git a/read-cache.c b/read-cache.c
--- a/read-cache.c
+++ b/read-cache.c
@@ -497,9 +497,12 @@ int read_cache(void)
 	offset = sizeof(*hdr);
 	for (i = 0; i < active_nr; i++) {
 		struct cache_entry *ce = map + offset;
-		offset = offset + ce_size(ce);
-		active_cache[i] = ce;
+		size_t size = ce_size(ce);
+		struct cache_entry *newce = malloc(size);
+		offset = offset + size;
+		active_cache[i] = memcpy(newce, ce, size);
 	}
+	munmap(map, size);
 	return active_nr;
 
 unmap:

  reply	other threads:[~2005-10-07 21:23 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-29  0:53 First cut at git port to Cygwin H. Peter Anvin
2005-09-29  4:30 ` Junio C Hamano
2005-09-29  5:07   ` H. Peter Anvin
2005-09-29  4:46 ` Martin Langhoff
2005-09-29  5:13   ` Junio C Hamano
2005-09-29  6:19   ` H. Peter Anvin
2005-09-29  8:46 ` Johannes Schindelin
2005-09-29 16:11   ` H. Peter Anvin
2005-09-29 17:25   ` H. Peter Anvin
2005-09-30 10:02 ` Junio C Hamano
2005-09-30 17:01   ` H. Peter Anvin
2005-09-30 19:08     ` H. Peter Anvin
2005-10-04 12:31 ` Alex Riesen
2005-10-04 13:06   ` Alex Riesen
2005-10-04 14:06   ` H. Peter Anvin
2005-10-05  3:15     ` Christopher Faylor
2005-10-04 15:03   ` H. Peter Anvin
2005-10-05  3:16     ` Christopher Faylor
2005-10-05  5:25       ` H. Peter Anvin
2005-10-05 11:24     ` Alex Riesen
2005-10-05 15:46       ` Alex Riesen
2005-10-05 15:54         ` Christopher Faylor
2005-10-05 16:09           ` Davide Libenzi
2005-10-05 16:15             ` Christopher Faylor
2005-10-05 16:23               ` H. Peter Anvin
2005-10-05 16:28                 ` Christopher Faylor
2005-10-05 17:29               ` Davide Libenzi
2005-10-05 19:17           ` Alex Riesen
2005-10-05 20:29             ` Christopher Faylor
2005-10-06  9:05               ` Alex Riesen
2005-10-06 10:07                 ` Alex Riesen
2005-10-07 12:44                   ` Alex Riesen
2005-10-07 15:34                     ` Linus Torvalds
2005-10-07 20:54                       ` Alex Riesen
2005-10-07 21:22                         ` Alex Riesen [this message]
2005-10-07 21:29                           ` Chuck Lever
2005-10-07 21:39                             ` Alex Riesen
2005-10-08 16:11                               ` Linus Torvalds
2005-10-08 17:38                                 ` Elfyn McBratney
2005-10-08 17:43                                 ` Elfyn McBratney
2005-10-08 18:27                                 ` Johannes Schindelin
2005-10-08 18:44                                   ` Junio C Hamano
2005-10-08 19:04                                     ` Johannes Schindelin
2005-10-08 21:10                                       ` Junio C Hamano
2005-10-08 22:06                                         ` Johannes Schindelin
2005-10-10 18:43                                     ` H. Peter Anvin
2005-10-10 19:01                                       ` Johannes Schindelin
2005-10-10 19:26                                         ` H. Peter Anvin
2005-10-10 19:42                                           ` Johannes Schindelin
2005-10-10 20:21                                           ` Junio C Hamano
2005-10-10 20:34                                           ` Junio C Hamano
2005-10-10 20:52                                             ` H. Peter Anvin
2005-10-10 20:27                                         ` Daniel Barkalow
2005-10-08 18:49                                   ` Alex Riesen
2005-10-09 20:40                           ` Commit text BEFORE the dashes (Re: First cut at git port to Cygwin) Matthias Urlichs
     [not found]                         ` <7vfyrdyre5.fsf@assigned-by-dhcp.cox.net>
2005-10-07 23:45                           ` First cut at git port to Cygwin Alex Riesen
2005-10-08  1:00                             ` Elfyn McBratney
2005-10-10 18:45                               ` H. Peter Anvin
2005-10-05 13:16 ` Jonas Fonseca
2005-10-05 13:58   ` Johannes Schindelin
2005-10-05 15:52     ` [PATCH] Fix symbolic ref validation Jonas Fonseca
2005-10-05 16:54       ` 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

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

  git send-email \
    --in-reply-to=20051007212250.GA1423@steel.home \
    --to=fork0@users.sourceforge.net \
    --cc=git@vger.kernel.org \
    --cc=hpa@zytor.com \
    --cc=junkio@cox.net \
    --cc=me@cgf.cx \
    --cc=torvalds@osdl.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).