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 1qtbPz-00D8nI-Gv for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Oct 2023 22:23:03 +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 1qtbPw-008Vio-Uj for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Oct 2023 22:23:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qtbPw-008Vif-Kn for pgsql-hackers@lists.postgresql.org; Thu, 19 Oct 2023 22:23:01 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qtbPt-001cEi-1n for pgsql-hackers@lists.postgresql.org; Thu, 19 Oct 2023 22:23:00 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id EA10732009E0; Thu, 19 Oct 2023 18:22:53 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Thu, 19 Oct 2023 18:22:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-type: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=fm3; t=1697754173; x=1697840573; bh=nJ qJlHOOYGZYdJ0F6PwTfRzABVyqjhsnfK0HJq9Kq4E=; b=bAzPZ6yoSagppYfnO4 Cgeg5xPMJd4SbDrk8GB7sdPJyUMPa+YWgJZO1M3cBDQetlcVif4QIO7Ev43Wn1Q2 VnowlHOH7zbD/Og57BVNUtdWLEvmJne5uj4PMJ6zLqptFKijdPKIybpHt8gMdQxK QzXekOGJo0/1PdF6rjtLwBLYSOO8ls5e9L7F+MZ5TMwNMAJNXVAHVCKSumiq3gQi CPEdN07pr5y1GaWdEIA2CW/hBhowcj+DrhDHkIsrWQR7On2PQEdvNf5EBBpsnB7q 7YvElOMmmI/bsmOck9SI++8K72N9fPaU7w6xxTwBwf2lbUyBtYeqUQAdK88/++76 80pA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type: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=fm3; t=1697754173; x=1697840573; bh=nJqJlHOOYGZYd J0F6PwTfRzABVyqjhsnfK0HJq9Kq4E=; b=Y6O5hvA56qp6IwigG6xvbJ/rOkPXB QpK7BKJZBFbjdAs4qo1Dup+ZskaqqGAt33AIG3OAZwVFRoON7P9rr5hZd3KgNcal fadMJqsUDWIsCQOvm5YZXz695xIppqW8M3nSud6RLciwcj/D7BDu6+JacLj4gV5O QMInbbd2oY+KhYoJJhCz81uGIAKDJCglCxRihsIfVylgqa3NrbBcAWO9t7pZNWqj PJL/Zo0vtFTnqhtuzEHo9XNX5fcU+dOJey0VoiJPrquE6FOE42Cncxb7dBxT8JqL VsZg+CjsoYkuC6Aady2u3aKIT2QIHN9RaVmVlvIaQeVJvwQHbsdDBa+gg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrjeejgddtlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeetnhgurhgv shcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtffrrg htthgvrhhnpedvffefvefhteevffegieetfefhtddvffejvefhueetgeeludehteevudei tedtudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe grnhgurhgvshesrghnrghrrgiivghlrdguvg X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 19 Oct 2023 18:22:52 -0400 (EDT) Date: Thu, 19 Oct 2023 15:22:51 -0700 From: Andres Freund To: Stephen Frost Cc: Andrei Lepikhov , reid.thompson@crunchydata.com, Arne Roland , "pgsql-hackers@lists.postgresql.org" , vignesh C , Justin Pryzby , Ibrar Ahmed , "stephen.frost" Subject: Re: Add the ability to limit the amount of memory that can be allocated to backends. Message-ID: <20231019222251.4qg6udcbtrwglogw@awork3.anarazel.de> References: <334ccda9d8790f2b80dc3fee787704b0621152da.camel@crunchydata.com> <94184680049d6bda0c85f1759af24d8127cfe895.camel@crunchydata.com> <7912c911af51d5cf28c611190bf3d463b9209343.camel@crunchydata.com> <4edafedc0f8acb12a2979088ac1317bd7dd42145.camel@crunchydata.com> <268e0ac7-8a81-4d65-8b40-b62c4b3f1bf9@postgrespro.ru> <48548d40-634b-4943-a737-3c9d95eacf06@postgrespro.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2023-10-19 18:06:10 -0400, Stephen Frost wrote: > Ignoring such would defeat much of the point of this effort- which is to > get to a position where we can say with some confidence that we're not > going to go over some limit that the user has set and therefore not > allow ourselves to end up getting OOM killed. I think that is a good medium to long term goal. I do however think that we'd be better off merging the visibility of memory allocations soon-ish and implement the limiting later. There's a lot of hairy details to get right for the latter, and even just having visibility will be a huge improvement. I think even patch 1 is doing too much at once. I doubt the DSM stuff is quite right. I'm unconvinced it's a good idea to split the different types of memory contexts out. That just exposes too much implementation detail stuff without a good reason. I think the overhead even just the tracking implies right now is likely too high and needs to be optimized. It should be a single math operation, not tracking things in multiple fields. I don't think pg_sub_u64_overflow() should be in the path either, that suddenly adds conditional branches. You really ought to look at the difference in assembly for the hot functions. Greetings, Andres Freund