diff options
| author | Andres Freund | 2016-02-19 20:17:51 +0000 |
|---|---|---|
| committer | Andres Freund | 2016-03-11 01:05:09 +0000 |
| commit | 9cd00c457e6a1ebb984167ac556a9961812a683c (patch) | |
| tree | 1d2857a1ef71d9031651a665b2c754a89d813718 /src/include | |
| parent | 428b1d6b29ca599c5700d4bc4f4ce4c5880369bf (diff) | |
Checkpoint sorting and balancing.
Up to now checkpoints were written in the order they're in the
BufferDescriptors. That's nearly random in a lot of cases, which
performs badly on rotating media, but even on SSDs it causes slowdowns.
To avoid that, sort checkpoints before writing them out. We currently
sort by tablespace, relfilenode, fork and block number.
One of the major reasons that previously wasn't done, was fear of
imbalance between tablespaces. To address that balance writes between
tablespaces.
The other prime concern was that the relatively large allocation to sort
the buffers in might fail, preventing checkpoints from happening. Thus
pre-allocate the required memory in shared memory, at server startup.
This particularly makes it more efficient to have checkpoint flushing
enabled, because that'll often result in a lot of writes that can be
coalesced into one flush.
Discussion: alpine.DEB.2.10.1506011320000.28433@sto
Author: Fabien Coelho and Andres Freund
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/storage/buf_internals.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/include/storage/buf_internals.h b/src/include/storage/buf_internals.h index af050419f7f..d04363b1665 100644 --- a/src/include/storage/buf_internals.h +++ b/src/include/storage/buf_internals.h @@ -239,6 +239,24 @@ extern PGDLLIMPORT WritebackContext BackendWritebackContext; /* in localbuf.c */ extern BufferDesc *LocalBufferDescriptors; +/* in bufmgr.c */ + +/* + * Structure to sort buffers per file on checkpoints. + * + * This structure is allocated per buffer in shared memory, so it should be + * kept as small as possible. + */ +typedef struct CkptSortItem +{ + Oid tsId; + Oid relNode; + ForkNumber forkNum; + BlockNumber blockNum; + int buf_id; +} CkptSortItem; + +extern CkptSortItem *CkptBufferIds; /* * Internal buffer management routines |
