72
60
Gets the minimum LRU_position field for the blocks in an initial segment
73
61
(determined by BUF_LRU_INITIAL_RATIO) of the LRU list. The limit is not
74
62
guaranteed to be precise, because the ulint_clock may wrap around. */
77
65
buf_LRU_get_recent_limit(void);
78
66
/*==========================*/
79
67
/* out: the limit; zero if could not determine it */
80
/************************************************************************
81
Insert a compressed block into buf_pool->zip_clean in the LRU order. */
84
buf_LRU_insert_zip_clean(
85
/*=====================*/
86
buf_page_t* bpage); /* in: pointer to the block in question */
68
/**********************************************************************
69
Look for a replaceable block from the end of the LRU list and put it to
70
the free list if found. */
88
/**********************************************************************
89
Try to free a block. If bpage is a descriptor of a compressed-only
90
page, the descriptor object will be freed as well. If this function
91
returns BUF_LRU_FREED, it will not temporarily release
94
enum buf_lru_free_block_status
97
/* out: BUF_LRU_FREED if freed,
98
BUF_LRU_CANNOT_RELOCATE or
99
BUF_LRU_NOT_FREED otherwise. */
100
buf_page_t* bpage, /* in: block to be freed */
101
ibool zip, /* in: TRUE if should remove also the
102
compressed page of an uncompressed page */
103
ibool* buf_pool_mutex_released);
104
/* in: pointer to a variable that will
105
be assigned TRUE if buf_pool_mutex
106
was temporarily released, or NULL */
107
/**********************************************************************
108
Try to free a replaceable block. */
111
73
buf_LRU_search_and_free_block(
112
74
/*==========================*/
113
/* out: TRUE if found and freed */
114
ulint n_iterations); /* in: how many times this has been called
75
/* out: TRUE if freed */
76
ulint n_iterations); /* in: how many times this has been called
115
77
repeatedly without result: a high value means
116
that we should search farther; if
117
n_iterations < 10, then we search
118
n_iterations / 10 * buf_pool->curr_size
119
pages from the end of the LRU list; if
120
n_iterations < 5, then we will also search
121
n_iterations / 5 of the unzip_LRU list. */
122
/**********************************************************************
123
Returns a free block from the buf_pool. The block is taken off the
124
free list. If it is empty, returns NULL. */
127
buf_LRU_get_free_only(void);
128
/*=======================*/
129
/* out: a free control block, or NULL
130
if the buf_block->free list is empty */
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
131
82
/**********************************************************************
132
83
Returns a free block from the buf_pool. The block is taken off the
133
84
free list. If it is empty, blocks are moved from the end of the
134
85
LRU list to the free list. */
137
buf_LRU_get_free_block(
138
/*===================*/
139
/* out: the free control block,
140
in state BUF_BLOCK_READY_FOR_USE */
141
ulint zip_size); /* in: compressed page size in bytes,
142
or 0 if uncompressed tablespace */
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 */
144
93
/**********************************************************************
145
94
Puts a block back to the free list. */
148
97
buf_LRU_block_free_non_file_page(
149
98
/*=============================*/
150
99
buf_block_t* block); /* in: block, must not contain a file page */
151
100
/**********************************************************************
152
101
Adds a block to the LRU list. */
155
104
buf_LRU_add_block(
156
105
/*==============*/
157
buf_page_t* bpage, /* in: control block */
106
buf_block_t* block, /* in: control block */
158
107
ibool old); /* in: TRUE if should be put to the old
159
108
blocks in the LRU list, else put to the
160
109
start; if the LRU list is very short, added to
161
110
the start regardless of this parameter */
162
111
/**********************************************************************
163
Adds a block to the LRU list of decompressed zip pages. */
166
buf_unzip_LRU_add_block(
167
/*====================*/
168
buf_block_t* block, /* in: control block */
169
ibool old); /* in: TRUE if should be put to the end
170
of the list, else put to the start */
171
/**********************************************************************
172
112
Moves a block to the start of the LRU list. */
175
115
buf_LRU_make_block_young(
176
116
/*=====================*/
177
buf_page_t* bpage); /* in: control block */
117
buf_block_t* block); /* in: control block */
178
118
/**********************************************************************
179
119
Moves a block to the end of the LRU list. */
182
122
buf_LRU_make_block_old(
183
123
/*===================*/
184
buf_page_t* bpage); /* in: control block */
185
/************************************************************************
186
Update the historical stats that we are collecting for LRU eviction
187
policy at the end of each interval. */
190
buf_LRU_stat_update(void);
191
/*=====================*/
193
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
124
buf_block_t* block); /* in: control block */
194
126
/**************************************************************************
195
127
Validates the LRU list. */
198
130
buf_LRU_validate(void);
199
131
/*==================*/
200
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
201
#if defined UNIV_DEBUG_PRINT || defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
202
132
/**************************************************************************
203
133
Prints the LRU list. */
206
136
buf_LRU_print(void);
207
137
/*===============*/
208
#endif /* UNIV_DEBUG_PRINT || UNIV_DEBUG || UNIV_BUF_DEBUG */
210
/**********************************************************************
211
These statistics are not 'of' LRU but 'for' LRU. We keep count of I/O
212
and page_zip_decompress() operations. Based on the statistics we decide
213
if we want to evict from buf_pool->unzip_LRU or buf_pool->LRU. */
215
/** Statistics for selecting the LRU list for eviction. */
216
struct buf_LRU_stat_struct
218
ulint io; /**< Counter of buffer pool I/O operations. */
219
ulint unzip; /**< Counter of page_zip_decompress operations. */
222
typedef struct buf_LRU_stat_struct buf_LRU_stat_t;
224
/** Current operation counters. Not protected by any mutex.
225
Cleared by buf_LRU_stat_update(). */
226
extern buf_LRU_stat_t buf_LRU_stat_cur;
228
/** Running sum of past values of buf_LRU_stat_cur.
229
Updated by buf_LRU_stat_update(). Protected by buf_pool_mutex. */
230
extern buf_LRU_stat_t buf_LRU_stat_sum;
232
/************************************************************************
233
Increments the I/O counter in buf_LRU_stat_cur. */
234
#define buf_LRU_stat_inc_io() buf_LRU_stat_cur.io++
235
/************************************************************************
236
Increments the page_zip_decompress() counter in buf_LRU_stat_cur. */
237
#define buf_LRU_stat_inc_unzip() buf_LRU_stat_cur.unzip++
138
#endif /* UNIV_DEBUG */
239
140
#ifndef UNIV_NONINL
240
141
#include "buf0lru.ic"