From: | Michael Paquier <michael(at)paquier(dot)xyz> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Expand the use of get_dirent_type(), shaving a few calls to stat |
Date: | 2022-09-02 07:58:32 |
Message-ID: | E1oU1ZP-0013Vp-VV@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
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(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2022-09-02 11:18:21 | Re: pgsql: Remove further unwanted linker flags from perl_embed_ldflags |
Previous Message | Etsuro Fujita | 2022-09-02 07:56:39 | pgsql: Doc: Update struct Trigger definition. |