pg_preadv() and pg_pwritev() - Mailing list pgsql-hackers

From Thomas Munro
Subject pg_preadv() and pg_pwritev()
Date
Msg-id CA+hUKGJA+u-220VONeoREBXJ9P3S94Y7J+kqCnTYmahvZJwM=g@mail.gmail.com
Whole thread Raw
Responses Re: pg_preadv() and pg_pwritev()
List pgsql-hackers
Hello hackers,

I want to be able to do synchronous vectored file I/O, so I made
wrapper macros for preadv() and pwritev() with fallbacks for systems
that don't have them.  Following the precedent of the pg_pread() and
pg_pwrite() macros, the "pg_" prefix reflects a subtle contract
change: the fallback paths might have the side effect of changing the
file position.

They're non-standard system calls, but the BSDs and Linux have had
them for a long time, and for other systems we can use POSIX
readv()/writev() with an additional lseek().  The worst case is
Windows (and maybe our favourite antique Unix build farm animal?)
which has none of those things, so there is a further fallback to a
loop.  Windows does have ReadFileScatter() and WriteFileGather(), but
those only work for overlapped (= asynchronous), unbuffered, page
aligned access.  They'll very likely be useful for native AIO+DIO
support in the future, but don't fit the bill here.

This is part of a project to consolidate and offload I/O (about which
more soon), but seemed isolated enough to post separately and I guess
it could be independently useful.

Attachment

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: v10 release notes for extended stats
Next
From: Tom Lane
Date:
Subject: Re: pg_preadv() and pg_pwritev()