Re: pgsql: Add function to get memory context stats for processes

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Daniel Gustafsson <dgustafsson(at)postgresql(dot)org>, pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: Re: pgsql: Add function to get memory context stats for processes
Date: 2025-04-10 11:42:02
Message-ID: d51172bd4e7f4b07a18a0288ca1b1c28a71a5f6a.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On Tue, 2025-04-08 at 09:10 +0000, Daniel Gustafsson wrote:
> 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.
>
> Discussion: https://postgr.es/m/CAH2L28v8mc9HDt8QoSJ8TRmKau_8FM_HKS41NeO9-6ZAkuZKXw@mail.gmail.com
>
> Details
> -------
> https://git.postgresql.org/pg/commitdiff/042a66291b04f473cbc72f95f07438abd75ae3a9
>
> [from the patch:]
> diff --git a/src/include/storage/procsignal.h b/src/include/storage/procsignal.h
> index 016dfd9b3f6..cfe14631445 100644
> --- a/src/include/storage/procsignal.h
> +++ b/src/include/storage/procsignal.h
> [...]
> +extern dsa_area *area;

This commit causes problems for PostGIS, because the name "area" collides
with a PostGIS object:

postgis_legacy.c:58:28: error: ‘area’ redeclared as different kind of symbol
58 | POSTGIS_DEPRECATE("3.0.0", area)
| ^~~~
postgis_legacy.c:40:15: note: in definition of macro ‘POSTGIS_DEPRECATE’
40 | Datum funcname(PG_FUNCTION_ARGS); \
| ^~~~~~~~
In file included from ../libpgcommon/lwgeom_pg.h:24,
from postgis_legacy.c:37:
/home/laurenz/pg/include/postgresql/server/utils/memutils.h:403:18: note: previous declaration of ‘area’ with type ‘dsa_area *’
403 | extern dsa_area *area;
| ^~~~

Now one can take the position that PostGIS as dependent library hs to
adapt, but I think "area" is too generic a name. Could you envision
renaming the global variable to something like "shm_area"?

Attached is a patch for this change.
I am not wedded to the name at all, it was just the first thing that
popped into my head.

Yours,
Laurenz Albe

Attachment Content-Type Size
v1-0001-Rename-a-global-variable-to-avoid-name-collisions.patch text/x-patch 8.4 KB

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Aleksander Alekseev 2025-04-10 11:48:11 Re: pgsql: Add function to get memory context stats for processes
Previous Message Alexander Korotkov 2025-04-10 08:23:48 Re: pgsql: Use extended stats for precise estimation of bucket size in hash

Browse pgsql-hackers by date

  From Date Subject
Next Message Aleksander Alekseev 2025-04-10 11:48:11 Re: pgsql: Add function to get memory context stats for processes
Previous Message Alexander Korotkov 2025-04-10 11:36:57 Re: Some problems regarding the self-join elimination code