Re: Draft for basic NUMA observability

From: Andres Freund <andres(at)anarazel(dot)de>
To: Tomas Vondra <tomas(at)vondra(dot)me>
Cc: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, Jakub Wartak <jakub(dot)wartak(at)enterprisedb(dot)com>, 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-05 23:00:13
Message-ID: insyd7wepk5xn6is5asomhkf6iv2u7ykgpz23lkodibvzyg6hm@zdxkn5nklij7
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2025-04-05 18:29:22 -0400, Andres Freund wrote:
> I think one thing that the docs should mention is that calling the numa
> functions/views will force the pages to be allocated, even if they're
> currently unused.
>
> Newly started server, with s_b of 32GB an 2MB huge pages:
>
> grep ^Huge /proc/meminfo
> HugePages_Total: 34802
> HugePages_Free: 34448
> HugePages_Rsvd: 16437
> HugePages_Surp: 0
> Hugepagesize: 2048 kB
> Hugetlb: 76517376 kB
>
> run
> SELECT node_id, sum(size) FROM pg_shmem_allocations_numa GROUP BY node_id;
>
> Now the pages that previously were marked as reserved are actually allocated:
>
> grep ^Huge /proc/meminfo
> HugePages_Total: 34802
> HugePages_Free: 18012
> HugePages_Rsvd: 1
> HugePages_Surp: 0
> Hugepagesize: 2048 kB
> Hugetlb: 76517376 kB
>
>
> I don't see how we can avoid that right now, but at the very least we ought to
> document it.

The only allocation where that really matters is shared_buffers. I wonder if
we could special case the logic for that, by only probing if at least one of
the buffers in the range is valid.

Then we could treat a page status of -ENOENT as "page is not mapped" and
display NULL for the node_id?

Of course that would mean that we'd always need to
pg_numa_touch_mem_if_required(), not just the first time round, because we
previously might not have for a page that is now valid. But compared to the
cost of actually allocating pages, the cost for that seems small.

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2025-04-05 23:07:19 Re: [PATCH] New predefined role pg_manage_extensions
Previous Message Michael Paquier 2025-04-05 22:42:02 Re: Back-patch of: avoid multiple hard links to same WAL file after a crash