pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ragnar Kjørstad <postgres@ragnark.vestdata.no>
Cc: Bruce Momjian <pgman@candle.pha.pa.us>
Cc: Gaetano Mendola <mendola@bigfoot.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: fsync or fdatasync
Date: Tue, 10 Sep 2002 15:17:00 -0400
Message-ID: <21315.1031685420@sss.pgh.pa.us> (raw)
In-Reply-To: <20020910180957.Y24188@vestdata.no>
References: <alil6f$fie$1@news.hub.org>
	<200209101540.g8AFeOo21086@candle.pha.pa.us>
	<20020910180957.Y24188@vestdata.no>

=?iso-8859-1?Q?Ragnar_Kj=F8rstad?= <postgres@ragnark.vestdata.no> writes:
> On Tue, Sep 10, 2002 at 11:40:24AM -0400, Bruce Momjian wrote:
>> We use fdatasync where available, and fsync when it is not.  

> Makes sense.

>> We also use O_SYNC on open if it is available.

s/also/instead/ ... open_datasync is the first choice if available.

> Why? That will slow tings down...

On what evidence do you assert that?

In theory open_datasync can be the fastest alternative for WAL writing,
because it should cause the kernel to force each WAL write() request
down to disk immediately.  fdatasync will result in the same amount of
I/O, but it will also require the kernel to scan its disk cache to see
if there are any other dirty blocks that need to be written.  On many
kernels this check is not very efficient and can chew substantial
amounts of CPU time.  The tradeoff is that open_datasync syncs each WAL
block individually, which is unnecessary if you are committing
multiple blocks worth of WAL entries at once --- but there's no hard
evidence that that slows things down, especially not when the WAL logs
are on their own disk spindle.  Giving the kernel scheduling freedom
for a small number of blocks doesn't help much anyway in that case.

Check the pghackers archives (a year or two back) for lots and lots of
discussion, but I recall we demonstrated that the current default
choices are reasonable for at least some set of Unixen.  If you've got
more information showing that the present default is wrong on some
kernel, let's have it ... but don't waste our time with blanket
assertions that "X is the right (or wrong) choice", because we know
that's not so across all the platforms we support.  We'd not have
bothered with four sync methods if there weren't good evidence that each
is the best available choice on some platforms.

			regards, tom lane



view thread (26+ messages)  latest in thread

Message-ID: <21315.1031685420@sss.pgh.pa.us>
Permalink:  ../21315.1031685420@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/21315.1031685420@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: tgl@sss.pgh.pa.us, postgres@ragnark.vestdata.no, pgman@candle.pha.pa.us, mendola@bigfoot.com
  Subject: Re: fsync or fdatasync
  In-Reply-To: <21315.1031685420@sss.pgh.pa.us>
  References: <alil6f$fie$1@news.hub.org> <200209101540.g8AFeOo21086@candle.pha.pa.us> <20020910180957.Y24188@vestdata.no> <21315.1031685420@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox