pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <pgman@candle.pha.pa.us>
To: Ragnar Kjørstad <postgres@ragnark.vestdata.no>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Gaetano Mendola <mendola@bigfoot.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: fsync or fdatasync
Date: Tue, 10 Sep 2002 17:07:30 -0400 (EDT)
Message-ID: <200209102107.g8AL7UN23077@candle.pha.pa.us> (raw)
In-Reply-To: <20020910224830.A30625@vestdata.no>

Ragnar Kjørstad wrote:
> > open_datasync is the first choice if available.
> 
> I assume open_datasync means open with O_SYNC flag..

Yes.

> > > 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.  
> 
> Yes, I see your argument. 
> However, I've just checked the linux-implementation of fsync() and I
> can't really see how it could chew substantial amounts of CPU time. The
> way it works every inode has a list of dirty data buffers - all it does
> it traverse that list and do a write on each. 

Remember we support >15 platforms, and I know there is at least one
(HPUX?) which does the fsync/fdatasync block finding inefficiently. It
may have even been old Linux; I can not remember.

> Anyway - I'm sure this is not enough to convince you, so I'll have to
> set up a test instead. But not tonight.

Again, that is a test case for only one OS.  It is helpful if we are
going to start doing per-OS defaults, which is something we have talked
about.  What would be great is a test program we can run on different
OS's to find out which is more efficient.
> 
> 
> > 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. 
> 
> Well, in theory fsync() will allow the disk to reorder the writes, and
> that should give significantly better performance, because it will
> reduce the required number of seeks. If the WAL is on a seperate spindel
> there will very few seeks in the first place, so there is less to gain,
> but for the case with the WAL on the same disk as something else there
> is probably some gain. But it makes sense to optimize for the
> WAL-on-seperate-disk case...


Remember, in most cases, we are fsync'ing only one block so there is no
_gathering_ to do.


-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073



view thread (26+ messages)  latest in thread

Message-ID: <200209102107.g8AL7UN23077@candle.pha.pa.us>
Permalink:  ../200209102107.g8AL7UN23077@candle.pha.pa.us/
Also on:    postgresql.org/message-id/200209102107.g8AL7UN23077@candle.pha.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: pgman@candle.pha.pa.us, postgres@ragnark.vestdata.no, tgl@sss.pgh.pa.us, mendola@bigfoot.com
  Subject: Re: fsync or fdatasync
  In-Reply-To: <200209102107.g8AL7UN23077@candle.pha.pa.us>
  References: <20020910224830.A30625@vestdata.no> <200209102107.g8AL7UN23077@candle.pha.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