Re: mmap for zeroing WAL log

From: Matthew Kirkwood <matthew(at)hairy(dot)beasts(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: mmap for zeroing WAL log
Date: 2001-02-27 22:20:57
Message-ID: Pine.LNX.4.10.10102272159490.5542-100000@sphinx.mythic-beasts.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

On Sat, 24 Feb 2001, Tom Lane wrote:

> >> I am confused why mmap() is better than writing to a real file.
>
> > It isn't, except that it allows to initialise the logfile in
> > one syscall, without first allocating and zeroing (and hence
> > dirtying) 16Mb of memory.
>
> Uh, the existing code does not zero 16Mb of memory... it zeroes
> 8K and then writes that block repeatedly.

See the "one syscall" bit above.

> It's possible that the overhead of a syscall for each 8K block is
> significant,

I had assumed that the overhead would come from synchronous
metadata incurring writes of at least the inode, block bitmap
and probably an indirect block for each syscall.

> but on the other hand writing a block at a time is a heavily used and
> heavily optimized path in all Unixen. It's at least as plausible that
> the mmap-as-source-of-zeroes path will be slower!

Results:

On Linux/ext2, it appears good for a gain of 3-5% for log
creations (via a fairly minimal test program).

On FreeBSD 4.1-RELEASE/ffs (with all of sync/async/softupdates)
it is a couple of percent worse in elapsed time, but consumes
around a third more system CPU time (12sec vs 9sec on one test
system).

I am awaiting numbers from reiserfs but, for now, it looks like
I am far from vindicated.

Matthew.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2001-02-27 22:25:03 Re: mmap for zeroing WAL log
Previous Message Ned Lilly 2001-02-27 22:20:10 Re: Re: Query precompilation? - Off topic

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2001-02-27 22:25:03 Re: mmap for zeroing WAL log
Previous Message Matthew Kirkwood 2001-02-27 21:12:41 Re: Small xlog.c cleanup