From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Expand the use of get_dirent_type(), shaving a few calls to stat
Date: Fri, 02 Sep 2022 07:58:32 +0000
Message-ID: <E1oU1ZP-0013Vp-VV@gemulon.postgresql.org> (raw)
Expand the use of get_dirent_type(), shaving a few calls to stat()/lstat()
Several backend-side loops scanning one or more directories with
ReadDir() (WAL segment recycle/removal in xlog.c, backend-side directory
copy, temporary file removal, configuration file parsing, some logical
decoding logic and some pgtz stuff) already know the type of the entry
being scanned thanks to the dirent structure associated to the entry, on
platforms where we know about DT_REG, DT_DIR and DT_LNK to make the
difference between a regular file, a directory and a symbolic link.
Relying on the direct structure of an entry saves a few system calls to
stat() and lstat() in the loops updated here, shaving some code while on
it. The logic of the code remains the same, calling stat() or lstat()
depending on if it is necessary to look through symlinks.
Authors: Nathan Bossart, Bharath Rupireddy
Reviewed-by: Andres Freund, Thomas Munro, Michael Paquier
Discussion: https://postgr.es/m/CALj2ACV8n-J-f=yiLUOx2=HrQGPSOZM3nWzyQQvLPcccPXxEdg@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/bfb9dfd93720098cf8f3e7d802df9b02ebe3dc20
Modified Files
--------------
src/backend/access/heap/rewriteheap.c | 7 +++--
src/backend/access/transam/xlog.c | 26 +++++++++---------
src/backend/replication/logical/snapbuild.c | 6 +++--
src/backend/replication/slot.c | 6 +++--
src/backend/storage/file/copydir.c | 21 +++++----------
src/backend/storage/file/fd.c | 12 +++------
src/backend/utils/misc/guc-file.l | 42 +++++++++++------------------
src/timezone/pgtz.c | 8 ++----
8 files changed, 53 insertions(+), 75 deletions(-)
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: michael@paquier.xyz
Subject: Re: pgsql: Expand the use of get_dirent_type(), shaving a few calls to stat
In-Reply-To: <E1oU1ZP-0013Vp-VV@gemulon.postgresql.org>
References: <E1oU1ZP-0013Vp-VV@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