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 1lXclM-00079B-2J for pgsql-hackers@arkaria.postgresql.org; Sat, 17 Apr 2021 04:40:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lXclJ-0001kH-O4 for pgsql-hackers@arkaria.postgresql.org; Sat, 17 Apr 2021 04:40:53 +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 1lXclH-0001f4-QA for pgsql-hackers@lists.postgresql.org; Sat, 17 Apr 2021 04:40:53 +0000 Received: from [66.111.4.25] (helo=out1-smtp.messagingengine.com) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lXclC-0002vg-5j for pgsql-hackers@lists.postgresql.org; Sat, 17 Apr 2021 04:40:50 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id D24B05C024E for ; Sat, 17 Apr 2021 00:40:34 -0400 (EDT) Received: from imap35 ([10.202.2.85]) by compute1.internal (MEProxy); Sat, 17 Apr 2021 00:40:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= mime-version:message-id:in-reply-to:references:date:from:to :subject:content-type; s=fm1; bh=+CnhI9GgCSnmNQRYqQAs1bZEYuI/HV3 pTU7kw+Sgy/w=; b=KAH9ONw3K6s5PVrPICqEAZUUhGwIVISSxPZImRxm/JLlL++ 63QoLzre7EE+LjjkJMBP2gCjuZSu3HbAbIROWyw/Q89nVvN9GR+Q4QJNs70wrwCU u6bX26aifC2iPkVdMGss+Fi3KcB8Az9Cy2U9e+k5q8fi70MMfJa/ksqDG1cTKf4K S1nzMjxy1DEaawfY8Q8ugE8SPdbP7g/CtJzZ9YoEYRLlZYh3NUr8wIUUczuMZeqY v6fehLsd1LhaAtssoeZvo4cYHayDb4MuF1MjkHUtPTZFSrJ1tPCwIwh9R0+vjpOn eR0snG+uPX55dBYYt/S6y34eHDyqp039oUSiLYw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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=fm2; bh=+CnhI9 GgCSnmNQRYqQAs1bZEYuI/HV3pTU7kw+Sgy/w=; b=TTyldSV4NKSMu2hPXk7bv2 dhF7lAE57SavBBVPjzXfzB2hqPfjIq6pcIlJQJjzm/tarokM6TOl9HK4tfZylH8O kMqoZDPZG6jdVgf2jjz4acuWF9ttenb8WJrO51Q7FMO0AxvsxKmCtpj9WMQWhEPJ rEgMekXOO9SCJO3HMZKrARImmjDyWpIB1rVxwtfVz4PlrZJ11F2yQUb8Ft3IhPhO ywW7Ux6AdoaFJn/SoeI+T1df/W+94A9E5mhVRYDjBgemx/KC/UFbbBZf9TEQA9/g 0wOQhZwzc8Hxcf1FKTM8s67DfAqfT9MPdDuzyWIdb+Ybx4SIHkPz9/1UTc6qNZ8Q == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudeliedgkeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfgjfhffhffvufgtsehttd ertderredtnecuhfhrohhmpedftehnughrvghsucfhrhgvuhhnugdfuceorghnughrvghs segrnhgrrhgriigvlhdruggvqeenucggtffrrghtthgvrhhnpeekgfekgefhveekgeeugf egheetkedtgeeutdetledvheevfeejvdefleejhfejueenucffohhmrghinhepphhoshht ghhrvghsqhhlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomheprghnughrvghssegrnhgrrhgriigvlhdruggv X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 073AA15A005F; Sat, 17 Apr 2021 00:40:33 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-273-g8500d2492d-fm-20210323.002-g8500d249 Mime-Version: 1.0 Message-Id: <21486531-e1bd-4c7e-aa2c-938093855f66@www.fastmail.com> In-Reply-To: <20210417031837.GM3315@telsasoft.com> References: <20201001021609.GC8476@telsasoft.com> <20201003220236.GL8476@telsasoft.com> <20201003230149.mtd7fjsjwgii3jv7@alap3.anarazel.de> <20201003233045.GM8476@telsasoft.com> <20201004020127.zbrol2ypu6tg2bei@alap3.anarazel.de> <20201007230242.rnwsbnxywvthef3w@alap3.anarazel.de> <20201218235607.GC30237@telsasoft.com> <20210417021755.xdcqaqqt4y46wzt7@alap3.anarazel.de> <20210417024854.GL3315@telsasoft.com> <20210417031837.GM3315@telsasoft.com> Date: Fri, 16 Apr 2021 21:40:12 -0700 From: "Andres Freund" To: pgsql-hackers@lists.postgresql.org Subject: Re: terminate called after throwing an instance of 'std::bad_alloc' Content-Type: text/plain X-Host-Lookup-Failed: Reverse DNS lookup failed for 66.111.4.25 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Fri, Apr 16, 2021, at 20:18, Justin Pryzby wrote: > On Fri, Apr 16, 2021 at 09:48:54PM -0500, Justin Pryzby wrote: > > On Fri, Apr 16, 2021 at 07:17:55PM -0700, Andres Freund wrote: > > > Hi, > > > > > > On 2020-12-18 17:56:07 -0600, Justin Pryzby wrote: > > > > I'd be happy to run with a prototype fix for the leak to see if the other issue > > > > does (not) recur. > > > > > > I just posted a prototype fix to https://www.postgresql.org/message-id/20210417021602.7dilihkdc7oblrf7%40alap3.anarazel.de > > > (just because that was the first thread I re-found). It'd be cool if you > > > could have a look! > > > > This doesn't seem to address the problem triggered by the reproducer at > > https://www.postgresql.org/message-id/20210331040751.GU4431@telsasoft.com > > (sorry I didn't CC you) > > I take that back - I forgot that this doesn't release RAM until hitting a > threshold. > Phew. > Without the patch, it looks like: > > $ yes 'SET jit_above_cost=0; SET jit_inline_above_cost=0; SET jit=on; > SET client_min_messages=debug; SET log_executor_stats=on; SELECT > cfn();' |head -11 |psql -h /tmp postgres 2>&1 |grep 'max resident' > ! 61820 kB max resident size > ! 65020 kB max resident size > ! 68812 kB max resident size > ! 71152 kB max resident size > ! 76820 kB max resident size > ! 78760 kB max resident size > ! 81140 kB max resident size > ! 83520 kB max resident size > ! 93084 kB max resident size > ! 94756 kB max resident size > ! 96416 kB max resident size > > With the patch and #define LLVMJIT_LLVM_CONTEXT_REUSE_MAX 1, it looks like > this: > > ! 61436 kB max resident size > ! 61572 kB max resident size > ! 63236 kB max resident size > ! 63236 kB max resident size > ! 63556 kB max resident size > ! 63556 kB max resident size > ! 63880 kB max resident size > ! 65416 kB max resident size > ! 65416 kB max resident size > ! 65416 kB max resident size > ! 65416 kB max resident size If you set the define to much lower, how low does this get? I didn't see an easy way to make the recreation of the context memory usage dependant, but that'd of course be much better than an #iterations based approach. I'll play around with your test tomorrow or so, if you don't, but now the next step is risotto... Regards, Andres