pgsql: Optimize pg_readv/pg_pwritev single vector case.

From: Thomas Munro <tmunro(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Optimize pg_readv/pg_pwritev single vector case.
Date: 2023-11-29 04:32:26
Message-ID: E1r8CFO-007kye-2s@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(at)iki(dot)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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andrew Dunstan 2023-11-29 12:20:59 Re: pgsql: meson: docs: Add {html,man} targets, rename install-doc-*
Previous Message Andres Freund 2023-11-29 02:28:43 Re: pgsql: meson: docs: Add {html,man} targets, rename install-doc-*