PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/xlogprefetcher.h"
#include "access/xlogreader.h"
#include "catalog/pg_control.h"
#include "catalog/storage_xlog.h"
#include "commands/dbcommands_xlog.h"
#include "funcapi.h"
#include "miscadmin.h"
#include "port/atomics.h"
#include "storage/bufmgr.h"
#include "storage/shmem.h"
#include "storage/smgr.h"
#include "utils/fmgrprotos.h"
#include "utils/guc_hooks.h"
#include "utils/hsearch.h"
#include "utils/timestamp.h"
Go to the source code of this file.
Data Structures | |
struct | LsnReadQueue |
struct | XLogPrefetcher |
struct | XLogPrefetcherFilter |
struct | XLogPrefetchStats |
Macros | |
#define | XLOGPREFETCHER_STATS_DISTANCE BLCKSZ |
#define | XLOGPREFETCHER_SEQ_WINDOW_SIZE 4 |
#define | XLOGPREFETCHER_DISTANCE_MULTIPLIER 4 |
#define | RecoveryPrefetchEnabled() false |
#define | PG_STAT_GET_RECOVERY_PREFETCH_COLS 10 |
Typedefs | |
typedef LsnReadQueueNextStatus(* | LsnReadQueueNextFun) (uintptr_t lrq_private, XLogRecPtr *lsn) |
typedef struct LsnReadQueue | LsnReadQueue |
typedef struct XLogPrefetcherFilter | XLogPrefetcherFilter |
typedef struct XLogPrefetchStats | XLogPrefetchStats |
Enumerations | |
enum | LsnReadQueueNextStatus { LRQ_NEXT_NO_IO , LRQ_NEXT_IO , LRQ_NEXT_AGAIN } |
Variables | |
int | recovery_prefetch = RECOVERY_PREFETCH_TRY |
static int | XLogPrefetchReconfigureCount = 0 |
static XLogPrefetchStats * | SharedStats |
#define PG_STAT_GET_RECOVERY_PREFETCH_COLS 10 |
#define RecoveryPrefetchEnabled | ( | ) | false |
Definition at line 75 of file xlogprefetcher.c.
#define XLOGPREFETCHER_DISTANCE_MULTIPLIER 4 |
Definition at line 62 of file xlogprefetcher.c.
#define XLOGPREFETCHER_SEQ_WINDOW_SIZE 4 |
Definition at line 56 of file xlogprefetcher.c.
#define XLOGPREFETCHER_STATS_DISTANCE BLCKSZ |
Definition at line 50 of file xlogprefetcher.c.
typedef struct LsnReadQueue LsnReadQueue |
typedef LsnReadQueueNextStatus(* LsnReadQueueNextFun) (uintptr_t lrq_private, XLogRecPtr *lsn) |
Definition at line 94 of file xlogprefetcher.c.
typedef struct XLogPrefetcherFilter XLogPrefetcherFilter |
typedef struct XLogPrefetchStats XLogPrefetchStats |
void assign_recovery_prefetch | ( | int | new_value, |
void * | extra | ||
) |
Definition at line 1095 of file xlogprefetcher.c.
References AmStartupProcess, recovery_prefetch, and XLogPrefetchReconfigure().
Definition at line 1081 of file xlogprefetcher.c.
References GUC_check_errdetail, and RECOVERY_PREFETCH_ON.
|
inlinestatic |
Definition at line 202 of file xlogprefetcher.c.
References Assert, LsnReadQueue::completed, LsnReadQueue::head, LsnReadQueue::inflight, LsnReadQueue::lrq_private, LsnReadQueue::max_inflight, next, LsnReadQueue::next, palloc(), LsnReadQueue::queue, LsnReadQueue::size, size, and LsnReadQueue::tail.
Referenced by XLogPrefetcherReadRecord().
|
inlinestatic |
Definition at line 272 of file xlogprefetcher.c.
References LsnReadQueue::completed, LsnReadQueue::head, LsnReadQueue::inflight, LsnReadQueue::io, lrq_prefetch(), LsnReadQueue::lsn, LsnReadQueue::queue, RecoveryPrefetchEnabled, LsnReadQueue::size, and LsnReadQueue::tail.
Referenced by XLogPrefetcherReadRecord().
|
inlinestatic |
Definition at line 239 of file xlogprefetcher.c.
References LsnReadQueue::completed.
Referenced by XLogPrefetcherComputeStats(), and XLogPrefetcherReadRecord().
|
inlinestatic |
Definition at line 227 of file xlogprefetcher.c.
References pfree().
Referenced by XLogPrefetcherFree(), and XLogPrefetcherReadRecord().
|
inlinestatic |
Definition at line 233 of file xlogprefetcher.c.
References LsnReadQueue::inflight.
Referenced by XLogPrefetcherComputeStats(), and XLogPrefetcherReadRecord().
|
inlinestatic |
Definition at line 245 of file xlogprefetcher.c.
References Assert, LsnReadQueue::completed, LsnReadQueue::head, LsnReadQueue::inflight, LsnReadQueue::io, LRQ_NEXT_AGAIN, LRQ_NEXT_IO, LRQ_NEXT_NO_IO, LsnReadQueue::lrq_private, LsnReadQueue::lsn, LsnReadQueue::max_inflight, LsnReadQueue::next, LsnReadQueue::queue, LsnReadQueue::size, and LsnReadQueue::tail.
Referenced by lrq_complete_lsn(), and XLogPrefetcherReadRecord().
Datum pg_stat_get_recovery_prefetch | ( | PG_FUNCTION_ARGS | ) |
Definition at line 824 of file xlogprefetcher.c.
References XLogPrefetchStats::block_distance, XLogPrefetchStats::hit, i, InitMaterializedSRF(), Int32GetDatum(), Int64GetDatum(), XLogPrefetchStats::io_depth, pg_atomic_read_u64(), PG_STAT_GET_RECOVERY_PREFETCH_COLS, XLogPrefetchStats::prefetch, XLogPrefetchStats::reset_time, ReturnSetInfo::setDesc, ReturnSetInfo::setResult, SharedStats, XLogPrefetchStats::skip_fpw, XLogPrefetchStats::skip_init, XLogPrefetchStats::skip_new, XLogPrefetchStats::skip_rep, TimestampTzGetDatum(), tuplestore_putvalues(), values, and XLogPrefetchStats::wal_distance.
|
inlinestatic |
Definition at line 856 of file xlogprefetcher.c.
References dlist_delete(), dlist_push_head(), XLogPrefetcherFilter::filter_from_block, XLogPrefetcher::filter_queue, XLogPrefetcher::filter_table, XLogPrefetcherFilter::filter_until_replayed, HASH_ENTER, hash_search(), XLogPrefetcherFilter::link, and Min.
Referenced by XLogPrefetcherNextBlock().
XLogPrefetcher* XLogPrefetcherAllocate | ( | XLogReaderState * | reader | ) |
Definition at line 362 of file xlogprefetcher.c.
References XLogPrefetchStats::block_distance, ctl, dlist_init(), XLogPrefetcher::filter_queue, XLogPrefetcher::filter_table, HASH_BLOBS, hash_create(), HASH_ELEM, XLogPrefetchStats::io_depth, palloc0(), XLogPrefetcher::reader, XLogPrefetcher::reconfigure_count, SharedStats, XLogPrefetchStats::wal_distance, and XLogPrefetchReconfigureCount.
Referenced by InitWalRecovery().
void XLogPrefetcherBeginRead | ( | XLogPrefetcher * | prefetcher, |
XLogRecPtr | recPtr | ||
) |
Definition at line 962 of file xlogprefetcher.c.
References XLogPrefetcher::begin_ptr, XLogPrefetcher::no_readahead_until, XLogPrefetcher::reader, XLogPrefetcher::reconfigure_count, and XLogBeginRead().
Referenced by FinishWalRecovery(), InitWalRecovery(), PerformWalRecovery(), and ReadCheckpointRecord().
|
inlinestatic |
Definition at line 894 of file xlogprefetcher.c.
References dlist_delete(), dlist_is_empty(), dlist_tail_element, XLogPrefetcher::filter_queue, XLogPrefetcher::filter_table, XLogPrefetcherFilter::filter_until_replayed, HASH_REMOVE, hash_search(), XLogPrefetcherFilter::link, and unlikely.
Referenced by XLogPrefetcherReadRecord().
void XLogPrefetcherComputeStats | ( | XLogPrefetcher * | prefetcher | ) |
Definition at line 410 of file xlogprefetcher.c.
References XLogPrefetchStats::block_distance, XLogReaderState::decode_queue_head, XLogReaderState::decode_queue_tail, XLogPrefetchStats::io_depth, lrq_completed(), lrq_inflight(), DecodedXLogRecord::lsn, XLogPrefetcher::next_stats_shm_lsn, XLogPrefetcher::reader, XLogReaderState::ReadRecPtr, SharedStats, XLogPrefetcher::streaming_read, XLogPrefetchStats::wal_distance, and XLOGPREFETCHER_STATS_DISTANCE.
Referenced by ShutdownWalRecovery(), WaitForWALToBecomeAvailable(), and XLogPrefetcherReadRecord().
void XLogPrefetcherFree | ( | XLogPrefetcher * | prefetcher | ) |
Definition at line 390 of file xlogprefetcher.c.
References XLogPrefetcher::filter_table, hash_destroy(), lrq_free(), pfree(), and XLogPrefetcher::streaming_read.
Referenced by ShutdownWalRecovery().
XLogReaderState* XLogPrefetcherGetReader | ( | XLogPrefetcher * | prefetcher | ) |
Definition at line 401 of file xlogprefetcher.c.
References XLogPrefetcher::reader.
Referenced by ReadRecord().
|
inlinestatic |
Definition at line 914 of file xlogprefetcher.c.
References RelFileLocator::dbOid, dlist_is_empty(), elog, XLogPrefetcherFilter::filter_from_block, XLogPrefetcher::filter_queue, XLogPrefetcher::filter_table, XLogPrefetcherFilter::filter_until_replayed, HASH_FIND, hash_search(), InvalidOid, InvalidRelFileNumber, LSN_FORMAT_ARGS, RelFileLocator::relNumber, RelFileLocator::spcOid, and unlikely.
Referenced by XLogPrefetcherNextBlock().
|
static |
Definition at line 459 of file xlogprefetcher.c.
References Assert, XLogPrefetcher::begin_ptr, BKPBLOCK_WILL_INIT, DecodedBkpBlock::blkno, xl_smgr_truncate::blkno, BufferIsValid(), xl_dbase_create_file_copy_rec::db_id, RelFileLocator::dbOid, XLogReaderState::decode_queue_tail, elog, ERROR, DecodedBkpBlock::flags, DecodedBkpBlock::forknum, xl_smgr_create::forkNum, DecodedBkpBlock::has_image, DecodedXLogRecord::header, XLogPrefetchStats::hit, i, if(), DecodedBkpBlock::in_use, PrefetchBufferResult::initiated_io, INVALID_PROC_NUMBER, InvalidBuffer, InvalidOid, InvalidRelFileNumber, InvalidXLogRecPtr, IO_DIRECT_DATA, io_direct_flags, RelFileLocatorBackend::locator, LRQ_NEXT_AGAIN, LRQ_NEXT_IO, LRQ_NEXT_NO_IO, DecodedXLogRecord::lsn, LSN_FORMAT_ARGS, DecodedXLogRecord::main_data, MAIN_FORKNUM, XLogPrefetcher::next_block_id, XLogPrefetcher::no_readahead_until, XLogPrefetchStats::prefetch, DecodedBkpBlock::prefetch_buffer, PrefetchSharedBuffer(), XLogPrefetcher::reader, XLogReaderState::ReadRecPtr, XLogPrefetcher::recent_block, PrefetchBufferResult::recent_buffer, XLogPrefetcher::recent_idx, XLogPrefetcher::recent_rlocator, XLogPrefetcher::record, RecoveryPrefetchEnabled, RelFileLocatorEquals, RelFileLocator::relNumber, DecodedBkpBlock::rlocator, xl_smgr_create::rlocator, xl_smgr_truncate::rlocator, SharedStats, XLogPrefetchStats::skip_fpw, XLogPrefetchStats::skip_init, XLogPrefetchStats::skip_new, XLogPrefetchStats::skip_rep, SMgrRelationData::smgr_rlocator, smgrexists(), smgrnblocks(), smgropen(), RelFileLocator::spcOid, XLogRecord::xl_info, XLogRecord::xl_rmid, XLOG_CHECKPOINT_SHUTDOWN, XLOG_DBASE_CREATE_FILE_COPY, XLOG_END_OF_RECOVERY, XLOG_SMGR_CREATE, XLOG_SMGR_TRUNCATE, XLOGPREFETCHER_SEQ_WINDOW_SIZE, XLogPrefetcherAddFilter(), XLogPrefetcherIsFiltered(), XLogPrefetchIncrement(), XLogReadAhead(), XLogReaderHasQueuedRecordOrError(), and XLR_INFO_MASK.
Referenced by XLogPrefetcherReadRecord().
XLogRecord* XLogPrefetcherReadRecord | ( | XLogPrefetcher * | prefetcher, |
char ** | errmsg | ||
) |
Definition at line 981 of file xlogprefetcher.c.
References Assert, errmsg(), DecodedXLogRecord::header, lrq_alloc(), lrq_complete_lsn(), lrq_completed(), lrq_free(), lrq_inflight(), lrq_prefetch(), DecodedXLogRecord::lsn, maintenance_io_concurrency, XLogPrefetcher::next_stats_shm_lsn, XLogPrefetcher::reader, XLogPrefetcher::reconfigure_count, XLogPrefetcher::record, XLogReaderState::record, RecoveryPrefetchEnabled, XLogPrefetcher::streaming_read, unlikely, XLogNextRecord(), XLOGPREFETCHER_DISTANCE_MULTIPLIER, XLogPrefetcherCompleteFilters(), XLogPrefetcherComputeStats(), XLogPrefetcherNextBlock(), XLogPrefetchReconfigureCount, XLogReaderHasQueuedRecordOrError(), and XLogReleasePreviousRecord().
Referenced by ReadRecord().
|
inlinestatic |
Definition at line 351 of file xlogprefetcher.c.
References AmStartupProcess, Assert, IsUnderPostmaster, pg_atomic_read_u64(), and pg_atomic_write_u64().
Referenced by XLogPrefetcherNextBlock().
void XLogPrefetchReconfigure | ( | void | ) |
Definition at line 340 of file xlogprefetcher.c.
References XLogPrefetchReconfigureCount.
Referenced by ApplyWalRecord(), assign_maintenance_io_concurrency(), and assign_recovery_prefetch().
void XLogPrefetchResetStats | ( | void | ) |
Definition at line 303 of file xlogprefetcher.c.
References GetCurrentTimestamp(), XLogPrefetchStats::hit, pg_atomic_write_u64(), XLogPrefetchStats::prefetch, XLogPrefetchStats::reset_time, SharedStats, XLogPrefetchStats::skip_fpw, XLogPrefetchStats::skip_init, XLogPrefetchStats::skip_new, and XLogPrefetchStats::skip_rep.
Referenced by pg_stat_reset_shared().
void XLogPrefetchShmemInit | ( | void | ) |
Definition at line 315 of file xlogprefetcher.c.
References GetCurrentTimestamp(), XLogPrefetchStats::hit, pg_atomic_init_u64(), XLogPrefetchStats::prefetch, XLogPrefetchStats::reset_time, SharedStats, ShmemInitStruct(), XLogPrefetchStats::skip_fpw, XLogPrefetchStats::skip_init, XLogPrefetchStats::skip_new, and XLogPrefetchStats::skip_rep.
Referenced by CreateOrAttachShmemStructs().
size_t XLogPrefetchShmemSize | ( | void | ) |
Definition at line 294 of file xlogprefetcher.c.
Referenced by CalculateShmemSize().
int recovery_prefetch = RECOVERY_PREFETCH_TRY |
Definition at line 68 of file xlogprefetcher.c.
Referenced by assign_recovery_prefetch().
|
static |
Definition at line 199 of file xlogprefetcher.c.
Referenced by pg_stat_get_recovery_prefetch(), XLogPrefetcherAllocate(), XLogPrefetcherComputeStats(), XLogPrefetcherNextBlock(), XLogPrefetchResetStats(), and XLogPrefetchShmemInit().
|
static |
Definition at line 78 of file xlogprefetcher.c.
Referenced by XLogPrefetcherAllocate(), XLogPrefetcherReadRecord(), and XLogPrefetchReconfigure().