Re: Setting huge_pages=off when HugePages are allocated in Linux? - Mailing list pgsql-admin

From Alicja Kucharczyk
Subject Re: Setting huge_pages=off when HugePages are allocated in Linux?
Date
Msg-id CAM=sWa7wFBK26fNFsmNdOgH27TgeYfqk=MmTGHCbyfN0VWzQBQ@mail.gmail.com
Whole thread
In response to Re: Setting huge_pages=off when HugePages are allocated in Linux?  (Laurenz Albe <laurenz.albe@cybertec.at>)
List pgsql-admin
śr., 28 sty 2026 o 18:02 Laurenz Albe <laurenz.albe@cybertec.at> napisał(a):
> In the example in this (quite helpful) Cybertec post, 10475 HugePages are allocated. 
> https://www.cybertec-postgresql.com/en/huge-pages-postgresql/
>
> If we set "huge_pages = off" within PG and then restart PG, will Linux see those 10475 HugePages as off-limits to normal 4KiB allocations?

Yes.  That's why it is a good idea to set "huge_pages = on" if you intend to use them with
PostgreSQL.  Otherwise it may happen that PostgreSQL resorts to allocating shared buffers
using normal memory, and your huge pages just sit around and are wasted.

Yours,
Laurenz Albe

I fully agree with Laurenz.

And it’s basically the same story the other way around: if you set huge_pages = on but you reserved too many huge pages, the extra ones will also just sit there unused, i.e. wasted.

What slightly worries me is this line in the docs:
“While we need at least 3170 huge pages in this example, a larger setting would be appropriate if other programs on the machine also need huge pages.”

I get what it’s trying to say (size for all consumers), but it can read a bit like “more is fine”. On a dedicated PostgreSQL server, “more” is usually just wasted memory unless you actually have another hugepage user.

It might be worth adding a short note that unused huge pages don’t get used for regular memory allocations, so it’s best to size them as close to what you need as possible (especially on dedicated servers). 

regards,
A.Kucharczyk

pgsql-admin by date:

Previous
From: Alicja Kucharczyk
Date:
Subject: Re: Setting huge_pages=off when HugePages are allocated in Linux?
Next
From: Ron Johnson
Date:
Subject: Does pg_dump custom format only compress the table data?