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 1qbMNt-00Boac-MJ for pgsql-general@arkaria.postgresql.org; Wed, 30 Aug 2023 14:41:30 +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 1qbMNs-0004ik-Ip for pgsql-general@arkaria.postgresql.org; Wed, 30 Aug 2023 14:41:28 +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 1qbMNs-0004iQ-3h for pgsql-general@lists.postgresql.org; Wed, 30 Aug 2023 14:41:27 +0000 Received: from mout-u-107.mailbox.org ([2001:67c:2050:101:465::107]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qbMNo-001ncR-BU for pgsql-general@lists.postgresql.org; Wed, 30 Aug 2023 14:41:26 +0000 Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-107.mailbox.org (Postfix) with ESMTPS id 4RbRn949tVz9sLw; Wed, 30 Aug 2023 16:41:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ewie.name; s=MBO0001; t=1693406477; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1pBl8koK0Q15Ls8awdXsY9qCjjHNVYig2mkfMm56J4g=; b=Xs9SEnbQLnXG3FhlzzXncELrD5UM3crr/14Dy6T0F7M93l8VQHf15T7s0H2+U9J2DKqRAM E7U28U4WB+NngW0FT4bV0sdAQEByW0IWM3PYQZVcdno6xp7fkAt/XBZ1IQgatNhalokvqC TQP3nzPfk+W2knBFRXaDG78/yYNbYyp/bIr4VqTMqbdrmBdYirK1HxSGNrhcSRjkh45nVn 9wYeJe1wBD7eVm14+mHbXNWCpebNXZc+8susR0zmkSWNzkOM0/3Mfl8IBWTnU+DklR8ZIO H8WolmEV7R76a+I+dxo3xY7a1D/fuZRM3GrKmSJaaVV259ZvCP8C9CQPiHdkvg== Date: Wed, 30 Aug 2023 16:41:16 +0200 (CEST) From: Erik Wienhold To: Troels Arvin , pgsql-general@lists.postgresql.org Message-ID: <1985478005.5957.1693406476870@office.mailbox.org> In-Reply-To: <43ddf925-9c8b-b023-282c-b20e9366077d@arvin.dk> References: <43ddf925-9c8b-b023-282c-b20e9366077d@arvin.dk> Subject: Re: Calculating vm.nr_hugepages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Priority: 3 Importance: Normal List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On 30/08/2023 15:12 CEST Troels Arvin 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=3D21965570048B and not 20GB? The l= arger value is quoted in the last section of the linked blog post for pre-15 Post= gres and is the shared memory size that Postgres wants to allocate but fails to = do with shared_buffers=3D20GB. The section also provides the formula for manu= ally calculating vm.nr_hugepages. > I've also tried doing what ChatGPG suggested: > Number of Huge Pages when shared_buffers is set to 1 GiB =3D > shared_buffers / huge_page_size > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D 1073741824 bytes / 2097152 b= ytes > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D 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 addit= ional shared memory for internal stuff. So 512 is correct when the shared memory= size already includes the overhead for internal stuff. -- Erik