Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJ23v-0003GI-Ae for pgsql-committers@arkaria.postgresql.org; Sun, 26 Nov 2017 18:53:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJ23t-00037D-Na for pgsql-committers@arkaria.postgresql.org; Sun, 26 Nov 2017 18:53:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eJ23t-000373-Ii for pgsql-committers@lists.postgresql.org; Sun, 26 Nov 2017 18:53:53 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eJ23k-0004ls-Pk for pgsql-committers@postgresql.org; Sun, 26 Nov 2017 18:53:52 +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 vAQIrb7j028145; Sun, 26 Nov 2017 13:53:37 -0500 From: Tom Lane To: Simon Riggs cc: Andres Freund , Tomas Vondra , pgsql-committers Subject: Re: pgsql: Generational memory allocator In-reply-to: References: <20171123001649.y2nf7422iay6cw3v@alap3.anarazel.de> <16449.1511548313@sss.pgh.pa.us> <4618.1511573138@sss.pgh.pa.us> <6189.1511587105@sss.pgh.pa.us> <8991.1511639441@sss.pgh.pa.us> <20171125200014.qbewtip5oydqsklt@alap3.anarazel.de> <21466.1511644760@sss.pgh.pa.us> <2875.1511646362@sss.pgh.pa.us> <16797.1511718406@sss.pgh.pa.us> Comments: In-reply-to Simon Riggs message dated "Mon, 27 Nov 2017 05:45:33 +1100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <28143.1511722417.1@sss.pgh.pa.us> Date: Sun, 26 Nov 2017 13:53:37 -0500 Message-ID: <28144.1511722417@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Simon Riggs writes: > On 27 November 2017 at 04:46, Tom Lane wrote: >> Well, I'm concerned about the possibility of a lot of palloc thrashing >> if the first bunch of records it reads happen to have steadily increasing >> sizes. However, rather than doubling, it might be sufficient to set a >> robust minimum on the first allocation, ie use something along the lines >> of Max(1024, MAXALIGN(state->main_data_len)). > Agreed. > I was just researching what that number should be... and I was > thinking that we should use the maximum normal tuple size, which I > think is > TOAST_TUPLE_THRESHOLD + > SizeOfXLogRecord + > SizeOfXLogRecordDataHeaderLong Well, let's not overthink this, because anything under 8K is going to be rounded up to the next power of 2 anyway by aset.c. Based on this point I'd say that BLCKSZ/2 or BLCKSZ/4 would be reasonable candidates for the minimum. regards, tom lane