Re: Re: [PATCHES] A patch for xlog.c - Mailing list pgsql-hackers

From Ian Lance Taylor
Subject Re: Re: [PATCHES] A patch for xlog.c
Date
Msg-id sibsrpqt5n.fsf@daffy.airs.com
Whole thread Raw
In response to [PATCHES] A patch for xlog.c  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-hackers
Tom Lane <tgl@sss.pgh.pa.us> writes:

> > Since mmap() is how everybody implements shared libraries,
> 
> Now *there's* a sweeping generalization.  Documentation of this
> claim, please?

I've seen a lot of shared library implementations (I used to be the
GNU binutils maintainer), and Nathan is approximately correct.  Most
ELF systems use a dynamic linker inherited from the original SVR4
implementation, which uses mmap.  You can see this by running strace
on an SVR4 system.  The *BSD and GNU dynamic linker implementations
are of course independently derived, but they use mmap too.

mmap is the natural way to implement ELF style shared libraries.  The
basic operation you have to do is to map the shared library into the
process memory space, and then to process a few relocations.  Mapping
the shared library in can be done either using mmap, or using
open/read/close.  For a large file, mmap is going to be much faster
than open/read/close, because it doesn't require actually reading the
file.

There are, of course, many non-ELF shared libraries implementations.
SVR3 does not use mmap.  SunOS does use mmap (SunOS shared libraries
were taken into SVR4 and the ELF standard).  I don't know offhand
about AIX, Digital Unix, or Windows.

mmap is standardized by the most recent version of POSIX.1.

Ian


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Re: [PATCHES] A patch for xlog.c
Next
From: Bruce Momjian
Date:
Subject: Re: AW: WAL does not recover gracefully from out-of-disk-sp ace