From: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | pg_preadv() and pg_pwritev() |
Date: | 2020-12-19 22:38:51 |
Message-ID: | CA+hUKGJA+u-220VONeoREBXJ9P3S94Y7J+kqCnTYmahvZJwM=g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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 | Content-Type | Size |
---|---|---|
0007-Add-pg_preadv-and-pg_pwritev.patch | application/x-patch | 12.4 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2020-12-19 23:34:17 | Re: pg_preadv() and pg_pwritev() |
Previous Message | Tom Lane | 2020-12-19 20:39:07 | Re: v10 release notes for extended stats |