From: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> |
---|---|
To: | Rahila Syed <rahilasyed90(at)gmail(dot)com> |
Cc: | Tomas Vondra <tomas(at)vondra(dot)me>, Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Improve monitoring of shared memory allocations |
Date: | 2025-05-13 11:04:05 |
Message-ID: | CAA4eK1+GXW4uKzzT45Zd14QKFNQ34wtO7FOUMe2wZvJJONgdmA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, Apr 4, 2025 at 9:15 PM Rahila Syed <rahilasyed90(at)gmail(dot)com> wrote:
>
> Please find attached the patch which removes the changes for non-shared hash tables
> and keeps them for shared hash tables.
>
/* Allocate initial segments */
+ i = 0;
for (segp = hashp->dir; hctl->nsegs < nsegs; hctl->nsegs++, segp++)
{
- *segp = seg_alloc(hashp);
- if (*segp == NULL)
- return false;
+ /* Assign initial segments, which are also pre-allocated */
+ if (hashp->isshared)
+ {
+ *segp = (HASHSEGMENT) HASH_SEGMENT_PTR(hashp, i++);
+ MemSet(*segp, 0, HASH_SEGMENT_SIZE(hashp));
+ }
+ else
+ {
+ *segp = seg_alloc(hashp);
+ i++;
+ }
In the non-shared hash table case, previously, we used to return false
from here when seg_alloc() fails, but now it seems to be proceeding
without returning false. Is there a reason for the same?
> I tested this by running make-check, make-check world and the reproducer script shared
> by David. I also ran pgbench to test creation and expansion of some of the
> shared hash tables.
>
This covers the basic tests for this patch. I think we should do some
low-level testing of both shared and non-shared hash tables by having
a contrib module or such (we don't need to commit such a contrib
module, but it will give us confidence that the low-level data
structure allocation change is thoroughly tested). We also need to
focus on negative tests where there is insufficient memory in the
system.
--
With Regards,
Amit Kapila.
From | Date | Subject | |
---|---|---|---|
Next Message | Fujii Masao | 2025-05-13 11:13:00 | Re: Allow reading LSN written by walreciever, but not flushed yet |
Previous Message | Dilip Kumar | 2025-05-13 10:52:39 | Re: Backward movement of confirmed_flush resulting in data duplication. |