pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Rowley <drowley@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Speedup and increase usability of set proc title functions
Date: Mon, 20 Feb 2023 03:18:58 +0000
Message-ID: <E1pTwhe-0021TP-21@gemulon.postgresql.org> (raw)

Speedup and increase usability of set proc title functions

The setting of the process title could be seen on profiles of very
fast-to-execute queries.  In many locations where we call
set_ps_display() we pass along a string constant, the length of which is
known during compilation.  Here we effectively rename set_ps_display() to
set_ps_display_with_len() and then add a static inline function named
set_ps_display() which calls strlen() on the given string.  This allows
the compiler to optimize away the strlen() call when dealing with
call sites passing a string constant.  We can then also use memcpy()
instead of strlcpy() to copy the string into the destination buffer.
That's significantly faster than strlcpy's byte-at-a-time way of
copying.

Here we also take measures to improve some code which was adjusting the
process title to add a " waiting" suffix to it.  Call sites which require
this can now just call set_ps_display_suffix() to add or adjust the suffix
and call set_ps_display_remove_suffix() to remove it again.

Reviewed-by: Andres Freund
Discussion: https://postgr.es/m/CAApHDvocBvvk-0gWNA2Gohe+sv9fMcv+fK_G+siBKJrgDG4O7g@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/2cb82e2acfba069d00c6bd253d58df03d315672a

Modified Files
--------------
src/backend/replication/syncrep.c   |  24 ++----
src/backend/storage/buffer/bufmgr.c |  25 ++----
src/backend/storage/ipc/standby.c   |  27 ++----
src/backend/storage/lmgr/lock.c     |  32 ++------
src/backend/tcop/postgres.c         |  11 ++-
src/backend/utils/misc/ps_status.c  | 158 ++++++++++++++++++++++++++++++++----
src/include/utils/ps_status.h       |  17 +++-
7 files changed, 199 insertions(+), 95 deletions(-)



Message-ID: <E1pTwhe-0021TP-21@gemulon.postgresql.org>
Permalink:  ../E1pTwhe-0021TP-21@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1pTwhe-0021TP-21@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 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: drowley@postgresql.org
  Subject: Re: pgsql: Speedup and increase usability of set proc title functions
  In-Reply-To: <E1pTwhe-0021TP-21@gemulon.postgresql.org>
  References: <E1pTwhe-0021TP-21@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