MySQL  8.0.19
Source Code Documentation
buf_pool_t Struct Reference

The buffer pool structure. More...

#include <buf0buf.h>

Public Attributes

General fields
BufListMutex chunks_mutex
 protects (de)allocation of chunks: More...
 
BufListMutex LRU_list_mutex
 LRU list mutex. More...
 
BufListMutex free_list_mutex
 free and withdraw list mutex More...
 
BufListMutex zip_free_mutex
 buddy allocator mutex More...
 
BufListMutex zip_hash_mutex
 zip_hash mutex More...
 
ib_mutex_t flush_state_mutex
 Flush state protection mutex. More...
 
BufPoolZipMutex zip_mutex
 Zip mutex of this buffer pool instance, protects compressed only pages (of type buf_page_t, not buf_block_t. More...
 
ulint instance_no
 Array index of this buffer pool instance. More...
 
ulint curr_pool_size
 Current pool size in bytes. More...
 
ulint LRU_old_ratio
 Reserve this much of the buffer pool for "old" blocks. More...
 
ulint buddy_n_frames
 Number of frames allocated from the buffer pool to the buddy system. More...
 
ut_allocator< unsigned char > allocator
 Allocator used for allocating memory for the the "chunks" member. More...
 
volatile ulint n_chunks
 number of buffer pool chunks More...
 
volatile ulint n_chunks_new
 new number of buffer pool chunks More...
 
buf_chunk_t * chunks
 buffer pool chunks More...
 
buf_chunk_t * chunks_old
 old buffer pool chunks to be freed after resizing buffer pool More...
 
ulint curr_size
 current pool size in pages More...
 
ulint old_size
 previous pool size in pages More...
 
page_no_t read_ahead_area
 size in pages of the area which the read-ahead algorithms read if invoked More...
 
hash_table_tpage_hash
 hash table of buf_page_t or buf_block_t file pages, buf_page_in_file() == TRUE, indexed by (space_id, offset). More...
 
hash_table_tpage_hash_old
 old pointer to page_hash to be freed after resizing buffer pool More...
 
hash_table_tzip_hash
 hash table of buf_block_t blocks whose frames are allocated to the zip buddy system, indexed by block->frame More...
 
ulint n_pend_reads
 number of pending read operations. More...
 
ulint n_pend_unzip
 number of pending decompressions. More...
 
ib_time_monotonic_t last_printout_time
 when buf_print_io was last time called. More...
 
buf_buddy_stat_t buddy_stat [BUF_BUDDY_SIZES_MAX+1]
 Statistics of buddy system, indexed by block size. More...
 
buf_pool_stat_t stat
 current statistics More...
 
buf_pool_stat_t old_stat
 old statistics More...
 

Page flushing algorithm fields

BufListMutex flush_list_mutex
 mutex protecting the flush list access. More...
 
FlushHp flush_hp
 "hazard pointer" used during scan of flush_list while doing flush list batch. More...
 
ibool init_flush [BUF_FLUSH_N_TYPES]
 this is TRUE when a flush of the given type is being initialized. More...
 
ulint n_flush [BUF_FLUSH_N_TYPES]
 this is the number of pending writes in the given flush type. More...
 
os_event_t no_flush [BUF_FLUSH_N_TYPES]
 this is in the set state when there is no flush batch of the given type running. More...
 
ib_rbt_tflush_rbt
 a red-black tree is used exclusively during recovery to speed up insertions in the flush_list. More...
 
ulint freed_page_clock
 a sequence number used to count the number of buffer blocks removed from the end of the LRU list; NOTE that this counter may wrap around at 4 billion! A thread is allowed to read this for heuristic purposes without holding any mutex or latch. More...
 
ibool try_LRU_scan
 Set to FALSE when an LRU scan for free block fails. More...
 
lsn_t track_page_lsn
 
lsn_t max_lsn_io
 
 UT_LIST_BASE_NODE_T (buf_page_t) flush_list
 base node of the modified block list More...
 

LRU replacement algorithm fields

ulint withdraw_target
 target length of withdraw block list, when withdrawing More...
 
LRUHp lru_hp
 "hazard pointer" used during scan of LRU while doing LRU list batch. More...
 
LRUItr lru_scan_itr
 Iterator used to scan the LRU list when searching for replacable victim. More...
 
LRUItr single_scan_itr
 Iterator used to scan the LRU list when searching for single page flushing victim. More...
 
buf_page_tLRU_old
 pointer to the about LRU_old_ratio/BUF_LRU_OLD_RATIO_DIV oldest blocks in the LRU list; NULL if LRU length less than BUF_LRU_OLD_MIN_LEN; NOTE: when LRU_old != NULL, its length should always equal LRU_old_len More...
 
ulint LRU_old_len
 length of the LRU list from the block to which LRU_old points onward, including that block; see buf0lru.cc for the restrictions on this value; 0 if LRU_old == NULL; NOTE: LRU_old_len must be adjusted whenever LRU_old shrinks or grows! More...
 
 UT_LIST_BASE_NODE_T (buf_page_t) free
 base node of the free block list More...
 
 UT_LIST_BASE_NODE_T (buf_page_t) withdraw
 base node of the withdraw block list. More...
 
 UT_LIST_BASE_NODE_T (buf_page_t) LRU
 base node of the LRU list More...
 
 UT_LIST_BASE_NODE_T (buf_block_t) unzip_LRU
 base node of the unzip_LRU list. More...
 

Buddy allocator fields

The buddy allocator is used for allocating compressed page frames and buf_page_t descriptors of blocks that exist in the buffer pool only in compressed form.

buf_page_twatch
 Sentinel records for buffer pool watches. More...
 
 UT_LIST_BASE_NODE_T (buf_page_t) zip_clean
 unmodified compressed pages More...
 
 UT_LIST_BASE_NODE_T (buf_buddy_free_t) zip_free[BUF_BUDDY_SIZES_MAX]
 buddy free lists More...
 
bool allocate_chunk (ulonglong mem_size, buf_chunk_t *chunk)
 A wrapper for buf_pool_t::allocator.alocate_large which also advices the OS that this chunk should not be dumped to a core file if that was requested. More...
 
void deallocate_chunk (buf_chunk_t *chunk)
 A wrapper for buf_pool_t::allocator.deallocate_large which also advices the OS that this chunk can be dumped to a core file. More...
 
bool madvise_dump ()
 Advices the OS that all chunks in this buffer pool instance can be dumped to a core file. More...
 
bool madvise_dont_dump ()
 Advices the OS that all chunks in this buffer pool instance should not be dumped to a core file. More...
 

Detailed Description

The buffer pool structure.

NOTE! The definition appears here only for other modules of this directory (buf) to see it. Do not use from outside!

Member Function Documentation

◆ allocate_chunk()

bool buf_pool_t::allocate_chunk ( ulonglong  mem_size,
buf_chunk_t *  chunk 
)

A wrapper for buf_pool_t::allocator.alocate_large which also advices the OS that this chunk should not be dumped to a core file if that was requested.

Emits a warning to the log and disables @global.core_file if advising was requested but could not be performed, but still return true as the allocation itself succeeded.

Parameters
[in]mem_sizenumber of bytes to allocate
[in,out]chunkmem and mem_pfx fields of this chunk will be updated to contain information about allocated memory region
Returns
true iff allocated successfully

◆ deallocate_chunk()

void buf_pool_t::deallocate_chunk ( buf_chunk_t *  chunk)

A wrapper for buf_pool_t::allocator.deallocate_large which also advices the OS that this chunk can be dumped to a core file.

Emits a warning to the log and disables @global.core_file if advising was requested but could not be performed.

Parameters
[in]chunkmem and mem_pfx fields of this chunk will be used to locate the memory region to free

◆ madvise_dont_dump()

bool buf_pool_t::madvise_dont_dump ( )

Advices the OS that all chunks in this buffer pool instance should not be dumped to a core file.

Emits a warning to the log if could not succeed.

Returns
true iff succeeded, false if no OS support or failed

◆ madvise_dump()

bool buf_pool_t::madvise_dump ( )

Advices the OS that all chunks in this buffer pool instance can be dumped to a core file.

Emits a warning to the log if could not succeed.

Returns
true iff succeeded, false if no OS support or failed

◆ UT_LIST_BASE_NODE_T() [1/7]

buf_pool_t::UT_LIST_BASE_NODE_T ( buf_block_t  )

base node of the unzip_LRU list.

The list is protected by LRU_list_mutex.

◆ UT_LIST_BASE_NODE_T() [2/7]

buf_pool_t::UT_LIST_BASE_NODE_T ( buf_buddy_free_t  )

buddy free lists

◆ UT_LIST_BASE_NODE_T() [3/7]

buf_pool_t::UT_LIST_BASE_NODE_T ( buf_page_t  )

base node of the modified block list

◆ UT_LIST_BASE_NODE_T() [4/7]

buf_pool_t::UT_LIST_BASE_NODE_T ( buf_page_t  )

base node of the free block list

◆ UT_LIST_BASE_NODE_T() [5/7]

buf_pool_t::UT_LIST_BASE_NODE_T ( buf_page_t  )

base node of the LRU list

◆ UT_LIST_BASE_NODE_T() [6/7]

buf_pool_t::UT_LIST_BASE_NODE_T ( buf_page_t  )

base node of the withdraw block list.

It is only used during shrinking buffer pool size, not to reuse the blocks will be removed. Protected by free_list_mutex

◆ UT_LIST_BASE_NODE_T() [7/7]

buf_pool_t::UT_LIST_BASE_NODE_T ( buf_page_t  )

unmodified compressed pages

Member Data Documentation

◆ allocator

ut_allocator<unsigned char> buf_pool_t::allocator

Allocator used for allocating memory for the the "chunks" member.

◆ buddy_n_frames

ulint buf_pool_t::buddy_n_frames

Number of frames allocated from the buffer pool to the buddy system.

Protected by zip_hash_mutex.

◆ buddy_stat

buf_buddy_stat_t buf_pool_t::buddy_stat[BUF_BUDDY_SIZES_MAX+1]

Statistics of buddy system, indexed by block size.

Protected by zip_free mutex, except for the used field, which is also accessed atomically

◆ chunks

buf_chunk_t* buf_pool_t::chunks

buffer pool chunks

◆ chunks_mutex

BufListMutex buf_pool_t::chunks_mutex

protects (de)allocation of chunks:

  • changes to chunks, n_chunks are performed while holding this latch,
  • reading buf_pool_should_madvise requires holding this latch for any buf_pool_t
  • writing to buf_pool_should_madvise requires holding these latches for all buf_pool_t-s

◆ chunks_old

buf_chunk_t* buf_pool_t::chunks_old

old buffer pool chunks to be freed after resizing buffer pool

◆ curr_pool_size

ulint buf_pool_t::curr_pool_size

Current pool size in bytes.

◆ curr_size

ulint buf_pool_t::curr_size

current pool size in pages

◆ flush_hp

FlushHp buf_pool_t::flush_hp

"hazard pointer" used during scan of flush_list while doing flush list batch.

Protected by flush_list_mutex

◆ flush_list_mutex

BufListMutex buf_pool_t::flush_list_mutex

mutex protecting the flush list access.

This mutex protects flush_list, flush_rbt and bpage::list pointers when the bpage is on flush_list. It also protects writes to bpage::oldest_modification and flush_list_hp

◆ flush_rbt

ib_rbt_t* buf_pool_t::flush_rbt

a red-black tree is used exclusively during recovery to speed up insertions in the flush_list.

This tree contains blocks in order of oldest_modification LSN and is kept in sync with the flush_list. Each member of the tree MUST also be on the flush_list. This tree is relevant only in recovery and is set to NULL once the recovery is over. Protected by flush_list_mutex

◆ flush_state_mutex

ib_mutex_t buf_pool_t::flush_state_mutex

Flush state protection mutex.

◆ free_list_mutex

BufListMutex buf_pool_t::free_list_mutex

free and withdraw list mutex

◆ freed_page_clock

ulint buf_pool_t::freed_page_clock

a sequence number used to count the number of buffer blocks removed from the end of the LRU list; NOTE that this counter may wrap around at 4 billion! A thread is allowed to read this for heuristic purposes without holding any mutex or latch.

For non-heuristic purposes protected by LRU_list_mutex

◆ init_flush

ibool buf_pool_t::init_flush[BUF_FLUSH_N_TYPES]

this is TRUE when a flush of the given type is being initialized.

Protected by flush_state_mutex.

◆ instance_no

ulint buf_pool_t::instance_no

Array index of this buffer pool instance.

◆ last_printout_time

ib_time_monotonic_t buf_pool_t::last_printout_time

when buf_print_io was last time called.

Accesses not protected.

◆ lru_hp

LRUHp buf_pool_t::lru_hp

"hazard pointer" used during scan of LRU while doing LRU list batch.

Protected by buf_pool::LRU_list_mutex

◆ LRU_list_mutex

BufListMutex buf_pool_t::LRU_list_mutex

LRU list mutex.

◆ LRU_old

buf_page_t* buf_pool_t::LRU_old

pointer to the about LRU_old_ratio/BUF_LRU_OLD_RATIO_DIV oldest blocks in the LRU list; NULL if LRU length less than BUF_LRU_OLD_MIN_LEN; NOTE: when LRU_old != NULL, its length should always equal LRU_old_len

◆ LRU_old_len

ulint buf_pool_t::LRU_old_len

length of the LRU list from the block to which LRU_old points onward, including that block; see buf0lru.cc for the restrictions on this value; 0 if LRU_old == NULL; NOTE: LRU_old_len must be adjusted whenever LRU_old shrinks or grows!

◆ LRU_old_ratio

ulint buf_pool_t::LRU_old_ratio

Reserve this much of the buffer pool for "old" blocks.

◆ lru_scan_itr

LRUItr buf_pool_t::lru_scan_itr

Iterator used to scan the LRU list when searching for replacable victim.

Protected by buf_pool::LRU_list_mutex.

◆ max_lsn_io

lsn_t buf_pool_t::max_lsn_io

◆ n_chunks

volatile ulint buf_pool_t::n_chunks

number of buffer pool chunks

◆ n_chunks_new

volatile ulint buf_pool_t::n_chunks_new

new number of buffer pool chunks

◆ n_flush

ulint buf_pool_t::n_flush[BUF_FLUSH_N_TYPES]

this is the number of pending writes in the given flush type.

Protected by flush_state_mutex.

◆ n_pend_reads

ulint buf_pool_t::n_pend_reads

number of pending read operations.

Accessed atomically

◆ n_pend_unzip

ulint buf_pool_t::n_pend_unzip

number of pending decompressions.

Accessed atomically.

◆ no_flush

os_event_t buf_pool_t::no_flush[BUF_FLUSH_N_TYPES]

this is in the set state when there is no flush batch of the given type running.

Protected by flush_state_mutex.

◆ old_size

ulint buf_pool_t::old_size

previous pool size in pages

◆ old_stat

buf_pool_stat_t buf_pool_t::old_stat

old statistics

◆ page_hash

hash_table_t* buf_pool_t::page_hash

hash table of buf_page_t or buf_block_t file pages, buf_page_in_file() == TRUE, indexed by (space_id, offset).

page_hash is protected by an array of mutexes.

◆ page_hash_old

hash_table_t* buf_pool_t::page_hash_old

old pointer to page_hash to be freed after resizing buffer pool

◆ read_ahead_area

page_no_t buf_pool_t::read_ahead_area

size in pages of the area which the read-ahead algorithms read if invoked

◆ single_scan_itr

LRUItr buf_pool_t::single_scan_itr

Iterator used to scan the LRU list when searching for single page flushing victim.

Protected by buf_pool::LRU_list_mutex.

◆ stat

buf_pool_stat_t buf_pool_t::stat

current statistics

◆ track_page_lsn

lsn_t buf_pool_t::track_page_lsn

◆ try_LRU_scan

ibool buf_pool_t::try_LRU_scan

Set to FALSE when an LRU scan for free block fails.

This flag is used to avoid repeated scans of LRU list when we know that there is no free block available in the scan depth for eviction. Set to TRUE whenever we flush a batch from the buffer pool. Accessed protected by memory barriers.

◆ watch

buf_page_t* buf_pool_t::watch

Sentinel records for buffer pool watches.

Scanning the array is protected by taking all page_hash latches in X. Updating or reading an individual watch page is protected by a corresponding individual page_hash latch.

◆ withdraw_target

ulint buf_pool_t::withdraw_target

target length of withdraw block list, when withdrawing

◆ zip_free_mutex

BufListMutex buf_pool_t::zip_free_mutex

buddy allocator mutex

◆ zip_hash

hash_table_t* buf_pool_t::zip_hash

hash table of buf_block_t blocks whose frames are allocated to the zip buddy system, indexed by block->frame

◆ zip_hash_mutex

BufListMutex buf_pool_t::zip_hash_mutex

zip_hash mutex

◆ zip_mutex

BufPoolZipMutex buf_pool_t::zip_mutex

Zip mutex of this buffer pool instance, protects compressed only pages (of type buf_page_t, not buf_block_t.


The documentation for this struct was generated from the following files: