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: Provide vectored variants of smgrread() and smgrwrite().
Date: Mon, 18 Dec 2023 02:09:03 +0000
Message-ID: <E1rF342-00AhnX-NB@gemulon.postgresql.org> (raw)

Provide vectored variants of smgrread() and smgrwrite().

smgrreadv() and smgrwritev() and their md.c implementations call
FileReadV() and FileWriteV().  A range of disk blocks beginning at
'blocknum' and extending for 'nblocks' can be scattered to or gathered
from multiple buffers with a single system call.  The traditional
smgrread() and smgrwrite() functions are implemented in terms of the new
functions.

Later commits will introduce calls with nblocks > 1, but the following
behavioral changes can be seen already:

* After a short transfer we'll now retry until we eventually read 0
  bytes (= EOF) or get ENOSPC, EDQUOT, EFBIG etc, where previously we
  would infer the reason.  Retrying is consistent with xlog.c's
  treatment of large WAL writes, and arguably also xlog.c and fd.c's
  treatment of EINTR.  Arbitrary short returns for larger transfers have
  been observed on several OSes, and might in theory also happen for
  transient reasons with our own pg_p*v() fallback code.

* After unexpected EOF or -1, the error thrown now talks about
  a range even for the single block case, eg "blocks 42..42".

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/4908c5872059c409aa647bcde758dfeffe07996e

Modified Files
--------------
doc/src/sgml/monitoring.sgml    |   4 +-
src/backend/storage/smgr/md.c   | 325 ++++++++++++++++++++++++++++------------
src/backend/storage/smgr/smgr.c |  37 ++---
src/include/storage/md.h        |   9 +-
src/include/storage/smgr.h      |  25 +++-
5 files changed, 279 insertions(+), 121 deletions(-)



Message-ID: <E1rF342-00AhnX-NB@gemulon.postgresql.org>
Permalink:  ../E1rF342-00AhnX-NB@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1rF342-00AhnX-NB@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: Provide vectored variants of smgrread() and smgrwrite().
  In-Reply-To: <E1rF342-00AhnX-NB@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