| From: | Alicja Kucharczyk <zaledwie10minut(at)gmail(dot)com> |
|---|---|
| To: | Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> |
| Cc: | Ron Johnson <ronljohnsonjr(at)gmail(dot)com>, Pgsql-admin <pgsql-admin(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Setting huge_pages=off when HugePages are allocated in Linux? |
| Date: | 2026-01-29 15:09:08 |
| Message-ID: | CAM=sWa7wFBK26fNFsmNdOgH27TgeYfqk=MmTGHCbyfN0VWzQBQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-admin |
śr., 28 sty 2026 o 18:02 Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ron Johnson | 2026-02-02 15:55:31 | Does pg_dump custom format only compress the table data? |
| Previous Message | Alicja Kucharczyk | 2026-01-29 14:57:47 | Re: Setting huge_pages=off when HugePages are allocated in Linux? |