Re: Improve monitoring of shared memory allocations

Rahila Syed <rahilasyed90@gmail.com>

From: Rahila Syed <rahilasyed90@gmail.com>
To: Andres Freund <andres@anarazel.de>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2025-03-12T10:46:10Z
Lists: pgsql-hackers

Attachments

Hi Andres,



>> > +             if (hashp->isshared)
>> > +             {
>> > +                     int                     nsegs;
>> > +                     int                     nbuckets;
>> > +                     nsegs = find_num_of_segs(nelem, &nbuckets,
>> hctl->num_partitions, hctl->ssize);
>> > +
>> > +                     curr_offset =  (((char *) hashp->hctl) +
>> sizeof(HASHHDR) + (info->dsize * sizeof(HASHSEGMENT)) +
>> > +                        + (sizeof(HASHBUCKET) * hctl->ssize * nsegs));
>> > +             }
>> > +
>>
>> Why only do this for shared hashtables? Couldn't we allocate the elments
>> together with the rest for non-share hashtables too?
>>
>
>
I have now made the changes uniformly across shared and non-shared hash
tables,
making the code fix look cleaner. I hope this aligns with your suggestions.
Please find attached updated and rebased versions of both patches.

Kindly let me know your views.

Thank you,
Rahila Syed

Commits

  1. Allocate all parts of shmem hash table from a single contiguous area

  2. Improve accounting for PredXactList, RWConflictPool and PGPROC

  3. Improve accounting for memory used by shared hash tables