Optimize pg_readv/pg_pwritev single vector case.
For the trivial case of iovcnt == 1, kernels are measurably slower at
dealing with the more complex arguments of preadv/pwritev than the
equivalent plain old pread/pwrite. The overheads are worth it for
iovcnt > 1, but for 1 let's just redirect to the cheaper calls. While
we could leave it to callers to worry about that, we already have to
have our own pg_ wrappers for portability reasons so it seems
reasonable to centralize this knowledge there (thanks to Heikki for this
suggestion). Try to avoid function call overheads by making them
inlinable, which might also allow the compiler to avoid the branch in
some cases. For systems that don't have preadv and pwritev (currently:
Windows and [closed] Solaris), we might as well pull the replacement
functions up into the static inline functions too.
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Discussion: https://postgr.es/m/CA+hUKGJkOiOCa+mag4BF+zHo7qo=o9CFheB8=g6uT5TUm2gkvA@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/15c9ac3629936a9bb5010155d3656e913027ccb7
Modified Files
--------------
configure | 22 +------------
configure.ac | 6 ++--
src/include/port/pg_iovec.h | 76 ++++++++++++++++++++++++++++++++++++++++-----
src/port/meson.build | 2 --
src/port/preadv.c | 43 -------------------------
src/port/pwritev.c | 43 -------------------------
src/tools/msvc/Mkvcbuild.pm | 2 +-
7 files changed, 74 insertions(+), 120 deletions(-)