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 1oLWNW-0002NN-Pu for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Aug 2022 21:03:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oLWNV-0003Yz-HP for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Aug 2022 21:03:05 +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 1oLWNU-0003Xx-Kr for pgsql-hackers@lists.postgresql.org; Tue, 09 Aug 2022 21:03:05 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oLWNS-0002Ar-5I for pgsql-hackers@lists.postgresql.org; Tue, 09 Aug 2022 21:03:03 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 6EF5D5C0262; Tue, 9 Aug 2022 17:03:01 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Tue, 09 Aug 2022 17:03:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm1; t=1660078981; x=1660165381; bh=3SXqxRe/4G KkoJXvJaotj4ue1+uFAxt91FqFfnfDTeM=; b=yMTmxrfHpLvhn0O3kAgEM5xKF5 jxZZrkvoqdbdsPFgq+jT51GR74AudJ9RW+dGoAccIwYNegCqBgjtc6u8/Z+3rijn ZOifGKNDv+jLfq2ZpMoT1WfuWX9ltrQJgiv260k82i6hIMqF51/NqFTs0HiLMuJX rV8uzO3TFxr1JkGqEbNCpH6vK1flJMF5dCeC7xEc5DvoMP2mJoA/zXYOzXbZ3rcs bNHdJbJ48yYujJvzaToW/3zPzhZanhImJcf36++mBuO9FdFfDcs8vrF53Dun06o/ y1Q728SovGxXFdgYlHbVBDjuLF5f3L8IdtnD77agILypRCnqqtRkdnOm1S5A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1660078981; x=1660165381; bh=3SXqxRe/4GKkoJXvJaotj4ue1+uF Axt91FqFfnfDTeM=; b=AHE2NI+QD8zYWujoYECwmrOKMZ9lmYaXJ67ZyxVhSvJ4 ewXiLa9EIoAP7Xj1L1URLZHW/EXqOYIPZ/MolY21XDvI+iOuNeNfebN5Rt2kEFbF W9N2cDHGV56t9HbV8E2Vp6Sn/+QzLJXpTkRf7T8vvX6O88eZptXpIizIxGTNUV00 PzKh8ElbVGxUZ0jHK4BQu5byheC5Y4QEtxhWLsKxTmXleyj9XRwSJXoEaJCCkiJD C7ZWBYIbHcg4a6W+DOT17BZjLa97bbIq+7cbz2Lol7Wg/IXKPS7tq06RFRhPo7PK mRBDwUWcN/g1Smd9j4AxXjZA/YkxI6tThuAv66EhLw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdegtddgudehjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeetnhgu rhgvshcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtf frrghtthgvrhhnpedvffefvefhteevffegieetfefhtddvffejvefhueetgeeludehteev udeitedtudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpegrnhgurhgvshesrghnrghrrgiivghlrdguvg X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 9 Aug 2022 17:03:00 -0400 (EDT) Date: Tue, 9 Aug 2022 14:02:58 -0700 From: Andres Freund To: Tom Lane Cc: Robert Haas , David Rowley , Yura Sokolov , PostgreSQL Developers Subject: Re: Reducing the chunk header sizes on all memory context types Message-ID: <20220809210258.o7to2ymxuaq2j76r@awork3.anarazel.de> References: <9dec1bd42fed3e263de294116380e5b51c427267.camel@postgrespro.ru> <20220712174404.polbc5it7j6mzmql@awork3.anarazel.de> <20220809184410.g6yzu6pvttuphag5@awork3.anarazel.de> <36081.1660072917@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <36081.1660072917@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2022-08-09 15:21:57 -0400, Tom Lane wrote: > Andres Freund writes: > > I think it's fine, given that we can change this at any time, but it's > > probably worth to explicitly agree that this will for now restrict us to 8 > > context methods? > > Do we really need it to be that tight? I know we only have 3 methods today, > but 8 doesn't seem that far away. If there were six bits reserved for > this I'd be happier. We only have so many bits available, so that'd have to come from some other resource. The current division is: + * 1. 3-bits to indicate the MemoryContextMethodID + * 2. 1-bit to indicate if the chunk is externally managed (see below) + * 3. 30-bits for the amount of memory which was reserved for the chunk + * 4. 30-bits for the number of bytes that must be subtracted from the chunk + * to obtain the address of the block that the chunk is stored on. I suspect we could reduce 3) here a bit, which I think would end up with slab context's max chunkSize shrinking further. Which should still be fine. But also, we could defer that to later, this is a limit that we can easily change. > >> # We also add a restriction that block sizes for all 3 of the memory > >> # allocators cannot be 1GB or larger. We would be unable to store the > >> # number of bytes that the block is offset from the chunk stored beyond this > >> #1GB boundary on any block that was larger than 1GB. > > Losing MemoryContextAllocHuge would be very bad, so I assume this comment > is not telling the full truth. It's just talking about chunked allocation (except for slab, which doesn't have anything else, but as David pointed out, it makes no sense to use slab for that large allocations). I.e. it's the max you can pass to AllocSetContextCreate()'s and GenerationContextCreate()'s maxBlockSize, and to SlabContextCreate()'s chunkSize. I don't think we have any code that currently sets a bigger limit than 8MB. Greetings, Andres Freund