]> git.ipfire.org Git - thirdparty/postgresql.git/commit
pgstat: reduce timer overhead by leaving timer running.
authorAndres Freund <andres@anarazel.de>
Fri, 17 Jun 2022 19:48:34 +0000 (12:48 -0700)
committerAndres Freund <andres@anarazel.de>
Tue, 5 Jul 2022 19:14:53 +0000 (12:14 -0700)
commit4a37527fde3c0959475636dcc88c19b7315f891a
tree693a612efb711d4aa5d7d14e0f7f7c77c7cc75d9
parent5a1ab894f758fae95b8d40fff0b0fa5048b09467
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-
src/backend/tcop/postgres.c
src/backend/utils/activity/pgstat.c