Re: pg_preadv() and pg_pwritev()
Thomas Munro <thomas.munro@gmail.com>
From: Thomas Munro <thomas.munro@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2020-12-20T03:26:42Z
Lists: pgsql-hackers
Attachments
- v2-0001-Add-pg_preadv-and-pg_pwritev.patch (application/x-patch) patch v2-0001
- v2-0002-Use-vectored-I-O-to-zero-WAL-segments.patch (application/x-patch) patch v2-0002
On Sun, Dec 20, 2020 at 12:34 PM Tom Lane <tgl@sss.pgh.pa.us> wrote: > Thomas Munro <thomas.munro@gmail.com> writes: > > 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. > > In a quick look, seems OK with some nits: Thanks for looking! > 1. port.h cannot assume that <limits.h> has already been included; > nor do I want to fix that by including <limits.h> there. Do we > really need to define a fallback value of IOV_MAX? If so, > maybe the answer is to put the replacement struct iovec and > IOV_MAX in some new header. Ok, I moved all this stuff into port/pg_uio.h. > 2. I'm not really that happy about loading <sys/uio.h> into > every compilation we do, which would be another reason for a > new specialized header that either includes <sys/uio.h> or > provides fallback definitions. Ack. > 3. The patch as given won't prove anything except that the code > compiles. Is it worth fixing at least one code path to make > use of pg_preadv and pg_pwritev, so we can make sure this code > is tested before there's layers of other new code on top? OK, here's a patch to zero-fill fresh WAL segments with pwritev(). I'm drawing a blank on trivial candidate uses for preadv(), without infrastructure from later patches.
Commits
-
Improve our heuristic for selecting PG_SYSROOT on macOS.
- 3934543c2bb0 9.5.25 landed
- fc6d08b27a33 9.6.21 landed
- 5fa060c8f593 10.16 landed
- 046c8facecee 11.11 landed
- f5d044eaeff0 12.6 landed
- f44ae4db5fec 13.2 landed
- 4823621db312 14.0 landed
-
Move our p{read,write}v replacements into their own files.
- 0d56acfbaa79 14.0 landed
-
Don't use elog() in src/port/pwrite.c.
- df10ac625c16 14.0 landed
-
Use vectored I/O to fill new WAL segments.
- ce6a71fa5300 14.0 landed
-
Provide pg_preadv() and pg_pwritev().
- 13a021f3e8c9 14.0 landed