pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix performance regression with flush of pending fixed-numbered 2+ messages / 1 participants [nested] [flat]
* pgsql: Fix performance regression with flush of pending fixed-numbered @ 2025-07-27 23:16 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 2+ messages in thread From: Michael Paquier @ 2025-07-27 23:16 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix performance regression with flush of pending fixed-numbered stats The callback added in fc415edf8ca8 used to check if there is any pending data to flush for fixed-numbered statistics, done by looping across all the builtin and custom stats kinds with a call to have_fixed_pending_cb, is proving to able to show in workloads that do not report any stats (read-only, no function calls, no WAL, no IO, etc). The code used in v17 was cheaper than that what HEAD has introduced, relying on three boolean checks for WAL, SLRU and IO stats. This commit switches the code to use a more efficient approach than fc415edf8ca8, with a single boolean flag that can be switched to "true" by any fixed-numbered stats kinds to force pgstat_report_stat() to go through one round of reports. The flag is reset by pgstat_report_stat() once a full round of reports is done. The flag being false means that fixed-numbered stats kinds saw no activity, and that there is no pending data to flush. ac000fca743e took one step in improving the performance by reducing the number of stats kinds that the backend can hold. This commit takes a more drastic step by bringing back the code efficiency to what it was before v18 with a cheap check at the beginning of pgstat_report_stat() for its fast-exit path. The callback have_static_pending_cb is removed as an effect of all that. Reported-by: Andres Freund <andres@anarazel.de> Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com> Discussion: https://postgr.es/m/eb224uegsga2hgq7dfq3ps5cduhpqej7ir2hjxzzozjthrekx5@dysei6buqthe Backpatch-through: 18 Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/13eb6bb76d5de1d5c3ae3a80684e6a0da5314817 Modified Files -------------- src/backend/access/transam/xlog.c | 10 ++++++ src/backend/utils/activity/pgstat.c | 52 +++++++++++------------------ src/backend/utils/activity/pgstat_backend.c | 14 ++------ src/backend/utils/activity/pgstat_io.c | 10 +----- src/backend/utils/activity/pgstat_slru.c | 10 +----- src/backend/utils/activity/pgstat_wal.c | 20 +++++------ src/include/utils/pgstat_internal.h | 34 ++++++++++--------- 7 files changed, 62 insertions(+), 88 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
* pgsql: Fix performance regression with flush of pending fixed-numbered @ 2025-07-27 23:16 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 2+ messages in thread From: Michael Paquier @ 2025-07-27 23:16 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix performance regression with flush of pending fixed-numbered stats The callback added in fc415edf8ca8 used to check if there is any pending data to flush for fixed-numbered statistics, done by looping across all the builtin and custom stats kinds with a call to have_fixed_pending_cb, is proving to able to show in workloads that do not report any stats (read-only, no function calls, no WAL, no IO, etc). The code used in v17 was cheaper than that what HEAD has introduced, relying on three boolean checks for WAL, SLRU and IO stats. This commit switches the code to use a more efficient approach than fc415edf8ca8, with a single boolean flag that can be switched to "true" by any fixed-numbered stats kinds to force pgstat_report_stat() to go through one round of reports. The flag is reset by pgstat_report_stat() once a full round of reports is done. The flag being false means that fixed-numbered stats kinds saw no activity, and that there is no pending data to flush. ac000fca743e took one step in improving the performance by reducing the number of stats kinds that the backend can hold. This commit takes a more drastic step by bringing back the code efficiency to what it was before v18 with a cheap check at the beginning of pgstat_report_stat() for its fast-exit path. The callback have_static_pending_cb is removed as an effect of all that. Reported-by: Andres Freund <andres@anarazel.de> Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com> Discussion: https://postgr.es/m/eb224uegsga2hgq7dfq3ps5cduhpqej7ir2hjxzzozjthrekx5@dysei6buqthe Backpatch-through: 18 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/793928c2d5ac8e60e1e4054fa3b986369777896d Modified Files -------------- src/backend/access/transam/xlog.c | 10 ++++++ src/backend/utils/activity/pgstat.c | 52 +++++++++++------------------ src/backend/utils/activity/pgstat_backend.c | 14 ++------ src/backend/utils/activity/pgstat_io.c | 10 +----- src/backend/utils/activity/pgstat_slru.c | 10 +----- src/backend/utils/activity/pgstat_wal.c | 20 +++++------ src/include/utils/pgstat_internal.h | 34 ++++++++++--------- 7 files changed, 62 insertions(+), 88 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2025-07-27 23:16 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2025-07-27 23:16 pgsql: Fix performance regression with flush of pending fixed-numbered Michael Paquier <michael@paquier.xyz> 2025-07-27 23:16 pgsql: Fix performance regression with flush of pending fixed-numbered Michael Paquier <michael@paquier.xyz>
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