| From: | Tomas Vondra <tomas(at)vondra(dot)me> | 
|---|---|
| To: | Jakub Wartak <jakub(dot)wartak(at)enterprisedb(dot)com> | 
| Cc: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> | 
| Subject: | Re: Draft for basic NUMA observability | 
| Date: | 2025-04-03 18:53:57 | 
| Message-ID: | da6a1e68-2acd-4887-bc64-07361571efac@vondra.me | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-hackers | 
On 4/3/25 15:12, Jakub Wartak wrote:
> On Thu, Apr 3, 2025 at 1:52 PM Tomas Vondra <tomas(at)vondra(dot)me> wrote:
> 
>> ...
>>
>> So unless someone can demonstrate a use case where this would matter,
>> I'd not worry about it too much.
> 
> OK, fine for me - just 3 cols for pg_buffercache_numa is fine for me,
> it's just that I don't have cycles left today and probably lack skills
> (i've never dealt with arrays so far) thus it would be slow to get it
> right... but I can pick up anything tomorrow morning.
> 
OK, I took a stab at reworking/simplifying this the way I proposed.
Here's v24 - needs more polishing, but hopefully enough to show what I
had in mind.
It does these changes:
1) Drops 0002 with the pg_buffercache refactoring, because the new view
is not "extending" the existing one.
2) Reworks pg_buffercache_num to return just three columns, bufferid,
page_num and node_id. page_num is a sequence starting from 0 for each
buffer.
3) It now builds an array of records, with one record per buffer/page.
4) I realized we don't really need to worry about buffers_per_page very
much, except for logging/debugging. There's always "at least one page"
per buffer, even if an incomplete one, so we can do this:
os_page_count = NBuffers * Max(1, pages_per_buffer);
and then
  for (i = 0; i < NBuffers; i++)
  {
      for (j = 0; j < Max(1, pages_per_buffer); j++)
      {
          ..
      }
  }
and everything just works fine, I think.
Opinions? I personally find this much cleaner / easier to understand.
regards
-- 
Tomas Vondra
| Attachment | Content-Type | Size | 
|---|---|---|
| v24-0001-Add-support-for-basic-NUMA-awareness.patch | text/x-patch | 22.1 KB | 
| v24-0002-Add-pg_buffercache_numa-view-with-NUMA-node-info.patch | text/x-patch | 20.0 KB | 
| v24-0003-Introduce-pg_shmem_allocations_numa-view.patch | text/x-patch | 16.4 KB | 
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Pavel Stehule | 2025-04-03 18:55:52 | Re: psql suggestion "select <tab>" offers nothing, can we get functions like "\df <tab>" | 
| Previous Message | Alvaro Herrera | 2025-04-03 18:39:18 | Re: Modern SHA2- based password hashes for pgcrypto |