Thread

  1. Re: show size of DSAs and dshash tables in pg_dsm_registry_allocations

    Rahila Syed <rahilasyed90@gmail.com> — 2025-11-27T08:21:39Z

    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