1
1
/*****************************************************************************
3
Copyright (C) 1995, 2009, Innobase Oy. All Rights Reserved.
3
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
5
5
This program is free software; you can redistribute it and/or modify it under
6
6
the terms of the GNU General Public License as published by the Free Software
56
buf_LRU_try_free_flushed_blocks(
57
/*============================*/
58
buf_pool_t* buf_pool); /*!< in: buffer pool instance */
55
buf_LRU_try_free_flushed_blocks(void);
56
/*==================================*/
59
57
/******************************************************************//**
60
58
Returns TRUE if less than 25 % of the buffer pool is available. This can be
61
59
used in heuristics to prevent huge transactions eating up the whole buffer
71
69
#########################################################################*/
73
71
/** Minimum LRU list length for which the LRU_old pointer is defined */
74
#define BUF_LRU_OLD_MIN_LEN 512 /* 8 megabytes of 16k pages */
72
#define BUF_LRU_OLD_MIN_LEN 80
76
74
/** Maximum LRU list search length in buf_flush_LRU_recommendation() */
77
#define BUF_LRU_FREE_SEARCH_LEN(b) (5 + 2 * BUF_READ_AHEAD_AREA(b))
75
#define BUF_LRU_FREE_SEARCH_LEN (5 + 2 * BUF_READ_AHEAD_AREA)
79
77
/******************************************************************//**
80
78
Invalidates all pages belonging to a given tablespace when we are deleting
86
84
buf_LRU_invalidate_tablespace(
87
85
/*==========================*/
88
86
ulint id); /*!< in: space id */
87
/******************************************************************//**
88
Gets the minimum LRU_position field for the blocks in an initial segment
89
(determined by BUF_LRU_INITIAL_RATIO) of the LRU list. The limit is not
90
guaranteed to be precise, because the ulint_clock may wrap around.
91
@return the limit; zero if could not determine it */
94
buf_LRU_get_recent_limit(void);
95
/*==========================*/
89
96
/********************************************************************//**
90
97
Insert a compressed block into buf_pool->zip_clean in the LRU order. */
98
105
Try to free a block. If bpage is a descriptor of a compressed-only
99
106
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
108
NOTE: If this function returns BUF_LRU_FREED, it will not temporarily
109
release buf_pool_mutex. Furthermore, the page frame will no longer be
103
110
accessible via bpage.
105
The caller must hold buf_pool->mutex and buf_page_get_mutex(bpage) and
112
The caller must hold buf_pool_mutex and buf_page_get_mutex(bpage) and
106
113
release these two mutexes after the call. No other
107
114
buf_page_get_mutex() may be held when calling this function.
108
115
@return BUF_LRU_FREED if freed, BUF_LRU_CANNOT_RELOCATE or
116
123
compressed page of an uncompressed page */
117
124
ibool* buf_pool_mutex_released);
118
125
/*!< in: pointer to a variable that will
119
be assigned TRUE if buf_pool->mutex
126
be assigned TRUE if buf_pool_mutex
120
127
was temporarily released, or NULL */
121
128
/******************************************************************//**
122
129
Try to free a replaceable block.
126
133
buf_LRU_search_and_free_block(
127
134
/*==========================*/
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. */
135
ulint n_iterations); /*!< in: how many times this has been called
136
repeatedly without result: a high value means
137
that we should search farther; if
138
n_iterations < 10, then we search
139
n_iterations / 10 * buf_pool->curr_size
140
pages from the end of the LRU list; if
141
n_iterations < 5, then we will also search
142
n_iterations / 5 of the unzip_LRU list. */
139
143
/******************************************************************//**
140
144
Returns a free block from the buf_pool. The block is taken off the
141
145
free list. If it is empty, returns NULL.
142
146
@return a free control block, or NULL if the buf_block->free list is empty */
145
buf_LRU_get_free_only(
146
/*==================*/
147
buf_pool_t* buf_pool); /*!< buffer pool instance */
149
buf_LRU_get_free_only(void);
150
/*=======================*/
148
151
/******************************************************************//**
149
152
Returns a free block from the buf_pool. The block is taken off the
150
153
free list. If it is empty, blocks are moved from the end of the
155
158
buf_LRU_get_free_block(
156
159
/*===================*/
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 */
160
ulint zip_size); /*!< in: compressed page size in bytes,
161
or 0 if uncompressed tablespace */
161
163
/******************************************************************//**
162
164
Puts a block back to the free list. */
199
201
buf_LRU_make_block_old(
200
202
/*===================*/
201
203
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
204
/********************************************************************//**
215
205
Update the historical stats that we are collecting for LRU eviction
216
206
policy at the end of each interval. */
237
227
/*===============*/
238
228
#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
230
/** @brief Statistics for selecting the LRU list for eviction.
271
232
These statistics are not 'of' LRU but 'for' LRU. We keep count of I/O
285
246
extern buf_LRU_stat_t buf_LRU_stat_cur;
287
248
/** Running sum of past values of buf_LRU_stat_cur.
288
Updated by buf_LRU_stat_update(). Protected by buf_pool->mutex. */
249
Updated by buf_LRU_stat_update(). Protected by buf_pool_mutex. */
289
250
extern buf_LRU_stat_t buf_LRU_stat_sum;
291
252
/********************************************************************//**