• Andres Freund's avatar
    Checkpoint sorting and balancing. · 9cd00c45
    Andres Freund authored
    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
    9cd00c45
buf_internals.h 10.5 KB