On 26 November 2017 at 08:46, Tom Lane <[email protected]> wrote:
> I wrote:
>> Instead I propose that we should make sure that the palloc request size
>> for XLogReaderState->main_data is always maxalign'd.  The existing
>> behavior in DecodeXLogRecord of palloc'ing it only just barely big
>> enough for the current record seems pretty brain-dead performance-wise
>> even without this consideration.  Generally, if we need to enlarge
>> that buffer, we should enlarge it significantly, IMO.
>
> 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.

So I think we're just good to go with your patch.

-- 
Simon Riggs                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Reply via email to