pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Erik Wienhold <ewie@ewie.name>
To: Troels Arvin <troels@arvin.dk>
To: pgsql-general@lists.postgresql.org
Subject: Re: Calculating vm.nr_hugepages
Date: Wed, 30 Aug 2023 16:41:16 +0200 (CEST)
Message-ID: <1985478005.5957.1693406476870@office.mailbox.org> (raw)
In-Reply-To: <43ddf925-9c8b-b023-282c-b20e9366077d@arvin.dk>
References: <43ddf925-9c8b-b023-282c-b20e9366077d@arvin.dk>

> On 30/08/2023 15:12 CEST Troels Arvin <troels@arvin.dk> wrote:
>
> I assume I need to find the same value as I get from running "postgres
> -C shared_memory_size_in_huge_pages". I call that my target value.
> Note: I cannot simply run "postgres -C ...", because I need my Ansible
> play to work against a server where Postgres is running.
>
> I've tried using the formula described at
> https://www.cybertec-postgresql.com/en/huge-pages-postgresql/, but it
> produces a different value than my target:
>
> Using a shared_buffers value of 21965570048, like in Cybertec
> Postgresql's example:
> "postgres ... -C 21965570048B" yields: 10719
> The formula from Cybertec Postgresql says: 10475

Probably because 21965570048B > 20GB.  What does your command look like
exactly?  Why do you use shared_buffers=21965570048B and not 20GB?  The larger
value is quoted in the last section of the linked blog post for pre-15 Postgres
and is the shared memory size that Postgres wants to allocate but fails to do
with shared_buffers=20GB.  The section also provides the formula for manually
calculating vm.nr_hugepages.

> I've also tried doing what ChatGPG suggested:
> Number of Huge Pages when shared_buffers is set to 1 GiB =
> shared_buffers / huge_page_size
>                      = 1073741824 bytes / 2097152 bytes
>                      = 512
> But that's also wrong compared to "postgres -C ..." (which said 542).

The formula from the blog post gives me 513 but it also includes some additional
shared memory for internal stuff.  So 512 is correct when the shared memory size
already includes the overhead for internal stuff.

--
Erik





view thread (3+ messages)

Message-ID: <1985478005.5957.1693406476870@office.mailbox.org>
Permalink:  ../1985478005.5957.1693406476870@office.mailbox.org/
Also on:    postgresql.org/message-id/1985478005.5957.1693406476870@office.mailbox.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: ewie@ewie.name, troels@arvin.dk
  Subject: Re: Calculating vm.nr_hugepages
  In-Reply-To: <1985478005.5957.1693406476870@office.mailbox.org>
  References: <43ddf925-9c8b-b023-282c-b20e9366077d@arvin.dk> <1985478005.5957.1693406476870@office.mailbox.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox