Re: pgsql: Add function to get memory context stats for processes - Mailing list pgsql-committers

From Laurenz Albe
Subject Re: pgsql: Add function to get memory context stats for processes
Date
Msg-id d51172bd4e7f4b07a18a0288ca1b1c28a71a5f6a.camel@cybertec.at
Whole thread Raw
In response to pgsql: Add function to get memory context stats for processes  (Daniel Gustafsson <dgustafsson@postgresql.org>)
Responses Re: pgsql: Add function to get memory context stats for processes
Re: pgsql: Add function to get memory context stats for processes
List pgsql-committers
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

pgsql-committers by date:

Previous
From: Alexander Korotkov
Date:
Subject: Re: pgsql: Use extended stats for precise estimation of bucket size in hash
Next
From: Aleksander Alekseev
Date:
Subject: Re: pgsql: Add function to get memory context stats for processes