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 1h4hKT-0003NV-3Y for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Mar 2019 07:32:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h4hKR-0003cq-8r for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Mar 2019 07:32:31 +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 1h4hKQ-0003cA-Tj for pgsql-hackers@lists.postgresql.org; Fri, 15 Mar 2019 07:32:31 +0000 Received: from mail-lj1-f181.google.com ([209.85.208.181]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h4hKM-0007d1-Qw for pgsql-hackers@lists.postgresql.org; Fri, 15 Mar 2019 07:32:29 +0000 Received: by mail-lj1-f181.google.com with SMTP id z7so7060973lji.0 for ; Fri, 15 Mar 2019 00:32:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=NVCt5X38P3r60wqIqVcUeTP6FKMAJGDTF/3hLE9+zTQ=; b=Kn3iNuknQPa1MVazlSGbNYuf5RSP39qPSR1UcM9HcuE0fghq7Xp+4knREK0luof9Rg 5o7S5SQbzGX/Bvji0aeI1w1YVNruPLdGutkq38esA6V75LXGjnGPfA7fTyY0/0oQsHTP 6BGdh6lBippnd3FTQBNozSZrFaWYMiYM+Pmsn3NsK4NsLjzQ8gQ7pz2pj0XcoQz2+Zl4 bIlV2pL/9gK7goe/AhJ5+y0xtRCqngzpJ/kckucnBRvD+7jj49Np1C76mITInFy+rjIq jMD6WzzyCCVKOOLLOveUHu+a8lFYGnZwxuxeTJcoT8MtrbBijn5+pRINKyQ2iKwTY3EF dWkg== X-Gm-Message-State: APjAAAXm3xXx4EFfHszJJAoozywjDkJ8k2A+Fx5cLYxlG7Q7jT9U5GP7 L5ycxIc0S01hzbPlQi8kGdGlBP52 X-Google-Smtp-Source: APXvYqzG5oBpx5rZe1VF3unUrDuuJ37BKV7JrCjXz5MhcICXzKpTiHuZV6I7VFIZd4PySYULKul7Sw== X-Received: by 2002:a2e:9143:: with SMTP id q3mr1258515ljg.72.1552635144644; Fri, 15 Mar 2019 00:32:24 -0700 (PDT) Received: from [192.168.1.10] (dsl-hkibng32-54fbf8-78.dhcp.inet.fi. [84.251.248.78]) by smtp.gmail.com with ESMTPSA id g68sm253984ljg.53.2019.03.15.00.32.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Mar 2019 00:32:23 -0700 (PDT) Subject: Re: hyrax vs. RelationBuildPartitionDesc To: Tom Lane , Robert Haas Cc: Alvaro Herrera , PostgreSQL Hackers 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> From: Heikki Linnakangas Message-ID: <2efba7eb-7fab-59db-68bd-9a03e39588eb@iki.fi> Date: Fri, 15 Mar 2019 09:32:22 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <15943.1552601288@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 15/03/2019 00:08, Tom Lane wrote: > What I'm thinking, therefore, is that 2455ab488 had the right idea but > didn't take it far enough. We should remove the temp-context logic it > added to RelationBuildPartitionDesc and instead put that one level up, > in RelationBuildDesc, where the same temp context can serve all of these > leak-prone sub-facilities. > > 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. 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. - Heikki