| From: | Ayoub Kazar <kazarayoub2004(at)gmail(dot)com> |
|---|---|
| To: | David Geier <geidav(dot)pg(at)gmail(dot)com> |
| Cc: | KAZAR Ayoub <ma_kazar(at)esi(dot)dz>, Tomas Vondra <tomas(at)vondra(dot)me>, Jakub Wartak <jakub(dot)wartak(at)enterprisedb(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: Add pg_stat_vfdcache view for VFD cache statistics |
| Date: | 2026-09-09 14:27:32 |
| Message-ID: | CADu+CpT7RQRTW9s25xd9QwRS_=y8b8P+T7OfJ986GdDb-MmcmA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Wed, Sep 9, 2026 at 4:06 PM Ayoub Kazar <kazarayoub2004(at)gmail(dot)com> wrote:
> On Wed, Sep 9, 2026 at 9:22 AM David Geier <geidav(dot)pg(at)gmail(dot)com> wrote:
>
>> >>> Yes of course, I’d be happy to take a look.
>> >> Attached is the patch. It's pretty small and passes regress tests.
>> >>
>> > Nice one.
>> > Few comments on it:
>> > #1:
>> > + oldcontext = MemoryContextSwitchTo(VfdCxt);
>> > + newVfdCache = repalloc_array(VfdCache, Vfd, newCacheSize);
>> > + MemoryContextSwitchTo(oldcontext);
>> >
>> > Can't we just do this?
>> > + newVfdCache = repalloc_array(VfdCache, Vfd, newCacheSize);
>> >
>> > because repalloc doesn't need CurrentMemoryContext.
>>
>> Yes. You can then make it even simpler and get rid of newVfdCache via
>>
>> VfdCache = repalloc_array(VfdCache, Vfd, newCacheSize);
>>
> Done. Attached is the change.
>
>> > #2:
>> > + newDescs = MemoryContextAllocExtended(VfdCxt,
>> > + newMax * sizeof(AllocateDesc), MCXT_ALLOC_NO_OOM);
>> > if (newDescs == NULL)
>> > return false;
>> > + memcpy(newDescs, allocatedDescs, maxAllocatedDescs *
>> > sizeof(AllocateDesc));
>> > + pfree(allocatedDescs);
>> >
>> > We can also just replace it with:
>> > + newDescs = repalloc_array_extended(allocatedDescs, AllocateDesc,
>> > + newMax, MCXT_ALLOC_NO_OOM);
>> > Correct?
>>
>> Yes.
>>
>> v7-0001: looks good to me.
>>
>> v7-0003: I'm wondering if we still want cache_bytes in pg_stat_vfdcache,
>> now where it's exposed via pg_backend_memory_contexts. It seems to me
>> that other stats functionality also doesn't expose memory info that is
>> accessible via pg_backend_memory_contexts. But I'm not completely sure
>> what's best here.
>>
> pg_backend_memory_contexts is local to current backend session, so AFAIK
> there's no other way of getting cluster-wide vfd cache memory usage.
> Therefore we need cache_bytes for this?
>
> Regards,
> Ayoub
>
| Attachment | Content-Type | Size |
|---|---|---|
| v7-0001-Vfd-cache-uses-memory-context-instead-of-malloc.patch | text/x-patch | 4.9 KB |
| v7-0003-Add-VFD-cache-footprint-metrics-to-pg_stat_vfdcache.patch | text/x-patch | 17.5 KB |
| v7-0002-Add-pg_stat_vfdcache-view-for-VFD-cache-statistics.patch | text/x-patch | 25.7 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Matthias van de Meent | 2026-09-09 14:30:45 | Re: Reduce build times of pg_trgm GIN indexes |
| Previous Message | Ilia Evdokimov | 2026-09-09 14:22:39 | Re: Improve Hash/Merge Join estimate accuracy when all predicates are Hash/Merge clauses |