Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mJhgD-0004C7-54 for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Aug 2021 19:38:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mJhgB-0003sR-Ol for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Aug 2021 19:38:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mJhgB-0003sJ-HA for pgsql-hackers@lists.postgresql.org; Fri, 27 Aug 2021 19:38:19 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mJhg9-00044j-Hx for pgsql-hackers@postgresql.org; Fri, 27 Aug 2021 19:38:19 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 44AAA5C0153; Fri, 27 Aug 2021 15:38:16 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Fri, 27 Aug 2021 15:38:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm2; bh=J9041+Ft3brDCjbllTSVETFT2JX b94b2Dr/7DNiJs6Q=; b=PedX4H3D+3WRKfjE7oAW1vNUr/xtsMXFwdXCa6bl5DG mxzfyLk+sMh5zhba0wD8oYiMMae5hix60gI+WHFe1oLGq9tfppWEG0jPkKqyDWbb fZdfa1Qz6iX/m63Mi1LyJVKy4WzJxQTkPSt2GXWWgRoeaBX9sBZQ0KtQAwR2e2Np qogqyyjlmc7TvMV68YwQY/ExGnVsgYpe/8rAx+qEwGfWkr8FDxrTK1mXbeIZpcTy z30r86dCOS3ouPUvO17jKp5OXvEZTzXYfllewbS7hUJVTkkVg56GUAqY8vcKVxvc rh20UeT7MtfxKtzk9aAu17MNKdpzh5LmotAHwzpM9eA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=J9041+ Ft3brDCjbllTSVETFT2JXb94b2Dr/7DNiJs6Q=; b=JgdG0e+e7GgLCSXKVRhueb lEbbueps3SsllfrF4fFPnqCHMDMFa26JU2U72hkJyQHu0IHqjJW0GAe9kkKDrge4 eyFP9hAoMrURSWvQ7A/WpOdZWEp9gYbwsa2MzaXlvYyXW6YoQ4hI7z7bFcuiq75c Avuht1C1tWL7paXT0MqjBrWrBPuiJgNcfH2nbw1QobdcDmtCEs/8sBW2Ug9vQQ+C pUPcIeM/O3jKLCli+IkdhcB+/ql0z2cOLwLU+QtHxrvArK+JkxIxzBhfT0oIgE5s c9GATa4ZztOgLJlxAR0a2EdACD4QQBcm4CXgKLAqQLq6D+SnKMawr3tFgUPP5FJQ == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddruddufedgudeflecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomheptehnughr vghsucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrf grthhtvghrnhepudekhfekleeugeevteehleffffejgeelueduleeffeeutdelffeujeff hfeuffdunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh eprghnughrvghssegrnhgrrhgriigvlhdruggv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 27 Aug 2021 15:38:14 -0400 (EDT) Date: Fri, 27 Aug 2021 12:38:13 -0700 From: Andres Freund To: "Bossart, Nathan" Cc: Magnus Hagander , Michael Paquier , Mark Dilger , Don Seiler , "pgsql-hackers@postgresql.org" Subject: Re: Estimating HugePages Requirements? Message-ID: <20210827193813.oqo5lamvyzahs35o@alap3.anarazel.de> References: <73A4E25F-1039-4FC9-8E6E-0A00230BDFB8@enterprisedb.com> <92BB93C3-1AA8-4548-96F7-062C4AF09182@amazon.com> <20210810034205.r72j5uouynepj4f2@alap3.anarazel.de> <0545F7B3-70C0-4DE8-8C85-EAFE6113B7EE@amazon.com> <20210827184648.d3jbv73pgyccqwkz@alap3.anarazel.de> <071DC95B-4CA8-4D2B-BD24-1A66B3EFFE28@amazon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <071DC95B-4CA8-4D2B-BD24-1A66B3EFFE28@amazon.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2021-08-27 19:27:18 +0000, Bossart, Nathan wrote: > + > + > + > + > + Prints the amount of shared memory required for the given > + configuration and exits. This can be used on a running server, but > + the return value reflects the amount of shared memory needed based > + on the current invocation. It does not return the amount of shared > + memory in use by the running server. This must be the first > + argument on the command line. > + > + > + > + This option is useful for determining the number of huge pages > + needed for the server. For more information, see > + . > + > + > + > + One thing I wonder is if this wouldn't better be dealt with in a more generic way. While this is the most problematic runtime computed GUC, it's not the only one. What if we introduced a new shared_memory_size GUC, and made --describe-config output it? Perhaps adding --describe-config=guc-name? I also wonder if we should output the number of hugepages needed instead of the "raw" bytes of shared memory. The whole business about figuring out the huge page size, dividing the shared memory size by that and then rounding up could be removed in that case. Due to huge_page_size it's not even immediately obvious which huge page size one should use... > diff --git a/src/backend/main/main.c b/src/backend/main/main.c > index 3a2a0d598c..c141ae3d1c 100644 > --- a/src/backend/main/main.c > +++ b/src/backend/main/main.c > @@ -182,9 +182,11 @@ main(int argc, char *argv[]) > */ > > if (argc > 1 && strcmp(argv[1], "--check") == 0) > - BootstrapModeMain(argc, argv, true); > + BootstrapModeMain(argc, argv, true, false); > + else if (argc > 1 && strcmp(argv[1], "--output-shmem") == 0) > + BootstrapModeMain(argc, argv, false, true); > else if (argc > 1 && strcmp(argv[1], "--boot") == 0) > - BootstrapModeMain(argc, argv, false); > + BootstrapModeMain(argc, argv, false, false); > #ifdef EXEC_BACKEND > else if (argc > 1 && strncmp(argv[1], "--fork", 6) == 0) > SubPostmasterMain(argc, argv); help() needs an update too. > diff --git a/src/backend/storage/ipc/ipci.c b/src/backend/storage/ipc/ipci.c > index 3e4ec53a97..b225b1ee70 100644 > --- a/src/backend/storage/ipc/ipci.c > +++ b/src/backend/storage/ipc/ipci.c > @@ -75,6 +75,87 @@ RequestAddinShmemSpace(Size size) > total_addin_request = add_size(total_addin_request, size); > } > > +/* > + * CalculateShmemSize > + * Calculates the amount of shared memory and number of semaphores needed. > + * > + * If num_semaphores is not NULL, it will be set to the number of semaphores > + * required. > + * > + * Note that this function freezes the additional shared memory request size > + * from loadable modules. > + */ > +Size > +CalculateShmemSize(int *num_semaphores) > +{ Can you split this into a separate commit? It feels fairy uncontroversial to me, so I think we could just apply it soon? Greetings, Andres Freund