pgsql: pgstat: reduce timer overhead by leaving timer running.

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: pgstat: reduce timer overhead by leaving timer running.
Date: 2022-07-05 20:36:37
Message-ID: E1o8pHf-001NEL-NW@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(at)anarazel(dot)de>
Discussion: https://postgr.es/m/20220616233130.rparivafipt6doj3@alap3.anarazel.de
Backpatch: 15-

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/056cc366fafa8110f5761a7383ae1cd903dd728c

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

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2022-07-05 22:23:44 pgsql: Tighten pg_upgrade's new check for non-upgradable anyarray usage
Previous Message Andres Freund 2022-07-05 18:33:25 pgsql: expression eval: Fix EEOP_JSON_CONSTRUCTOR and EEOP_JSONEXPR siz