Go to the source code of this file.
Classes | |
struct | buf_LRU_stat_struct |
Statistics for selecting the LRU list for eviction. More... |
Macros | |
#define | buf0lru_h |
#define | BUF_LRU_OLD_MIN_LEN 512 /* 8 megabytes of 16k pages */ |
#define | BUF_LRU_FREE_SEARCH_LEN(b) (5 + 2 * BUF_READ_AHEAD_AREA(b)) |
#define | buf_LRU_stat_inc_io() buf_LRU_stat_cur.io++ |
#define | buf_LRU_stat_inc_unzip() buf_LRU_stat_cur.unzip++ |
Typedefs | |
typedef struct buf_LRU_stat_struct | buf_LRU_stat_t |
Enumerations | |
enum | buf_lru_free_block_status { BUF_LRU_FREED = 0, BUF_LRU_CANNOT_RELOCATE, BUF_LRU_NOT_FREED } |
Functions | |
UNIV_INTERN void | buf_LRU_try_free_flushed_blocks (buf_pool_t *buf_pool) |
UNIV_INTERN ibool | buf_LRU_buf_pool_running_out (void) |
UNIV_INTERN void | buf_LRU_invalidate_tablespace (ulint id) |
UNIV_INTERN void | buf_LRU_insert_zip_clean (buf_page_t *bpage) |
UNIV_INTERN enum buf_lru_free_block_status | buf_LRU_free_block (buf_page_t *bpage, ibool zip, ibool *buf_pool_mutex_released) |
UNIV_INTERN ibool | buf_LRU_search_and_free_block (buf_pool_t *buf_pool, ulint n_iterations) |
UNIV_INTERN buf_block_t * | buf_LRU_get_free_only (buf_pool_t *buf_pool) |
UNIV_INTERN buf_block_t * | buf_LRU_get_free_block (buf_pool_t *buf_pool, ulint zip_size) |
UNIV_INTERN void | buf_LRU_block_free_non_file_page (buf_block_t *block) |
UNIV_INTERN void | buf_LRU_add_block (buf_page_t *bpage, ibool old) |
UNIV_INTERN void | buf_unzip_LRU_add_block (buf_block_t *block, ibool old) |
UNIV_INTERN void | buf_LRU_make_block_young (buf_page_t *bpage) |
UNIV_INTERN void | buf_LRU_make_block_old (buf_page_t *bpage) |
UNIV_INTERN ulint | buf_LRU_old_ratio_update (uint old_pct, ibool adjust) |
UNIV_INTERN void | buf_LRU_stat_update (void) |
UNIV_INTERN bool | buf_LRU_file_dump (void) |
UNIV_INTERN bool | buf_LRU_file_restore (void) |
Variables | |
buf_LRU_stat_t | buf_LRU_stat_cur |
buf_LRU_stat_t | buf_LRU_stat_sum |
Heuristics for detecting index scan @{ | |
#define | BUF_LRU_OLD_RATIO_DIV 1024 |
#define | BUF_LRU_OLD_RATIO_MAX BUF_LRU_OLD_RATIO_DIV |
#define | BUF_LRU_OLD_RATIO_MIN 51 |
uint | buf_LRU_old_ratio |
uint | buf_LRU_old_threshold_ms |
The database buffer pool LRU replacement algorithm
Created 11/5/1995 Heikki Tuuri
Definition in file buf0lru.h.
#define BUF_LRU_FREE_SEARCH_LEN | ( | b | ) | (5 + 2 * BUF_READ_AHEAD_AREA(b)) |
#define BUF_LRU_OLD_MIN_LEN 512 /* 8 megabytes of 16k pages */ |
Minimum LRU list length for which the LRU_old pointer is defined
Definition at line 75 of file buf0lru.h.
Referenced by buf_LRU_free_block().
#define BUF_LRU_OLD_RATIO_DIV 1024 |
#define BUF_LRU_OLD_RATIO_MAX BUF_LRU_OLD_RATIO_DIV |
Maximum value of buf_LRU_old_ratio.
#define BUF_LRU_OLD_RATIO_MIN 51 |
Minimum value of buf_LRU_old_ratio.
#define buf_LRU_stat_inc_io | ( | ) | buf_LRU_stat_cur.io++ |
Increments the I/O counter in buf_LRU_stat_cur.
Definition at line 308 of file buf0lru.h.
Referenced by buf_LRU_file_restore(), buf_read_ahead_linear(), and buf_read_page().
#define buf_LRU_stat_inc_unzip | ( | ) | buf_LRU_stat_cur.unzip++ |
Increments the page_zip_decompress() counter in buf_LRU_stat_cur.
typedef struct buf_LRU_stat_struct buf_LRU_stat_t |
The return type of buf_LRU_free_block()
UNIV_INTERN void buf_LRU_add_block | ( | buf_page_t * | bpage, |
ibool | old | ||
) |
Adds a block to the LRU list. in: TRUE if should be put to the old blocks in the LRU list, else put to the start; if the LRU list is very short, added to the start regardless of this parameter
Adds a block to the LRU list.
bpage | in: control block |
old | in: TRUE if should be put to the old blocks in the LRU list, else put to the start; if the LRU list is very short, the block is added to the start, regardless of this parameter |
Definition at line 1398 of file buf0lru.cc.
UNIV_INTERN void buf_LRU_block_free_non_file_page | ( | buf_block_t * | block | ) |
Puts a block back to the free list. in: block, must not contain a file page
Puts a block back to the free list.
block | in: block, must not contain a file page |
Definition at line 1704 of file buf0lru.cc.
References buf_block_get_state(), BUF_BLOCK_MEMORY, BUF_BLOCK_NOT_USED, BUF_BLOCK_READY_FOR_USE, buf_block_set_state(), buf_buddy_free(), buf_pool_from_block(), buf_pool_mutex_exit_allow, buf_pool_mutex_exit_forbid, buf_pool_mutex_own, page_zip_des_struct::data, FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, FIL_PAGE_OFFSET, buf_block_struct::frame, buf_block_struct::mutex, buf_block_struct::page, page_zip_get_size(), page_zip_set_size(), ut_a, ut_ad, ut_d, ut_error, UT_LIST_ADD_FIRST, and buf_page_struct::zip.
UNIV_INTERN ibool buf_LRU_buf_pool_running_out | ( | void | ) |
Returns TRUE if less than 25 % of the buffer pool is available. This can be used in heuristics to prevent huge transactions eating up the whole buffer pool for their locks.
Returns TRUE if less than 25 % of the buffer pool in any instance is available. This can be used in heuristics to prevent huge transactions eating up the whole buffer pool for their locks.
Definition at line 788 of file buf0lru.cc.
References buf_pool_from_array(), buf_pool_mutex_enter, buf_pool_mutex_exit, buf_pool_struct::curr_size, recv_recovery_on, srv_buf_pool_instances, and UT_LIST_GET_LEN.
UNIV_INTERN bool buf_LRU_file_dump | ( | void | ) |
Dump the LRU page list to the specific file.
Definition at line 2119 of file buf0lru.cc.
References buf_pool_from_array(), buf_pool_mutex_enter, buf_pool_mutex_exit, mach_write_to_4(), buf_page_struct::offset, OS_DATA_FILE, os_file_get_last_error(), buf_page_struct::space, srv_buf_pool_instances, ut_align(), ut_free(), UT_LIST_GET_LAST, UT_LIST_GET_PREV, and ut_malloc().
UNIV_INTERN bool buf_LRU_file_restore | ( | void | ) |
Read the pages based on the specific file.
Definition at line 2250 of file buf0lru.cc.
References buf_LRU_stat_inc_io, BUF_READ_ANY_PAGE, mach_read_from_4(), os_aio_simulated_wake_handler_threads(), OS_AIO_SIMULATED_WAKE_LATER, os_file_get_last_error(), os_file_get_size(), OS_FILE_OPEN, ut_align(), ut_free(), ut_malloc(), and ut_print_timestamp().
UNIV_INTERN enum buf_lru_free_block_status buf_LRU_free_block | ( | buf_page_t * | bpage, |
ibool | zip, | ||
ibool * | buf_pool_mutex_released | ||
) |
Try to free a block. If bpage is a descriptor of a compressed-only page, the descriptor object will be freed as well.
NOTE: If this function returns BUF_LRU_FREED, it will temporarily release buf_pool->mutex. Furthermore, the page frame will no longer be accessible via bpage.
The caller must hold buf_pool->mutex and buf_page_get_mutex(bpage) and release these two mutexes after the call. No other buf_page_get_mutex() may be held when calling this function.
Try to free a block. If bpage is a descriptor of a compressed-only page, the descriptor object will be freed as well.
NOTE: If this function returns BUF_LRU_FREED, it will temporarily release buf_pool->mutex. Furthermore, the page frame will no longer be accessible via bpage.
The caller must hold buf_pool->mutex and buf_page_get_mutex(bpage) and release these two mutexes after the call. No other buf_page_get_mutex() may be held when calling this function.
bpage | in: block to be freed |
zip | in: TRUE if should remove also the compressed page of an uncompressed page |
buf_pool_mutex_released | in: pointer to a variable that will be assigned TRUE if buf_pool_mutex was temporarily released, or NULL |
Definition at line 1457 of file buf0lru.cc.
References BUF_BLOCK_FILE_PAGE, BUF_BLOCK_ZIP_DIRTY, BUF_BLOCK_ZIP_FREE, BUF_BLOCK_ZIP_PAGE, buf_buddy_alloc(), buf_page_struct::buf_fix_count, BUF_IO_NONE, BUF_IO_READ, BUF_LRU_CANNOT_RELOCATE, BUF_LRU_FREED, BUF_LRU_NOT_FREED, BUF_LRU_OLD_MIN_LEN, BUF_NO_CHECKSUM_MAGIC, buf_page_address_fold(), buf_page_can_relocate(), buf_page_get_mutex(), buf_page_get_page_no(), buf_page_get_space(), buf_page_get_state(), buf_page_hash_get_low(), buf_page_in_file(), buf_page_is_old(), buf_page_set_io_fix(), buf_page_set_old(), buf_pool_from_bpage(), buf_pool_mutex_enter, buf_pool_mutex_exit, buf_pool_mutex_exit_allow, buf_pool_mutex_exit_forbid, buf_pool_mutex_own, page_zip_des_struct::data, FIL_PAGE_SPACE_OR_CHKSUM, HASH_INSERT, buf_page_struct::io_fix, buf_pool_struct::LRU_old, buf_pool_struct::LRU_old_len, mach_write_to_4(), buf_page_struct::offset, buf_page_struct::oldest_modification, buf_pool_struct::page_hash, page_zip_calc_checksum(), page_zip_get_size(), page_zip_set_size(), buf_page_struct::space, buf_page_struct::state, ut_a, ut_ad, ut_d, UT_LIST_GET_LEN, UT_LIST_GET_NEXT, UT_LIST_GET_PREV, UT_LIST_INSERT_AFTER, buf_page_struct::zip, and buf_pool_struct::zip_mutex.
UNIV_INTERN buf_block_t* buf_LRU_get_free_block | ( | buf_pool_t * | buf_pool, |
ulint | zip_size | ||
) |
Returns a free block from the buf_pool. The block is taken off the free list. If it is empty, blocks are moved from the end of the LRU list to the free list.
Returns a free block from the buf_pool. The block is taken off the free list. If it is empty, blocks are moved from the end of the LRU list to the free list.
buf_pool | in: buffer pool instance |
zip_size | in: compressed page size in bytes, or 0 if uncompressed tablespace |
Definition at line 860 of file buf0lru.cc.
References buf_buddy_alloc(), buf_pool_from_block(), buf_pool_mutex_enter, buf_pool_mutex_exit, buf_pool_struct::curr_size, page_zip_des_struct::data, buf_pool_struct::LRU_flush_ended, page_zip_des_struct::m_end, page_zip_des_struct::m_nonempty, page_zip_des_struct::n_blobs, os_aio_simulated_wake_handler_threads(), os_event_set(), os_thread_sleep(), buf_block_struct::page, page_zip_set_size(), recv_recovery_on, ut_ad, ut_error, UT_LIST_GET_LEN, ut_print_timestamp(), and buf_page_struct::zip.
UNIV_INTERN buf_block_t* buf_LRU_get_free_only | ( | buf_pool_t * | buf_pool | ) |
Returns a free block from the buf_pool. The block is taken off the free list. If it is empty, returns NULL.
Returns a free block from the buf_pool. The block is taken off the free list. If it is empty, returns NULL.
Definition at line 821 of file buf0lru.cc.
References BUF_BLOCK_READY_FOR_USE, buf_block_set_state(), buf_page_in_file(), buf_pool_from_block(), buf_pool_mutex_own, buf_block_struct::frame, buf_block_struct::mutex, buf_block_struct::page, ut_a, ut_ad, ut_d, UT_LIST_GET_FIRST, and UT_LIST_REMOVE.
UNIV_INTERN void buf_LRU_insert_zip_clean | ( | buf_page_t * | bpage | ) |
Insert a compressed block into buf_pool->zip_clean in the LRU order. in: pointer to the block in question
Insert a compressed block into buf_pool->zip_clean in the LRU order.
bpage | in: pointer to the block in question |
Definition at line 529 of file buf0lru.cc.
References BUF_BLOCK_ZIP_PAGE, buf_page_get_state(), buf_pool_from_bpage(), buf_pool_mutex_own, ut_ad, UT_LIST_ADD_FIRST, UT_LIST_GET_NEXT, UT_LIST_GET_PREV, and UT_LIST_INSERT_AFTER.
UNIV_INTERN void buf_LRU_invalidate_tablespace | ( | ulint | id | ) |
Invalidates all pages belonging to a given tablespace when we are deleting the data file(s) of that tablespace. A PROBLEM: if readahead is being started, what guarantees that it will not try to read in pages after this operation has completed? in: space id
Invalidates all pages belonging to a given tablespace when we are deleting the data file(s) of that tablespace.
id | in: space id |
Definition at line 504 of file buf0lru.cc.
References buf_pool_from_array(), and srv_buf_pool_instances.
UNIV_INTERN void buf_LRU_make_block_old | ( | buf_page_t * | bpage | ) |
Moves a block to the end of the LRU list. in: control block
Moves a block to the end of the LRU list.
bpage | in: control block |
Definition at line 1434 of file buf0lru.cc.
UNIV_INTERN void buf_LRU_make_block_young | ( | buf_page_t * | bpage | ) |
Moves a block to the start of the LRU list. in: control block
Moves a block to the start of the LRU list.
bpage | in: control block |
Definition at line 1414 of file buf0lru.cc.
References buf_pool_from_bpage(), buf_pool_mutex_own, buf_pool_stat_struct::n_pages_made_young, buf_page_struct::old, buf_pool_struct::stat, and ut_ad.
UNIV_INTERN ulint buf_LRU_old_ratio_update | ( | uint | old_pct, |
ibool | adjust | ||
) |
Updates buf_LRU_old_ratio.
Updates buf_pool->LRU_old_ratio.
old_pct | in: Reserve this percentage of the buffer pool for "old" blocks. |
adjust | in: TRUE=adjust the LRU list; FALSE=just assign buf_pool->LRU_old_ratio during the initialization of InnoDB |
Definition at line 2045 of file buf0lru.cc.
References buf_pool_from_array(), and srv_buf_pool_instances.
UNIV_INTERN ibool buf_LRU_search_and_free_block | ( | buf_pool_t * | buf_pool, |
ulint | n_iterations | ||
) |
Try to free a replaceable block.
Try to free a replaceable block.
buf_pool | in: buffer pool instance |
n_iterations | in: how many times this has been called repeatedly without result: a high value means that we should search farther; if n_iterations < 10, then we search n_iterations / 10 * buf_pool->curr_size pages from the end of the LRU list; if n_iterations < 5, then we will also search n_iterations / 5 of the unzip_LRU list. |
Definition at line 707 of file buf0lru.cc.
References buf_pool_mutex_enter, buf_pool_mutex_exit, and buf_pool_struct::LRU_flush_ended.
UNIV_INTERN void buf_LRU_stat_update | ( | void | ) |
Update the historical stats that we are collecting for LRU eviction policy at the end of each interval.
Definition at line 2073 of file buf0lru.cc.
References buf_pool_from_array(), buf_pool_struct::freed_page_clock, buf_LRU_stat_struct::io, srv_buf_pool_instances, and buf_LRU_stat_struct::unzip.
UNIV_INTERN void buf_LRU_try_free_flushed_blocks | ( | buf_pool_t * | buf_pool | ) |
Tries to remove LRU flushed blocks from the end of the LRU list and put them to the free list. This is beneficial for the efficiency of the insert buffer operation, as flushed pages from non-unique non-clustered indexes are here taken out of the buffer pool, and their inserts redirected to the insert buffer. Otherwise, the flushed blocks could get modified again before read operations need new buffer blocks, and the i/o work done in flushing would be wasted. in: buffer pool instance
Tries to remove LRU flushed blocks from the end of the LRU list and put them to the free list. This is beneficial for the efficiency of the insert buffer operation, as flushed pages from non-unique non-clustered indexes are here taken out of the buffer pool, and their inserts redirected to the insert buffer. Otherwise, the flushed blocks could get modified again before read operations need new buffer blocks, and the i/o work done in flushing would be wasted.
buf_pool | in: buffer pool instance |
Definition at line 753 of file buf0lru.cc.
References buf_pool_from_array(), buf_pool_mutex_enter, buf_pool_mutex_exit, buf_pool_struct::LRU_flush_ended, and srv_buf_pool_instances.
UNIV_INTERN void buf_unzip_LRU_add_block | ( | buf_block_t * | block, |
ibool | old | ||
) |
Adds a block to the LRU list of decompressed zip pages. in: TRUE if should be put to the end of the list, else put to the start
Adds a block to the LRU list of decompressed zip pages.
block | in: control block |
old | in: TRUE if should be put to the end of the list, else put to the start |
Definition at line 1254 of file buf0lru.cc.
References buf_page_belongs_to_unzip_LRU(), buf_pool_from_block(), buf_pool_mutex_own, buf_block_struct::page, ut_a, ut_ad, ut_d, UT_LIST_ADD_FIRST, and UT_LIST_ADD_LAST.
uint buf_LRU_old_ratio |
Reserve this much/BUF_LRU_OLD_RATIO_DIV of the buffer pool for "old" blocks. Protected by buf_pool->mutex.
uint buf_LRU_old_threshold_ms |
Move blocks to "new" LRU list only if the first access was at least this many milliseconds ago. Not protected by any mutex or latch.
Definition at line 119 of file buf0lru.cc.
buf_LRU_stat_t buf_LRU_stat_cur |
Current operation counters. Not protected by any mutex. Cleared by buf_LRU_stat_update().
Definition at line 108 of file buf0lru.cc.
buf_LRU_stat_t buf_LRU_stat_sum |
Running sum of past values of buf_LRU_stat_cur. Updated by buf_LRU_stat_update(). Protected by buf_pool->mutex.
Running sum of past values of buf_LRU_stat_cur. Updated by buf_LRU_stat_update(). Not Protected by any mutex.
Definition at line 112 of file buf0lru.cc.