On Sat, Jan 7, 2017 at 7:48 PM, Jim Nasby <jim.na...@bluetreble.com> wrote:
> On 1/5/17 12:55 PM, Jonathon Nelson wrote: > >> Attached please find a patch for PostgreSQL 9.4 which changes the >> maximum amount of data that the wal sender will send at any point in >> time from the hard-coded value of 128KiB to a user-controllable value up >> to 16MiB. It has been primarily tested under 9.4 but there has been some >> testing with 9.5. >> > > To make sure this doesn't get lost, please add it to > https://commitfest.postgresql.org. Please verify the patch will apply > against current HEAD and pass make check-world. Attached please find a revision of the patch, changed in the following ways: 1. removed a call to debug2. 2. applies cleanly against master (as of 8c5722948e831c1862a39da2bb5d79 3a6f2aabab) 3. one small indentation fix, one small verbiage fix. 4. switched to calculating the upper bound using XLOG_SEG_SIZE rather than hard-coding 16384. 5. the git author is - obviously - different. make check-world passes. I have added it to the commitfest. I have verified with strace that up to 16MB sends are being used. I have verified that the GUC properly grumps about values greater than XLOG_SEG_SIZE / 1024 or smaller than 4. -- Jon
From 7286e290daec32e12260e9e1e44a490c13ed2245 Mon Sep 17 00:00:00 2001 From: Jon Nelson <jnel...@jamponi.net> Date: Mon, 9 Jan 2017 20:00:41 -0600 Subject: [PATCH] guc-ify the formerly hard-coded MAX_SEND_SIZE to max_wal_send --- src/backend/replication/walsender.c | 13 +++++++------ src/backend/utils/misc/guc.c | 12 ++++++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c index f3082c3..4a9eb16 100644 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -91,7 +91,7 @@ * because signals are checked only between messages. 128kB (with * default 8k blocks) seems like a reasonable guess for now. */ -#define MAX_SEND_SIZE (XLOG_BLCKSZ * 16) +int max_wal_send_guc = 0; /* Array of WalSnds in shared memory */ WalSndCtlData *WalSndCtl = NULL; @@ -2194,7 +2194,7 @@ retry: /* * Send out the WAL in its normal physical/stored form. * - * Read up to MAX_SEND_SIZE bytes of WAL that's been flushed to disk, + * Read up to max_wal_send kilobytes of WAL that's been flushed to disk, * but not yet sent to the client, and buffer it in the libpq output * buffer. * @@ -2208,6 +2208,7 @@ XLogSendPhysical(void) XLogRecPtr startptr; XLogRecPtr endptr; Size nbytes; + int max_wal_send = max_wal_send_guc * 1024; if (streamingDoneSending) { @@ -2346,8 +2347,8 @@ XLogSendPhysical(void) /* * Figure out how much to send in one message. If there's no more than - * MAX_SEND_SIZE bytes to send, send everything. Otherwise send - * MAX_SEND_SIZE bytes, but round back to logfile or page boundary. + * max_wal_send bytes to send, send everything. Otherwise send + * max_wal_send bytes, but round back to logfile or page boundary. * * The rounding is not only for performance reasons. Walreceiver relies on * the fact that we never split a WAL record across two messages. Since a @@ -2357,7 +2358,7 @@ XLogSendPhysical(void) */ startptr = sentPtr; endptr = startptr; - endptr += MAX_SEND_SIZE; + endptr += max_wal_send; /* if we went beyond SendRqstPtr, back off */ if (SendRqstPtr <= endptr) @@ -2376,7 +2377,7 @@ XLogSendPhysical(void) } nbytes = endptr - startptr; - Assert(nbytes <= MAX_SEND_SIZE); + Assert(nbytes <= max_wal_send); /* * OK to read and send the slice. diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 5b23dbf..b9a0c47 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -112,6 +112,7 @@ extern char *default_tablespace; extern char *temp_tablespaces; extern bool ignore_checksum_failure; extern bool synchronize_seqscans; +extern int max_wal_send_guc; #ifdef TRACE_SYNCSCAN extern bool trace_syncscan; @@ -2342,6 +2343,17 @@ static struct config_int ConfigureNamesInt[] = }, { + {"max_wal_send", PGC_SIGHUP, REPLICATION_SENDING, + gettext_noop("Sets the maximum WAL payload size for WAL replication."), + NULL, + GUC_UNIT_KB + }, + &max_wal_send_guc, + 128, 4, XLOG_SEG_SIZE / 1024, + NULL, NULL, NULL + }, + + { {"commit_delay", PGC_SUSET, WAL_SETTINGS, gettext_noop("Sets the delay in microseconds between transaction commit and " "flushing WAL to disk."), -- 2.10.2
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers