public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce•org>
To: "Stefan-W. Hahn" <stefan.hahn@s-hahn•de>
Cc: git@vger•kernel.org
Subject: Re: [PATCH] Replacing the system call pread() with real mmap().
Date: Sun, 7 Jan 2007 06:24:45 -0500	[thread overview]
Message-ID: <20070107112445.GE10351@spearce.org> (raw)
In-Reply-To: <20070107111712.GB9909@scotty.home>

"Stefan-W. Hahn" <stefan.hahn@s-hahn•de> wrote:
> +# Define NO_PREAD if you have a problem with pread() system call (i.e.
> +# cygwin.dll before v1.5.22). This needs NO_MMAP not to be set, because pread()
> +# is emulated using mmap.

Better to emulate pread using lseek/xread/lseek:

	off_t p = lseek(fd, offset, SEEK_SET);
	xread(fd, buf, count);
	lseek(fd, p, SEEK_SET);

If you look at the history for contrib/mmap.c you will see an
implementation like that before it was called git_mmap().

This works OK in Git as we only ever have one thread, therefore
there is no race condition during the seek/read/seek calls.  Its also
usually faster on platforms like Mac OS X where mmap() is horrible.
If the platform is lacking a good pread() it may also be the case
that it lacks a good mmap(); in this case it would be desirable to
set both NO_MMAP and NO_PREAD.

-- 
Shawn.

  reply	other threads:[~2007-01-07 11:24 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-06 17:03 problem with git clone on cygwin Stefan-W. Hahn
2007-01-06 21:40 ` Juergen Ruehle
     [not found]   ` <20070106215919.GB8041@scotty.home>
2007-01-07  9:30     ` Stefan-W. Hahn
2007-01-07 10:46       ` Juergen Ruehle
2007-01-07 11:21         ` Stefan-W. Hahn
2007-01-07  6:00 ` Shawn O. Pearce
2007-01-07 11:17   ` [PATCH] Replacing the system call pread() with real mmap() Stefan-W. Hahn
2007-01-07 11:24     ` Shawn O. Pearce [this message]
2007-01-07 16:36       ` Stefan-W. Hahn
2007-01-07 17:10         ` Johannes Schindelin
2007-01-07 20:01           ` Stefan-W. Hahn
2007-01-09 18:51         ` [PATCH] Test for failing pread() on cygwin Stefan-W. Hahn
2007-01-09 18:51         ` [PATCH] Replacing the system call pread() with lseek()/xread()/lseek() sequence Stefan-W. Hahn
2007-01-09 20:21           ` Junio C Hamano
2007-01-07 11:18   ` [PATCH] Test for failing pread() on cygwin Stefan-W. Hahn
2007-01-08  0:19     ` Horst H. von Brand
2007-01-08 17:09       ` Stefan-W. Hahn
     [not found] <11683687161816-git-send-email->

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=20070107112445.GE10351@spearce.org \
    --to=spearce@spearce$(echo .)org \
    --cc=git@vger$(echo .)kernel.org \
    --cc=stefan.hahn@s-hahn$(echo .)de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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