Re: We really ought to do something about O_DIRECT and data=journalled on ext4 - Mailing list pgsql-hackers

From Josh Berkus
Subject Re: We really ought to do something about O_DIRECT and data=journalled on ext4
Date
Msg-id 4CF94B2B.7060001@agliodbs.com
Whole thread Raw
In response to Re: We really ought to do something about O_DIRECT and data=journalled on ext4  (Bruce Momjian <bruce@momjian.us>)
Responses Re: We really ought to do something about O_DIRECT and data=journalled on ext4  (Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>)
List pgsql-hackers
All,

So, I've been doing some reading about this issue, and I think
regardless of what other changes we make we should never enable O_DIRECT
automatically on Linux, and it was a mistake for us to do so in the
first place.

First, in the Linux docs for open():

=========

In summary, O_DIRECT is a potentially powerful tool that should be used
with caution.  It is recommended that applications treat use of O_DIRECT
as a performance option which is disabled by default.

=========

Second, Linus has a quote about O_DIRECT that I think should serve as an
indicator to us that directIO will never be beneficial-by-default on
Linux, and might even someday be desupported:

============

The right way to do it is to just not use O_DIRECT.

The whole notion of "direct IO" is totally braindamaged. Just say no.
This is your brain: OThis is your brain on O_DIRECT: .
Any questions?

I should have fought back harder. There really is no valid reason for EVER
using O_DIRECT. You need a buffer whatever IO you do, and it might as well
be the page cache. There are better ways to control the page cache than
play games and think that a page cache isn't necessary.

So don't use O_DIRECT. Use things like madvise() and posix_fadvise()
instead.
    Linus
=============



--                                  -- Josh Berkus                                    PostgreSQL Experts Inc.
                        http://www.pgexperts.com
 


pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: Patch to add a primary key using an existing index
Next
From: Alvaro Herrera
Date:
Subject: Re: Patch to add a primary key using an existing index