O_DIRECT for relations and SLRUs (Prototype) - Mailing list pgsql-hackers

From Michael Paquier
Subject O_DIRECT for relations and SLRUs (Prototype)
Date
Msg-id 20190112044632.GA21945@paquier.xyz
Whole thread Raw
Responses Re: O_DIRECT for relations and SLRUs (Prototype)  (Andrey Borodin <x4mmm@yandex-team.ru>)
Re: O_DIRECT for relations and SLRUs (Prototype)  (Andrey Borodin <x4mmm@yandex-team.ru>)
List 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

pgsql-hackers by date:

Previous
From: David Steele
Date:
Subject: Re: Checksum errors in pg_stat_database
Next
From: Pavel Stehule
Date:
Subject: Re: Early WIP/PoC for inlining CTEs