pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Munro <tmunro@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Optimize pg_readv/pg_pwritev single vector case.
Date: Wed, 29 Nov 2023 04:32:26 +0000
Message-ID: <E1r8CFO-007kye-2s@gemulon.postgresql.org> (raw)

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(-)



Message-ID: <E1r8CFO-007kye-2s@gemulon.postgresql.org>
Permalink:  ../E1r8CFO-007kye-2s@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1r8CFO-007kye-2s@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tmunro@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Optimize pg_readv/pg_pwritev single vector case.
  In-Reply-To: <E1r8CFO-007kye-2s@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox