Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 59af8d4

Browse files
Pad XLogReaderState's per-buffer data_bufsz more aggressively.
Originally, we palloc'd this buffer just barely big enough to hold the largest xlog backup block seen so far. We now MAXALIGN the palloc size. The original coding could result in many repeated palloc cycles, in the worst case where we see a series ofgradually larger xlog records. We ameliorate that similarly to 8735978 by imposing a minimum buffer size of BLCKSZ. Discussion: https://postgr.es/m/E1eHa4J-0006hI-Q8@gemulon.postgresql.org
1 parent d5f965c commit 59af8d4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/backend/access/transam/xlogreader.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,13 @@ DecodeXLogRecord(XLogReaderState *state, XLogRecord *record, char **errormsg)
12641264
{
12651265
if (blk->data)
12661266
pfree(blk->data);
1267-
blk->data_bufsz = blk->data_len;
1267+
1268+
/*
1269+
* Force the initial request to be BLCKSZ so that we don't
1270+
* waste time with lots of trips through this stanza as a
1271+
* result of WAL compression.
1272+
*/
1273+
blk->data_bufsz = MAXALIGN(Max(blk->data_len, BLCKSZ));
12681274
blk->data = palloc(blk->data_bufsz);
12691275
}
12701276
memcpy(blk->data, ptr, blk->data_len);

0 commit comments

Comments
 (0)