pgsql: Allow the WAL writer to flush WAL at a reduced rate. - Mailing list pgsql-committers

From Andres Freund
Subject pgsql: Allow the WAL writer to flush WAL at a reduced rate.
Date
Msg-id E1aVTLE-00076m-NP@gemulon.postgresql.org
Whole thread Raw
List pgsql-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(-)


pgsql-committers by date:

Previous
From: Alvaro Herrera
Date:
Subject: pgsql: pgbench: avoid FD_ISSET on an invalid file descriptor
Next
From: Joe Conway
Date:
Subject: pgsql: Move DATA entry to correct position