pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: pgsql-committers@postgresql.org
Subject: pgsql: Allow the WAL writer to flush WAL at a reduced rate.
Date: Tue, 16 Feb 2016 00:18:08 +0000
Message-ID: <E1aVTLE-00076m-NP@gemulon.postgresql.org> (raw)
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>

Allow the WAL writer to flush WAL at a reduced rate.

Commit 4de82f7d7 increased the WAL flush rate, mainly to increase the
likelihood that hint bits can be set quickly. More quickly set hint bits
can reduce contention around the clog et al.  But unfortunately the
increased flush rate can have a significant negative performance impact,
I have measured up to a factor of ~4.  The reason for this slowdown is
that if there are independent writes to the underlying devices, for
example because shared buffers is a lot smaller than the hot data set,
or because a checkpoint is ongoing, the fdatasync() calls force cache
flushes to be emitted to the storage.

This is achieved by flushing WAL only if the last flush was longer than
wal_writer_delay ago, or if more than wal_writer_flush_after (new GUC)
unflushed blocks are pending. Based on some tests the default for
wal_writer_delay is 1MB, which seems to work well both on SSD and
rotational media.

To avoid negative performance impact due to 4de82f7d7 an earlier
commit (db76b1e) made SetHintBits() more likely to succeed; preventing
performance regressions in the pgbench tests I performed.

Discussion: 20160118163908.GW10941@awork2.anarazel.de

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/7975c5e0a992ae9a45e03d145e0d37e2b5a707f5

Modified Files
--------------
doc/src/sgml/config.sgml                      |  41 +++++++---
src/backend/access/transam/README             |  32 ++++----
src/backend/access/transam/xlog.c             | 104 +++++++++++++++++++-------
src/backend/postmaster/walwriter.c            |   1 +
src/backend/utils/misc/guc.c                  |  13 +++-
src/backend/utils/misc/postgresql.conf.sample |   1 +
src/include/postmaster/walwriter.h            |   1 +
7 files changed, 141 insertions(+), 52 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


Message-ID: <E1aVTLE-00076m-NP@gemulon.postgresql.org>
Permalink:  ../E1aVTLE-00076m-NP@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1aVTLE-00076m-NP@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: andres@anarazel.de
  Subject: Re: pgsql: Allow the WAL writer to flush WAL at a reduced rate.
  In-Reply-To: <E1aVTLE-00076m-NP@gemulon.postgresql.org>
  References: <E1aVTLE-00076m-NP@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox