MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
buf0lru.cc File Reference
#include "buf0lru.h"
#include "ut0byte.h"
#include "ut0lst.h"
#include "ut0rnd.h"
#include "sync0sync.h"
#include "sync0rw.h"
#include "hash0hash.h"
#include "os0sync.h"
#include "fil0fil.h"
#include "btr0btr.h"
#include "buf0buddy.h"
#include "buf0buf.h"
#include "buf0dblwr.h"
#include "buf0flu.h"
#include "buf0rea.h"
#include "btr0sea.h"
#include "ibuf0ibuf.h"
#include "os0file.h"
#include "page0zip.h"
#include "log0recv.h"
#include "srv0srv.h"
#include "srv0mon.h"
#include "lock0lock.h"
#include "ha_prototypes.h"
Include dependency graph for buf0lru.cc:

Go to the source code of this file.

Macros

#define BUF_LRU_OLD_TOLERANCE   20
#define BUF_LRU_NON_OLD_MIN_LEN   5
#define BUF_LRU_DROP_SEARCH_SIZE   1024

Functions

UNIV_INTERN ibool buf_LRU_evict_from_unzip_LRU (buf_pool_t *buf_pool)
 ut_ad (buf_pool_mutex_own(buf_pool))
 ut_ad (buf_page_in_file(bpage))
 mutex_enter (block_mutex)
 buf_page_set_sticky (bpage)
 buf_pool_mutex_exit (buf_pool)
 mutex_exit (block_mutex)
 os_thread_yield ()
 buf_pool_mutex_enter (buf_pool)
 buf_page_unset_sticky (bpage)

Variables

static bool zip
static buf_page_t *bpage
ib_mutex_t
block_mutex = buf_page_get_mutex(bpage)
static buf_page_tbpage
Heuristics for detecting index scan @{
UNIV_INTERN uint buf_LRU_old_threshold_ms
#define BUF_LRU_STAT_N_INTERVAL   50
#define BUF_LRU_IO_TO_UNZIP_FACTOR   50
UNIV_INTERN buf_LRU_stat_t buf_LRU_stat_cur
UNIV_INTERN buf_LRU_stat_t buf_LRU_stat_sum

Detailed Description

The database buffer replacement algorithm

Created 11/5/1995 Heikki Tuuri

Definition in file buf0lru.cc.

Macro Definition Documentation

#define BUF_LRU_DROP_SEARCH_SIZE   1024
When dropping the search hash index entries before deleting an ibd

file, we build a local array of pages belonging to that tablespace in the buffer pool. Following is the size of that array. We also release buf_pool->mutex after scanning this many pages of the flush_list when dropping a table. This is to ensure that other threads are not blocked for extended period of time when using very large buffer pools.

Definition at line 82 of file buf0lru.cc.

#define BUF_LRU_IO_TO_UNZIP_FACTOR   50
Co-efficient with which we multiply I/O operations to equate them

with page_zip_decompress() operations.

Definition at line 106 of file buf0lru.cc.

#define BUF_LRU_NON_OLD_MIN_LEN   5
The minimum amount of non-old blocks when the LRU_old list exists

(that is, when there are more than BUF_LRU_OLD_MIN_LEN blocks).

See Also
buf_LRU_old_adjust_len

Definition at line 70 of file buf0lru.cc.

#define BUF_LRU_OLD_TOLERANCE   20
The number of blocks from the LRU_old pointer onward, including

the block pointed to, must be buf_pool->LRU_old_ratio/BUF_LRU_OLD_RATIO_DIV of the whole LRU list length, except that the tolerance defined below is allowed. Note that the tolerance must be small enough such that for even the BUF_LRU_OLD_MIN_LEN long LRU list, the LRU_old pointer is not allowed to point to either end of the LRU list.

Definition at line 65 of file buf0lru.cc.

#define BUF_LRU_STAT_N_INTERVAL   50

These statistics are not 'of' LRU but 'for' LRU. We keep count of I/O and page_zip_decompress() operations. Based on the statistics, buf_LRU_evict_from_unzip_LRU() decides if we want to evict from unzip_LRU or the regular LRU. From unzip_LRU, we will only evict the uncompressed frame (meaning we can evict dirty blocks as well). From the regular LRU, we will evict the entire block (i.e.: both the uncompressed and compressed data), which must be clean. Number of intervals for which we keep the history of these stats. Each interval is 1 second, defined by the rate at which srv_error_monitor_thread() calls buf_LRU_stat_update().

Definition at line 102 of file buf0lru.cc.

Function Documentation

UNIV_INTERN ibool buf_LRU_evict_from_unzip_LRU ( buf_pool_t buf_pool)

Determines if the unzip_LRU list should be used for evicting a victim instead of the general LRU list.

Returns
TRUE if should use unzip_LRU

Definition at line 185 of file buf0lru.cc.

Here is the caller graph for this function:

os_thread_yield ( void  )

Advises the os to give up remainder of the thread's time slice.

Definition at line 222 of file os0thread.cc.

Here is the caller graph for this function:

Variable Documentation

block_mutex = buf_page_get_mutex(bpage)

< in/out: buffer pool instance

< in/out: current page

Definition at line 376 of file buf0lru.cc.

buf_page_t* bpage

< in/out: buffer pool instance in/out: bpage to remove

Definition at line 415 of file buf0lru.cc.

UNIV_INTERN 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 128 of file buf0lru.cc.

UNIV_INTERN 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 117 of file buf0lru.cc.

UNIV_INTERN buf_LRU_stat_t buf_LRU_stat_sum
Running sum of past values of buf_LRU_stat_cur.

Updated by buf_LRU_stat_update(). Not Protected by any mutex.

Definition at line 121 of file buf0lru.cc.

bool zip

< in: block, must contain a file page and be in a state where it can be freed; there may or may not be a hash index to the page in: true if should remove also the compressed page of an uncompressed page

Definition at line 152 of file buf0lru.cc.