pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: pgstat: reduce timer overhead by leaving timer running.
Date: Tue, 05 Jul 2022 20:36:37 +0000
Message-ID: <E1o8pHf-001NEM-O3@gemulon.postgresql.org> (raw)

pgstat: reduce timer overhead by leaving timer running.

Previously the timer was enabled whenever there were any pending stats after
executing a statement, just to then be disabled again when not idle
anymore. That lead to an increase in GetCurrentTimestamp() calls from within
timeout.c compared to 14.

To avoid that increase, leave the timer enabled until stats are reported,
rather than until idle. The timer is only disabled once the pending stats have
been reported.

For me this fixes the increase in GetCurrentTimestamp() calls, there now are
fewer calls in 15 than in 14, in the previously slowed down workload.

While at it, also update assertion in pgstat_report_stat() to be more precise.

Author: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/20220616233130.rparivafipt6doj3@alap3.anarazel.de
Backpatch: 15-

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/4a37527fde3c0959475636dcc88c19b7315f891a

Modified Files
--------------
src/backend/tcop/postgres.c         | 48 ++++++++++++++++++++++++-------------
src/backend/utils/activity/pgstat.c |  2 +-
2 files changed, 32 insertions(+), 18 deletions(-)



view thread (2+ messages)

Message-ID: <E1o8pHf-001NEM-O3@gemulon.postgresql.org>
Permalink:  ../E1o8pHf-001NEM-O3@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1o8pHf-001NEM-O3@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: andres@anarazel.de
  Subject: Re: pgsql: pgstat: reduce timer overhead by leaving timer running.
  In-Reply-To: <E1o8pHf-001NEM-O3@gemulon.postgresql.org>
  References: <E1o8pHf-001NEM-O3@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