O_DIRECT for relations and SLRUs (Prototype)

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Kevin Grittner <kgrittn(at)gmail(dot)com>
Subject: O_DIRECT for relations and SLRUs (Prototype)
Date: 2019-01-12 04:46:32
Message-ID: 20190112044632.GA21945@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,
(Added Kevin in CC)

There have been over the ages discussions about getting better
O_DIRECT support to close the gap with other players in the database
market, but I have not actually seen on those lists a patch which
makes use of O_DIRECT for relations and SLRUs (perhaps I missed it,
anyway that would most likely conflict now).

Attached is a toy patch that I have begun using for tests in this
area. That's nothing really serious at this stage, but you can use
that if you would like to see the impact of O_DIRECT. Of course,
things get significantly slower. The patch is able to compile, pass
regression tests, and looks stable. So that's usable for experiments.
The patch uses a GUC called direct_io, enabled to true to ease
regression testing when applying it.

Note that pg_attribute_aligned() cannot be used as that's not an
option with clang and a couple of other comilers as far as I know, so
the patch uses a simple set of placeholder buffers large enough to be
aligned with the OS pages, which should be 4k for Linux by the way,
and not set to BLCKSZ, but for WAL's O_DIRECT we don't really care
much with such details.

If there is interest for such things, perhaps we could get a patch
sorted out, with some angles of attack like:
- Move to use of page-aligned buffers for relations and SLRUs.
- Split use of O_DIRECT for SLRU and relations into separate GUCs.
- Perhaps other things.
However this is a large and very controversial topic, and of course
more complex than the experiment attached, still this prototype is fun
to play with.

Thanks for reading!
--
Michael

Attachment Content-Type Size
direct-io-v1.patch text/x-diff 13.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2019-01-12 05:51:22 Re: Early WIP/PoC for inlining CTEs
Previous Message David Steele 2019-01-12 04:15:54 Re: Checksum errors in pg_stat_database