From: | Daniel Gustafsson <dgustafsson(at)postgresql(dot)org> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Add function to get memory context stats for processes |
Date: | 2025-04-08 09:10:49 |
Message-ID: | E1u24yn-003Ggy-01@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers pgsql-hackers |
Add function to get memory context stats for processes
This adds a function for retrieving memory context statistics
and information from backends as well as auxiliary processes.
The intended usecase is cluster debugging when under memory
pressure or unanticipated memory usage characteristics.
When calling the function it sends a signal to the specified
process to submit statistics regarding its memory contexts
into dynamic shared memory. Each memory context is returned
in detail, followed by a cumulative total in case the number
of contexts exceed the max allocated amount of shared memory.
Each process is limited to use at most 1Mb memory for this.
A summary can also be explicitly requested by the user, this
will return the TopMemoryContext and a cumulative total of
all lower contexts.
In order to not block on busy processes the caller specifies
the number of seconds during which to retry before timing out.
In the case where no statistics are published within the set
timeout, the last known statistics are returned, or NULL if
no previously published statistics exist. This allows dash-
board type queries to continually publish even if the target
process is temporarily congested. Context records contain a
timestamp to indicate when they were submitted.
Author: Rahila Syed <rahilasyed90(at)gmail(dot)com>
Reviewed-by: Daniel Gustafsson <daniel(at)yesql(dot)se>
Reviewed-by: Andres Freund <andres(at)anarazel(dot)de>
Reviewed-by: Tomas Vondra <tomas(at)vondra(dot)me>
Reviewed-by: Atsushi Torikoshi <torikoshia(at)oss(dot)nttdata(dot)com>
Reviewed-by: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
Reviewed-by: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAH2L28v8mc9HDt8QoSJ8TRmKau_8FM_HKS41NeO9-6ZAkuZKXw@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/042a66291b04f473cbc72f95f07438abd75ae3a9
Modified Files
--------------
doc/src/sgml/func.sgml | 172 +++++++
src/backend/catalog/system_views.sql | 5 +
src/backend/postmaster/autovacuum.c | 4 +
src/backend/postmaster/checkpointer.c | 4 +
src/backend/postmaster/interrupt.c | 4 +
src/backend/postmaster/pgarch.c | 4 +
src/backend/postmaster/startup.c | 4 +
src/backend/postmaster/walsummarizer.c | 4 +
src/backend/storage/ipc/ipci.c | 3 +
src/backend/storage/ipc/procsignal.c | 3 +
src/backend/storage/lmgr/lwlock.c | 2 +
src/backend/storage/lmgr/proc.c | 1 +
src/backend/tcop/postgres.c | 3 +
src/backend/utils/activity/wait_event_names.txt | 1 +
src/backend/utils/adt/mcxtfuncs.c | 426 ++++++++++++++--
src/backend/utils/init/globals.c | 1 +
src/backend/utils/init/postinit.c | 7 +
src/backend/utils/mmgr/mcxt.c | 645 +++++++++++++++++++++++-
src/include/catalog/pg_proc.dat | 10 +
src/include/miscadmin.h | 1 +
src/include/storage/lwlock.h | 2 +
src/include/storage/procsignal.h | 1 +
src/include/utils/memutils.h | 82 +++
src/test/regress/expected/sysviews.out | 19 +
src/test/regress/sql/sysviews.sql | 18 +
src/tools/pgindent/typedefs.list | 4 +
26 files changed, 1385 insertions(+), 45 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Munro | 2025-04-08 09:35:52 | pgsql: Introduce file_copy_method setting. |
Previous Message | Andres Freund | 2025-04-08 06:52:34 | pgsql: Increase BAS_BULKREAD based on effective_io_concurrency |
From | Date | Subject | |
---|---|---|---|
Next Message | Heikki Linnakangas | 2025-04-08 09:21:47 | Re: Move tests of contrib/spi/ out of the core regression tests |
Previous Message | Yuya Watari | 2025-04-08 09:04:16 | Re: [PoC] Reducing planning time when tables have many partitions |