Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h4n4I-0005EA-2h for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Mar 2019 13:40:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h4n4F-0006hM-N9 for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Mar 2019 13:40:11 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h4n4F-0006hF-Bw for pgsql-hackers@lists.postgresql.org; Fri, 15 Mar 2019 13:40:11 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h4n4C-0007QH-Iz for pgsql-hackers@lists.postgresql.org; Fri, 15 Mar 2019 13:40:10 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x2FDdlTb030381; Fri, 15 Mar 2019 09:39:48 -0400 From: Tom Lane To: Heikki Linnakangas cc: Robert Haas , Alvaro Herrera , PostgreSQL Hackers Subject: Re: hyrax vs. RelationBuildPartitionDesc In-reply-to: <2efba7eb-7fab-59db-68bd-9a03e39588eb@iki.fi> References: <20190313164232.GA5270@alvherre.pgsql> <7448.1552497345@sss.pgh.pa.us> <7961.1552498252@sss.pgh.pa.us> <10788.1552501588@sss.pgh.pa.us> <3969.1552581380@sss.pgh.pa.us> <15943.1552601288@sss.pgh.pa.us> <2efba7eb-7fab-59db-68bd-9a03e39588eb@iki.fi> Comments: In-reply-to Heikki Linnakangas message dated "Fri, 15 Mar 2019 09:32:22 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <30379.1552657187.1@sss.pgh.pa.us> Date: Fri, 15 Mar 2019 09:39:47 -0400 Message-ID: <30380.1552657187@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Heikki Linnakangas writes: > On 15/03/2019 00:08, Tom Lane wrote: >> Possibly it'd make sense to conditionally compile this so that we only >> do it in a CLOBBER_CACHE_ALWAYS build. I'm not very sure about that, >> but arguably in a normal build the overhead of making and destroying >> a context would outweigh the cost of the leaked memory. The main >> argument I can think of for doing it all the time is that having memory >> allocation work noticeably differently in CCA builds than normal ones >> seems like a recipe for masking normal-mode bugs from the CCA animals. > Having CLOBBER_CACHE_ALWAYS behave differently sounds horrible. I'm not entirely convinced of that. It's already pretty different... > We maintain a free list of AllocSetContexts nowadays, so creating a > short-lived context should be pretty cheap. Or if it's still too > expensive, we could create one short-lived context as a child of > TopMemoryContext, and reuse that on every call, resetting it at the end > of the function. RelationBuildDesc potentially recurses, so a single context won't do. Perhaps you're right that the context freelist would make this cheap enough to not matter, but I'm not sure of that either. What I'm inclined to do to get the buildfarm pressure off is to set things up so that by default we do this only in CCA builds, but there's a #define you can set from the compile command line to override that decision in either direction. Then, if somebody wants to investigate the performance effects in more detail, they could twiddle it easily. Depending on the results, we could alter the default policy. regards, tom lane