Re: pgsql: Generational memory allocator

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, Tomas Vondra <tv(at)fuzzy(dot)cz>, pgsql-committers <pgsql-committers(at)postgresql(dot)org>
Subject: Re: pgsql: Generational memory allocator
Date: 2017-11-26 17:46:46
Message-ID: 16797.1511718406@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Simon Riggs <simon(at)2ndquadrant(dot)com> writes:
> On 26 November 2017 at 08:46, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> I've confirmed that the attached is sufficient to stop the valgrind crash
>> on my machine. But as I said, I think we should be more aggressive at
>> resizing the buffer, to reduce resize cycles. I'm inclined to start out
>> with a buffer size of 128 or 256 or so bytes and double it when needed.
>> Anybody have a feeling for a typical size for the "main data" part
>> of a WAL record?

> We reuse the buffer and only pfree/palloc when we need to enlarge the
> buffer, so not sure we need to do the doubling thing and it probably
> doesn't matter what the typical size is.

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)).

regards, tom lane

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Joe Conway 2017-11-26 17:52:11 pgsql: Make has_sequence_privilege support WITH GRANT OPTION
Previous Message Simon Riggs 2017-11-26 09:34:49 Re: pgsql: Generational memory allocator