Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qbKzl-00Bkq8-SY for pgsql-general@arkaria.postgresql.org; Wed, 30 Aug 2023 13:12:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qbKzj-00H0Xr-Cw for pgsql-general@arkaria.postgresql.org; Wed, 30 Aug 2023 13:12:27 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qbKzj-00H0XW-1R for pgsql-general@lists.postgresql.org; Wed, 30 Aug 2023 13:12:26 +0000 Received: from home.borberg.arvin.dk ([194.45.76.153]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qbKzb-001mwN-A5 for pgsql-general@lists.postgresql.org; Wed, 30 Aug 2023 13:12:25 +0000 Received: from localhost (localhost [127.0.0.1]) by arvin.dk (Postfix) with ESMTP id 45184213E692 for ; Wed, 30 Aug 2023 15:12:15 +0200 (CEST) X-Virus-Scanned: amavisd-new at arvin.dk Received: from arvin.dk ([127.0.0.1]) by localhost (arvinserver4.home.borberg.arvin.dk [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Qn0U53JaE3GS for ; Wed, 30 Aug 2023 15:12:13 +0200 (CEST) Received: from [192.168.1.8] (_gateway [192.168.1.1]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by arvin.dk (Postfix) with ESMTPSA id 8C96E213E698 for ; Wed, 30 Aug 2023 15:12:13 +0200 (CEST) Message-ID: <43ddf925-9c8b-b023-282c-b20e9366077d@arvin.dk> Date: Wed, 30 Aug 2023 15:12:13 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Content-Language: en-US To: pgsql-general@lists.postgresql.org From: Troels Arvin Subject: Calculating vm.nr_hugepages Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello, I'm writing an Ansible play which is to set the correct value for vm.nr_hugepages on Linux servers where I hope to make Postgres make use of huge pages. However, I'm struggling to find the right formula. 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 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). Which formula can I use? It's OK for me for it to be slightly wrong compared to "postgres -C", but if it's wrong, it needs to be slightly higher than what "postgres -C" outputs, so that I'm sure there's enough huge pages for Postgres to be able to use them properly. -- Kind regards, Troels Arvin