Rewrite background writer.
This currently consists out of two major parts:
1) Add more statistics, to be able to even evaluate the effects of
bgwriter changes / problems. This should probably be split into a
separate commit.
It's remarkable how odd the set of current measurements is, and how
many different mechanisms for transporting those values we
currently have. The patch adds and replaces a few measurements, but
doesn't yet do enough cleanup (have fewer transport mechanisms,
split into different views).
2) A new bgwriter implementation (that can be turned on by setting the
bgwriter_legacy GUC to false). There's a few major differences:
a) bgwriter performs the clock sweep - that makes it a lot easier
to actually find buffers worthwhile to clean. It's quite
possible to get into situations where the old bgwriter can't do
anything for a while because all buffers have a usagecount > 0.
b) When a buffer is encountered by bgwriter, after performing clock
sweep, is clean and has usage/pin count of 0 (i.e. it can be
reclaimed), then we also push it onto the queue.
c) It just has a ringbuffer of clean buffers, that backends can
drain. Bgwriter pushes (without any locks) entries onto the
queue, backends can pop them of.
d) The pacing logic is a lot simpler. There's a ringbuffer that
bgwriter tries to fill. There's a low watermark that causes
backends to wake up bgwriter.
16 files changed: