86
68
buf_LRU_invalidate_tablespace(
87
69
/*==========================*/
88
ulint id); /*!< in: space id */
89
/********************************************************************//**
70
ulint id); /* in: space id */
71
/**********************************************************************
72
Gets the minimum LRU_position field for the blocks in an initial segment
73
(determined by BUF_LRU_INITIAL_RATIO) of the LRU list. The limit is not
74
guaranteed to be precise, because the ulint_clock may wrap around. */
77
buf_LRU_get_recent_limit(void);
78
/*==========================*/
79
/* out: the limit; zero if could not determine it */
80
/************************************************************************
90
81
Insert a compressed block into buf_pool->zip_clean in the LRU order. */
93
84
buf_LRU_insert_zip_clean(
94
85
/*=====================*/
95
buf_page_t* bpage); /*!< in: pointer to the block in question */
86
buf_page_t* bpage); /* in: pointer to the block in question */
97
/******************************************************************//**
88
/**********************************************************************
98
89
Try to free a block. If bpage is a descriptor of a compressed-only
99
page, the descriptor object will be freed as well.
101
NOTE: If this function returns BUF_LRU_FREED, it will temporarily
102
release buf_pool->mutex. Furthermore, the page frame will no longer be
103
accessible via bpage.
105
The caller must hold buf_pool->mutex and buf_page_get_mutex(bpage) and
106
release these two mutexes after the call. No other
107
buf_page_get_mutex() may be held when calling this function.
108
@return BUF_LRU_FREED if freed, BUF_LRU_CANNOT_RELOCATE or
109
BUF_LRU_NOT_FREED otherwise. */
90
page, the descriptor object will be freed as well. If this function
91
returns BUF_LRU_FREED, it will not temporarily release
111
94
enum buf_lru_free_block_status
112
95
buf_LRU_free_block(
113
96
/*===============*/
114
buf_page_t* bpage, /*!< in: block to be freed */
115
ibool zip, /*!< in: TRUE if should remove also the
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
116
102
compressed page of an uncompressed page */
117
103
ibool* buf_pool_mutex_released);
118
/*!< in: pointer to a variable that will
119
be assigned TRUE if buf_pool->mutex
104
/* in: pointer to a variable that will
105
be assigned TRUE if buf_pool_mutex
120
106
was temporarily released, or NULL */
121
/******************************************************************//**
122
Try to free a replaceable block.
123
@return TRUE if found and freed */
107
/**********************************************************************
108
Try to free a replaceable block. */
126
111
buf_LRU_search_and_free_block(
127
112
/*==========================*/
128
buf_pool_t* buf_pool, /*!< in: buffer pool instance */
129
ulint n_iterations); /*!< in: how many times this has
130
been called repeatedly without
131
result: a high value means that
132
we should search farther; if
133
n_iterations < 10, then we search
134
n_iterations / 10 * buf_pool->curr_size
135
pages from the end of the LRU list; if
136
n_iterations < 5, then we will
137
also search n_iterations / 5
138
of the unzip_LRU list. */
139
/******************************************************************//**
113
/* out: TRUE if found and freed */
114
ulint n_iterations); /* in: how many times this has been called
115
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
/**********************************************************************
140
123
Returns a free block from the buf_pool. The block is taken off the
141
free list. If it is empty, returns NULL.
142
@return a free control block, or NULL if the buf_block->free list is empty */
124
free list. If it is empty, returns NULL. */
145
buf_LRU_get_free_only(
146
/*==================*/
147
buf_pool_t* buf_pool); /*!< buffer pool instance */
148
/******************************************************************//**
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 */
131
/**********************************************************************
149
132
Returns a free block from the buf_pool. The block is taken off the
150
133
free list. If it is empty, blocks are moved from the end of the
151
LRU list to the free list.
152
@return the free control block, in state BUF_BLOCK_READY_FOR_USE */
134
LRU list to the free list. */
155
137
buf_LRU_get_free_block(
156
138
/*===================*/
157
buf_pool_t* buf_pool, /*!< in: preferred buffer pool */
158
ulint zip_size); /*!< in: compressed page size in bytes,
159
or 0 if uncompressed tablespace */
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 */
161
/******************************************************************//**
144
/**********************************************************************
162
145
Puts a block back to the free list. */
165
148
buf_LRU_block_free_non_file_page(
166
149
/*=============================*/
167
buf_block_t* block); /*!< in: block, must not contain a file page */
168
/******************************************************************//**
150
buf_block_t* block); /* in: block, must not contain a file page */
151
/**********************************************************************
169
152
Adds a block to the LRU list. */
172
155
buf_LRU_add_block(
173
156
/*==============*/
174
buf_page_t* bpage, /*!< in: control block */
175
ibool old); /*!< in: TRUE if should be put to the old
157
buf_page_t* bpage, /* in: control block */
158
ibool old); /* in: TRUE if should be put to the old
176
159
blocks in the LRU list, else put to the
177
160
start; if the LRU list is very short, added to
178
161
the start regardless of this parameter */
179
/******************************************************************//**
162
/**********************************************************************
180
163
Adds a block to the LRU list of decompressed zip pages. */
183
166
buf_unzip_LRU_add_block(
184
167
/*====================*/
185
buf_block_t* block, /*!< in: control block */
186
ibool old); /*!< in: TRUE if should be put to the end
168
buf_block_t* block, /* in: control block */
169
ibool old); /* in: TRUE if should be put to the end
187
170
of the list, else put to the start */
188
/******************************************************************//**
171
/**********************************************************************
189
172
Moves a block to the start of the LRU list. */
192
175
buf_LRU_make_block_young(
193
176
/*=====================*/
194
buf_page_t* bpage); /*!< in: control block */
195
/******************************************************************//**
177
buf_page_t* bpage); /* in: control block */
178
/**********************************************************************
196
179
Moves a block to the end of the LRU list. */
199
182
buf_LRU_make_block_old(
200
183
/*===================*/
201
buf_page_t* bpage); /*!< in: control block */
202
/**********************************************************************//**
203
Updates buf_LRU_old_ratio.
204
@return updated old_pct */
207
buf_LRU_old_ratio_update(
208
/*=====================*/
209
uint old_pct,/*!< in: Reserve this percentage of
210
the buffer pool for "old" blocks. */
211
ibool adjust);/*!< in: TRUE=adjust the LRU list;
212
FALSE=just assign buf_LRU_old_ratio
213
during the initialization of InnoDB */
214
/********************************************************************//**
184
buf_page_t* bpage); /* in: control block */
185
/************************************************************************
215
186
Update the historical stats that we are collecting for LRU eviction
216
187
policy at the end of each interval. */
237
207
/*===============*/
238
208
#endif /* UNIV_DEBUG_PRINT || UNIV_DEBUG || UNIV_BUF_DEBUG */
240
/** @name Heuristics for detecting index scan @{ */
241
/** Reserve this much/BUF_LRU_OLD_RATIO_DIV of the buffer pool for
242
"old" blocks. Protected by buf_pool->mutex. */
243
extern uint buf_LRU_old_ratio;
244
/** The denominator of buf_LRU_old_ratio. */
245
#define BUF_LRU_OLD_RATIO_DIV 1024
246
/** Maximum value of buf_LRU_old_ratio.
247
@see buf_LRU_old_adjust_len
248
@see buf_LRU_old_ratio_update */
249
#define BUF_LRU_OLD_RATIO_MAX BUF_LRU_OLD_RATIO_DIV
250
/** Minimum value of buf_LRU_old_ratio.
251
@see buf_LRU_old_adjust_len
252
@see buf_LRU_old_ratio_update
253
The minimum must exceed
254
(BUF_LRU_OLD_TOLERANCE + 5) * BUF_LRU_OLD_RATIO_DIV / BUF_LRU_OLD_MIN_LEN. */
255
#define BUF_LRU_OLD_RATIO_MIN 51
257
#if BUF_LRU_OLD_RATIO_MIN >= BUF_LRU_OLD_RATIO_MAX
258
# error "BUF_LRU_OLD_RATIO_MIN >= BUF_LRU_OLD_RATIO_MAX"
260
#if BUF_LRU_OLD_RATIO_MAX > BUF_LRU_OLD_RATIO_DIV
261
# error "BUF_LRU_OLD_RATIO_MAX > BUF_LRU_OLD_RATIO_DIV"
264
/** Move blocks to "new" LRU list only if the first access was at
265
least this many milliseconds ago. Not protected by any mutex or latch. */
266
extern uint buf_LRU_old_threshold_ms;
269
/** @brief Statistics for selecting the LRU list for eviction.
210
/**********************************************************************
271
211
These statistics are not 'of' LRU but 'for' LRU. We keep count of I/O
272
212
and page_zip_decompress() operations. Based on the statistics we decide
273
213
if we want to evict from buf_pool->unzip_LRU or buf_pool->LRU. */
215
/** Statistics for selecting the LRU list for eviction. */
274
216
struct buf_LRU_stat_struct
276
218
ulint io; /**< Counter of buffer pool I/O operations. */
277
219
ulint unzip; /**< Counter of page_zip_decompress operations. */
280
/** Statistics for selecting the LRU list for eviction. */
281
222
typedef struct buf_LRU_stat_struct buf_LRU_stat_t;
283
224
/** Current operation counters. Not protected by any mutex.