Re: Determine optimal fdatasync/fsync, O_SYNC/O_DSYNC options

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Gaetano Mendola <mendola(at)bigfoot(dot)com>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Determine optimal fdatasync/fsync, O_SYNC/O_DSYNC options
Date: 2004-09-13 21:18:26
Message-ID: 24308.1095110306@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Gaetano Mendola <mendola(at)bigfoot(dot)com> writes:
> Now that the argument is already open, why postgres choose
> on linux fdatasync? I'm understanding from other posts that
> on this platform open_sync is better than fdatasync.

AFAIR, we've seen *one* test from *one* person alleging that.
And it was definitely not that way when we tested the behavior
originally, several releases back. I'd like to see more evidence,
or better some indication that the Linux kernel changed algorithms,
before changing the default.

The tests that started this thread are pretty unconvincing in my eyes,
because they are comparing open_sync against code that fsyncs after each
one-block write. Under those circumstances, *of course* fsync will lose
(or at least do no better), because it's forcing the same number of
writes through a same-or-less-efficient API. The reason that this isn't
a trivial choice is that Postgres doesn't necessarily need to fsync
after every block of WAL. In particular, when doing large transactions
there could be many blocks written between fsyncs, and in that case you
could come out ahead with fsync because the kernel would have more
freedom to schedule disk writes.

So, the only test I put a whole lot of faith in is testing your own
workload on your own Postgres server. But if we want to set up a toy
test program to test this stuff, it's at least got to have an easily
adjustable (and preferably randomizable) distance between fsyncs.

Also, tests on IDE drives have zero credibility to start with, unless
you can convince me you know how to turn off write buffering on the
drive...

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Simon Riggs 2004-09-13 22:07:35 Re: Data Warehouse Reevaluation - MySQL vs Postgres -- merge tables
Previous Message Josh Berkus 2004-09-13 21:15:59 Re: Determine optimal fdatasync/fsync, O_SYNC/O_DSYNC options