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 1mDIen-0005lN-GK for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Aug 2021 03:42:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mDIem-00055g-Df for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Aug 2021 03:42:24 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mDIem-00051g-63 for pgsql-hackers@lists.postgresql.org; Tue, 10 Aug 2021 03:42:24 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mDIej-0006oa-Vr for pgsql-hackers@postgresql.org; Tue, 10 Aug 2021 03:42:23 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 4A6BC3200962; Mon, 9 Aug 2021 23:42:20 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Mon, 09 Aug 2021 23:42:20 -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=ozqc4uu4nh9awOq4akG9ql6ta8m NKoEmw4sgPcxXLeA=; b=OOTl5L5VB9dPaFl1E7bRRYZUvRcHA9g9HU+NO7RzNuk ljPJ5PDGUnhyPqD0seGJmtPjT9rDV3+nqX18FiOCSm6W4wtouaCNooLFZoRsSIs0 T5EydVc6YNeAlSdqQ3OEQ9+LFHtqFBT+NZPElVAlz5tslt6BwcuD3wrquDyB+R7i CkOj4sJtGJAT85L3MpC4fSYunwufrNW4Wzl1+/jmwVHK1dSr92J7jFUoTUqvmKOJ t30btVt2kicKzO8V2ZIjiq0PzQhuRNpCGGPtFZa+xiQ3sj7y5/OGkfZqVnVOSFM9 bHkbDSICxm3kq4uyzTkgy4zsjaFEqmj4DRDZNPFarHg== 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=ozqc4u u4nh9awOq4akG9ql6ta8mNKoEmw4sgPcxXLeA=; b=AR9JrL3FIM3fTTcVQ7dM/X wcxjIDKx708ib9Y/Y2VucC5RJhs6jyCNgGfw1uOXtV1u2Nz885xXoC4z35Sp3KKw WHkW0OR4z4+Lg7vRIU1rrB9BKxhnjinP9C+30OwAIojfIfWcid+mq/B4Ivxs/gRC GUJMYqhhVRfE85A38ICrm/eU31oPHazSxgjqmzzS8Cdh0DVVkzvcaR7xibABtEPz 0TW9QgRTvxPjw7jEJtT1r1XV7MOYXAtUbwl5qIVBnDA+AGUupN5bRuFq3m3nyQRh jiyicqU3+gUkEUq3NGVaPTM3mJP//ivHWdHW1hVcZqexRIr0rEVCrEeUKizG/UFQ == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrjeekgdejgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomheptehnughrvghs ucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrfgrth htvghrnhepudekhfekleeugeevteehleffffejgeelueduleeffeeutdelffeujeffhfeu ffdunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hnughrvghssegrnhgrrhgriigvlhdruggv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 9 Aug 2021 23:42:18 -0400 (EDT) Date: Mon, 9 Aug 2021 20:42:05 -0700 From: Andres Freund To: "Bossart, Nathan" Cc: Mark Dilger , Don Seiler , "pgsql-hackers@postgresql.org" Subject: Re: Estimating HugePages Requirements? Message-ID: <20210810034205.r72j5uouynepj4f2@alap3.anarazel.de> References: <73A4E25F-1039-4FC9-8E6E-0A00230BDFB8@enterprisedb.com> <92BB93C3-1AA8-4548-96F7-062C4AF09182@amazon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <92BB93C3-1AA8-4548-96F7-062C4AF09182@amazon.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2021-08-09 22:57:18 +0000, Bossart, Nathan wrote: > @@ -1026,6 +1031,18 @@ PostmasterMain(int argc, char *argv[]) > */ > InitializeMaxBackends(); > > + if (output_shmem) > + { > + char output[64]; > + Size size; > + > + size = CreateSharedMemoryAndSemaphores(true); > + sprintf(output, "%zu", size); > + > + puts(output); > + ExitPostmaster(0); > + } I don't like putting this into PostmasterMain(). Either BootstrapMain() (specifically checker mode) or GucInfoMain() seem like better places. > -void > -CreateSharedMemoryAndSemaphores(void) > +Size > +CreateSharedMemoryAndSemaphores(bool size_only) > { > PGShmemHeader *shim = NULL; > > @@ -161,6 +161,9 @@ CreateSharedMemoryAndSemaphores(void) > /* might as well round it off to a multiple of a typical page size */ > size = add_size(size, 8192 - (size % 8192)); > > + if (size_only) > + return size; > + > elog(DEBUG3, "invoking IpcMemoryCreate(size=%zu)", size); > > /* > @@ -288,4 +291,6 @@ CreateSharedMemoryAndSemaphores(void) > */ > if (shmem_startup_hook) > shmem_startup_hook(); > + > + return 0; > } That seems like an ugly API to me. Why don't we split the size determination and shmem creation functions into two? Greetings, Andres Freund