1
/******************************************************
2
The database buffer pool LRU replacement algorithm
6
Created 11/5/1995 Heikki Tuuri
7
*******************************************************/
14
#include "buf0types.h"
16
/**********************************************************************
17
Tries to remove LRU flushed blocks from the end of the LRU list and put them
18
to the free list. This is beneficial for the efficiency of the insert buffer
19
operation, as flushed pages from non-unique non-clustered indexes are here
20
taken out of the buffer pool, and their inserts redirected to the insert
21
buffer. Otherwise, the flushed blocks could get modified again before read
22
operations need new buffer blocks, and the i/o work done in flushing would be
26
buf_LRU_try_free_flushed_blocks(void);
27
/*==================================*/
28
/**********************************************************************
29
Returns TRUE if less than 25 % of the buffer pool is available. This can be
30
used in heuristics to prevent huge transactions eating up the whole buffer
31
pool for their locks. */
34
buf_LRU_buf_pool_running_out(void);
35
/*==============================*/
36
/* out: TRUE if less than 25 % of buffer pool
39
/*#######################################################################
40
These are low-level functions
41
#########################################################################*/
43
/* Minimum LRU list length for which the LRU_old pointer is defined */
45
#define BUF_LRU_OLD_MIN_LEN 80
47
#define BUF_LRU_FREE_SEARCH_LEN (5 + 2 * BUF_READ_AHEAD_AREA)
49
/**********************************************************************
50
Invalidates all pages belonging to a given tablespace when we are deleting
51
the data file(s) of that tablespace. A PROBLEM: if readahead is being started,
52
what guarantees that it will not try to read in pages after this operation has
56
buf_LRU_invalidate_tablespace(
57
/*==========================*/
58
ulint id); /* in: space id */
59
/**********************************************************************
60
Gets the minimum LRU_position field for the blocks in an initial segment
61
(determined by BUF_LRU_INITIAL_RATIO) of the LRU list. The limit is not
62
guaranteed to be precise, because the ulint_clock may wrap around. */
65
buf_LRU_get_recent_limit(void);
66
/*==========================*/
67
/* out: the limit; zero if could not determine it */
68
/**********************************************************************
69
Look for a replaceable block from the end of the LRU list and put it to
70
the free list if found. */
73
buf_LRU_search_and_free_block(
74
/*==========================*/
75
/* out: TRUE if freed */
76
ulint n_iterations); /* in: how many times this has been called
77
repeatedly without result: a high value means
78
that we should search farther; if value is
79
k < 10, then we only search k/10 * number
80
of pages in the buffer pool from the end
82
/**********************************************************************
83
Returns a free block from the buf_pool. The block is taken off the
84
free list. If it is empty, blocks are moved from the end of the
85
LRU list to the free list. */
88
buf_LRU_get_free_block(void);
89
/*=========================*/
90
/* out: the free control block; also if AWE is
91
used, it is guaranteed that the block has its
92
page mapped to a frame when we return */
93
/**********************************************************************
94
Puts a block back to the free list. */
97
buf_LRU_block_free_non_file_page(
98
/*=============================*/
99
buf_block_t* block); /* in: block, must not contain a file page */
100
/**********************************************************************
101
Adds a block to the LRU list. */
106
buf_block_t* block, /* in: control block */
107
ibool old); /* in: TRUE if should be put to the old
108
blocks in the LRU list, else put to the
109
start; if the LRU list is very short, added to
110
the start regardless of this parameter */
111
/**********************************************************************
112
Moves a block to the start of the LRU list. */
115
buf_LRU_make_block_young(
116
/*=====================*/
117
buf_block_t* block); /* in: control block */
118
/**********************************************************************
119
Moves a block to the end of the LRU list. */
122
buf_LRU_make_block_old(
123
/*===================*/
124
buf_block_t* block); /* in: control block */
126
/**************************************************************************
127
Validates the LRU list. */
130
buf_LRU_validate(void);
131
/*==================*/
132
/**************************************************************************
133
Prints the LRU list. */
138
#endif /* UNIV_DEBUG */
141
#include "buf0lru.ic"