MySQL 8.4.3
Source Code Documentation
|
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... | |
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_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). More... | |
hash_table_t * | zip_hash |
Hash table of buf_block_t blocks whose frames are allocated to the zip buddy system, indexed by block->frame. More... | |
std::atomic< ulint > | n_pend_reads |
Number of pending read operations. More... | |
std::atomic< ulint > | n_pend_unzip |
number of pending decompressions. More... | |
std::chrono::steady_clock::time_point | 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... | |
FlushHp | oldest_hp |
Entry pointer to scan the oldest page except for system temporary. More... | |
bool | init_flush [BUF_FLUSH_N_TYPES] |
This is true when a flush of the given type is being initialized. More... | |
std::array< size_t, BUF_FLUSH_N_TYPES > | n_flush |
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_t * | flush_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... | |
bool | try_LRU_scan |
Set to false when an LRU scan for free block fails. More... | |
lsn_t | track_page_lsn |
Page Tracking start LSN. More... | |
lsn_t | max_lsn_io |
Maximum LSN for which write io has already started. More... | |
UT_LIST_BASE_NODE_T (buf_page_t, list) flush_list | |
Base node of the modified block list. More... | |
bool | is_tracking () |
Check if the page modifications are tracked. 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 replaceable victim. More... | |
LRUItr | single_scan_itr |
Iterator used to scan the LRU list when searching for single page flushing victim. More... | |
buf_page_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. 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, list) free | |
Base node of the free block list. More... | |
UT_LIST_BASE_NODE_T (buf_page_t, list) withdraw | |
base node of the withdraw block list. More... | |
UT_LIST_BASE_NODE_T (buf_page_t, LRU) LRU | |
Base node of the LRU list. More... | |
UT_LIST_BASE_NODE_T (buf_block_t, unzip_LRU) 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_t * | watch |
Sentinel records for buffer pool watches. More... | |
UT_LIST_BASE_NODE_T (buf_page_t, list) zip_clean | |
Unmodified compressed pages. More... | |
UT_LIST_BASE_NODE_T (buf_buddy_free_t, list) 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... | |
bool | is_flushing (buf_flush_t flush_type) const |
Checks if the batch is running, which is basically equivalent to !os_event_is_set(no_flush[type]) if you hold flush_state_mutex. More... | |
template<typename F > | |
void | change_flush_state (buf_flush_t flush_type, F &&change) |
Executes change() which modifies fields protected by flush_state_mutex. More... | |
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!
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.
[in] | mem_size | number of bytes to allocate |
[in,out] | chunk | mem and mem_pfx fields of this chunk will be updated to contain information about allocated memory region |
|
inline |
Executes change() which modifies fields protected by flush_state_mutex.
If it caused a change to is_flushing(flush_type) then it sets or resets the no_flush[flush_type] to keep it in sync.
[in] | flush_type | The type of the flush this change of state concerns |
[in] | change | A callback to execute within flush_state_mutex |
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.
[in] | chunk | mem and mem_pfx fields of this chunk will be used to locate the memory region to free |
|
inline |
Checks if the batch is running, which is basically equivalent to !os_event_is_set(no_flush[type]) if you hold flush_state_mutex.
It is used as source of truth to know when to set or reset this event. Caller should hold flush_state_mutex.
[in] | flush_type | The type of the flush we are interested in |
|
inline |
Check if the page modifications are tracked.
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.
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.
buf_pool_t::UT_LIST_BASE_NODE_T | ( | buf_block_t | , |
unzip_LRU | |||
) |
Base node of the unzip_LRU list.
The list is protected by the LRU_list_mutex.
buf_pool_t::UT_LIST_BASE_NODE_T | ( | buf_buddy_free_t | , |
list | |||
) |
Buddy free lists.
buf_pool_t::UT_LIST_BASE_NODE_T | ( | buf_page_t | , |
list | |||
) |
Base node of the modified block list.
buf_pool_t::UT_LIST_BASE_NODE_T | ( | buf_page_t | , |
list | |||
) |
Base node of the free block list.
buf_pool_t::UT_LIST_BASE_NODE_T | ( | buf_page_t | , |
list | |||
) |
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
buf_pool_t::UT_LIST_BASE_NODE_T | ( | buf_page_t | , |
list | |||
) |
Unmodified compressed pages.
buf_pool_t::UT_LIST_BASE_NODE_T | ( | buf_page_t | , |
LRU | |||
) |
Base node of the LRU list.
ulint buf_pool_t::buddy_n_frames |
Number of frames allocated from the buffer pool to the buddy system.
Protected by zip_hash_mutex.
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
buf_chunk_t* buf_pool_t::chunks |
buffer pool chunks
BufListMutex buf_pool_t::chunks_mutex |
protects (de)allocation of chunks:
buf_chunk_t* buf_pool_t::chunks_old |
old buffer pool chunks to be freed after resizing buffer pool
ulint buf_pool_t::curr_pool_size |
Current pool size in bytes.
ulint buf_pool_t::curr_size |
Current pool size in pages.
FlushHp buf_pool_t::flush_hp |
"Hazard pointer" used during scan of flush_list while doing flush list batch.
Protected by 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
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
ib_mutex_t buf_pool_t::flush_state_mutex |
Flush state protection mutex.
BufListMutex buf_pool_t::free_list_mutex |
free and withdraw list mutex
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
bool 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.
ulint buf_pool_t::instance_no |
Array index of this buffer pool instance.
std::chrono::steady_clock::time_point buf_pool_t::last_printout_time |
when buf_print_io was last time called.
Accesses not protected.
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
BufListMutex buf_pool_t::LRU_list_mutex |
LRU list mutex.
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.
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!
ulint buf_pool_t::LRU_old_ratio |
Reserve this much of the buffer pool for "old" blocks.
LRUItr buf_pool_t::lru_scan_itr |
Iterator used to scan the LRU list when searching for replaceable victim.
Protected by buf_pool::LRU_list_mutex.
lsn_t buf_pool_t::max_lsn_io |
Maximum LSN for which write io has already started.
volatile ulint buf_pool_t::n_chunks |
Number of buffer pool chunks.
volatile ulint buf_pool_t::n_chunks_new |
New number of buffer pool chunks.
std::array<size_t, BUF_FLUSH_N_TYPES> buf_pool_t::n_flush |
This is the number of pending writes in the given flush type.
Protected by flush_state_mutex.
std::atomic<ulint> buf_pool_t::n_pend_reads |
Number of pending read operations.
Accessed atomically
std::atomic<ulint> buf_pool_t::n_pend_unzip |
number of pending decompressions.
Accessed atomically.
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.
ulint buf_pool_t::old_size |
Previous pool size in pages.
buf_pool_stat_t buf_pool_t::old_stat |
Old statistics.
FlushHp buf_pool_t::oldest_hp |
Entry pointer to scan the oldest page except for system temporary.
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_no_t buf_pool_t::read_ahead_area |
Size in pages of the area which the read-ahead algorithms read if invoked.
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.
buf_pool_stat_t buf_pool_t::stat |
Current statistics.
lsn_t buf_pool_t::track_page_lsn |
Page Tracking start LSN.
bool 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.
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.
ulint buf_pool_t::withdraw_target |
Target length of withdraw block list, when withdrawing.
BufListMutex buf_pool_t::zip_free_mutex |
buddy allocator mutex
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.
BufListMutex buf_pool_t::zip_hash_mutex |
zip_hash 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.