Re: show size of DSAs and dshash tables in pg_dsm_registry_allocations - Mailing list pgsql-hackers

From Rahila Syed
Subject Re: show size of DSAs and dshash tables in pg_dsm_registry_allocations
Date
Msg-id CAH2L28tr5q965MbD2TroyTc-Ey+b-z3=3kpWAuGg6w7qQwwChA@mail.gmail.com
Whole thread Raw
In response to show size of DSAs and dshash tables in pg_dsm_registry_allocations  (Nathan Bossart <nathandbossart@gmail.com>)
List pgsql-hackers
Hi,

Thank you for this improvement. I think it will be very helpful to have the ability to
report dsa and dshash memory sizes.  

Please find below a few comments.
 
1. As a result of this change, the following comment in pg_get_dsm_registry_allocations
 is incorrect. 
   /*
                 * Since we can't know the size of DSA/dshash entries without first
                 * attaching to them, return NULL for those.
                 */

2. +
+       LWLockAcquire(&control->lock, LW_SHARED);

The dsa_get_total_size function takes LW_EXCLUSIVE lock for the same purpose.
I wonder why that is the case and whether both should be consistent.

3. +/*
+ * Same as dsa_get_total_size(), but accepts a DSA handle.  The area must have
+ * been created with dsa_create (not dsa_create_in_place).
+ */
+size_t
+dsa_get_total_size_from_handle(dsa_handle handle)

I believe this function will report the size as long as the dsa control structure is
created within a dsm segment, since all dsm segments are tracked by the global list
- dsm_segment_list, regardless of whether the dsa is created with dsa_create or
dsa_create_in_place. In that case, perhaps we should update the comment
above to reflect this.
 
4. Since, with this change, the size column will show memory allocation regardless
of whether it is currently mapped in the local process, I think it would be helpful to add a
boolean column to display the mapped status as a future enhancement.

Thank you,
Rahila Syed

pgsql-hackers by date:

Previous
From: Mahendra Singh Thalor
Date:
Subject: Re: Non-text mode for pg_dumpall
Next
From: Sergei Glukhov
Date:
Subject: Re: Partial hash index is not used for implied qual.