Re: Direct I/O

Thomas Munro <thomas.munro@gmail.com>

From: Thomas Munro <thomas.munro@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Andres Freund <andres@anarazel.de>, Andrew Dunstan <andrew@dunslane.net>, Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>, Christoph Berg <myon@debian.org>, mikael.kjellstrom@gmail.com, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2023-04-15T21:48:58Z
Lists: pgsql-hackers
On Sun, Apr 16, 2023 at 6:19 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> So apparently, the fact that you even get a warning about the
> alignment not being honored is something OpenBSD patched in
> after-the-fact; it's not there in genuine vintage gcc.

Ah, that is an interesting discovery, and indeed kills the configure check idea.

> At this point I agree with Andres that it'd be good enough to
> silence the warning by getting rid of these alignment pragmas
> when the platform lacks O_DIRECT.

Hmm.  My preferred choice would be: accept Mikael's kind offer to
upgrade curculio to a live version, forget about GCC 4.2.1 forever,
and do nothing.  It is a dead parrot.

But if we really want to do something about this, my next preferred
option would be to modify c.h's test to add more conditions, here:

/* GCC, Sunpro and XLC support aligned, packed and noreturn */
#if defined(__GNUC__) || defined(__SUNPRO_C) || defined(__IBMC__)
#define pg_attribute_aligned(a) __attribute__((aligned(a)))
...

Full GCC support including stack objects actually began in 4.6, it
seems.  It might require a bit of research because the GCC-workalikes
including Clang also claim to be certain versions of GCC (for example
I think Clang 7 would be excluded if you excluded GCC 4.2, even though
this particular thing apparently worked fine in Clang 7).  That's my
best idea, ie to actually model the feature history accurately, if we
are suspending disbelief and pretending that it is a reasonable
target.



Commits

  1. Rename hook functions for debug_io_direct to match variable name.

  2. Rename io_direct to debug_io_direct.

  3. Skip the 004_io_direct.pl test if a pre-flight check fails.

  4. Use higher wal_level for 004_io_direct.pl.

  5. Skip \password TAP test on old IPC::Run versions

  6. Add io_direct setting (developer-only).

  7. Introduce PG_IO_ALIGN_SIZE and align all I/O buffers.

  8. Add palloc_aligned() to allow aligned memory allocations

  9. initdb: When running CREATE DATABASE, use STRATEGY = WAL_COPY.