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 1lXbTp-0004ij-Rn for pgsql-hackers@arkaria.postgresql.org; Sat, 17 Apr 2021 03:18:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lXbTo-0002aL-Nw for pgsql-hackers@arkaria.postgresql.org; Sat, 17 Apr 2021 03:18:44 +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 1lXbTo-0002aD-H9 for pgsql-hackers@lists.postgresql.org; Sat, 17 Apr 2021 03:18:44 +0000 Received: from mail-oo1-xc2c.google.com ([2607:f8b0:4864:20::c2c]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lXbTl-0001op-EY for pgsql-hackers@postgresql.org; Sat, 17 Apr 2021 03:18:43 +0000 Received: by mail-oo1-xc2c.google.com with SMTP id h2-20020a4ad7420000b02901e5901169a5so6334625oot.8 for ; Fri, 16 Apr 2021 20:18:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Efzk7R0/6lIvOmY0/elwuAuHbeA5zkl2uuXo4OaR3Do=; b=Zl+aE90WpWS3Ch93Ss19GEacDt21RjpN8chveTtMxUuErsU3y8QzPp94n/c/ZX9Yar BxE26MmFDe7Ek83OY23TniuLeWoZ78kneU4CbGkPEMaz00VtavfMznW5Dcu+eJOZvvr7 kdFYv/QJDcLEIt11NXG7COTO90NDsMpUcLnHn2YQM6dkhMKH20F5u7Vqzc4Q8e32Iu6o +d58AiuWwhT8kD7sKfkSBTcj5Dm+48kmvS83RceMpDC50Kxc8jiWwbSkvDyBfOB1UIk8 drDd3ocOGnh+RlJfzH+/ZQsdSTZj8YSJ7upq5hAmU0g/6yKIBix7FH8y7HUJrbk8axPv 9XBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Efzk7R0/6lIvOmY0/elwuAuHbeA5zkl2uuXo4OaR3Do=; b=RJuOOQxrrfcBZpzbuHCZ+kbRxmLBK/gX9BC4+eM8lyw2xv0cHPI0dNFM5VaCPyXP71 eM4eKyoigVA/+N43ZeWJx/m6Tmdsg7Gv13Mi2LPs3eISSfhFMzYnt6Tw54EHCgYyKgBi tjBNmuu/MmT11ookoM5EydMiJXrPoCioKkyyi3vrEyRDvIJzCQWgCt6JAJ7NjtFo8Q1a mfU00NmLQfAVoUatmbWURuLI6esAi2vmUzZYJobBH3Xao4n6kwuJB9bRYtcqpr2DO/3T YFfPGHxTXtBs9k2zIL3jBREP2Rie3n3QF09jAPr+6CF+TbiEA9eYBV7mdOLSw4jxHkw/ sBcA== X-Gm-Message-State: AOAM5310xEdBCkeQbhx421bQyLxXYnU67u4vTptmvx0g7kB3UTAyic6T i1bxmDotYCaWtmHEhxX9fs0tdSNJ0Tw+yA== X-Google-Smtp-Source: ABdhPJz+lqg84XKSY6gWxNQeAxTqqf6x+FH+STCt35ZLFfksStHy/q9sy4odrXK6hYCar3W8Hl6SKw== X-Received: by 2002:a4a:48c2:: with SMTP id p185mr5595093ooa.73.1618629519535; Fri, 16 Apr 2021 20:18:39 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id j8sm1813355otr.28.2021.04.16.20.18.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Apr 2021 20:18:39 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id D6B73800A3E; Fri, 16 Apr 2021 22:18:37 -0500 (CDT) Date: Fri, 16 Apr 2021 22:18:37 -0500 From: Justin Pryzby To: Andres Freund Cc: pgsql-hackers@postgresql.org, Tom Lane Subject: Re: terminate called after throwing an instance of 'std::bad_alloc' Message-ID: <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210417024854.GL3315@telsasoft.com> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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. 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 -- Justin