Drizzled Public API Documentation

buf0lru.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (C) 1995, 2009, Innobase Oy. All Rights Reserved.
4 
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free Software
7 Foundation; version 2 of the License.
8 
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 
13 You should have received a copy of the GNU General Public License along with
14 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15 St, Fifth Floor, Boston, MA 02110-1301 USA
16 
17 *****************************************************************************/
18 
19 /**************************************************/
26 #pragma once
27 #ifndef buf0lru_h
28 #define buf0lru_h
29 
30 #include <sys/types.h>
31 #include "univ.i"
32 #include "ut0byte.h"
33 #include "buf0types.h"
34 
45 };
46 
47 /******************************************************************/
55 UNIV_INTERN
56 void
57 buf_LRU_try_free_flushed_blocks(
58 /*============================*/
59  buf_pool_t* buf_pool);
60 /******************************************************************/
65 UNIV_INTERN
66 ibool
67 buf_LRU_buf_pool_running_out(void);
68 /*==============================*/
69 
70 /*#######################################################################
71 These are low-level functions
72 #########################################################################*/
73 
75 #define BUF_LRU_OLD_MIN_LEN 512 /* 8 megabytes of 16k pages */
76 
78 #define BUF_LRU_FREE_SEARCH_LEN(b) (5 + 2 * BUF_READ_AHEAD_AREA(b))
79 
80 /******************************************************************/
85 UNIV_INTERN
86 void
87 buf_LRU_invalidate_tablespace(
88 /*==========================*/
89  ulint id);
90 /********************************************************************/
92 UNIV_INTERN
93 void
94 buf_LRU_insert_zip_clean(
95 /*=====================*/
96  buf_page_t* bpage);
98 /******************************************************************/
111 UNIV_INTERN
113 buf_LRU_free_block(
114 /*===============*/
115  buf_page_t* bpage,
116  ibool zip,
118  ibool* buf_pool_mutex_released);
122 /******************************************************************/
125 UNIV_INTERN
126 ibool
127 buf_LRU_search_and_free_block(
128 /*==========================*/
129  buf_pool_t* buf_pool,
130  ulint n_iterations);
140 /******************************************************************/
144 UNIV_INTERN
146 buf_LRU_get_free_only(
147 /*==================*/
148  buf_pool_t* buf_pool);
149 /******************************************************************/
154 UNIV_INTERN
156 buf_LRU_get_free_block(
157 /*===================*/
158  buf_pool_t* buf_pool,
159  ulint zip_size);
162 /******************************************************************/
164 UNIV_INTERN
165 void
166 buf_LRU_block_free_non_file_page(
167 /*=============================*/
168  buf_block_t* block);
169 /******************************************************************/
171 UNIV_INTERN
172 void
173 buf_LRU_add_block(
174 /*==============*/
175  buf_page_t* bpage,
176  ibool old);
180 /******************************************************************/
182 UNIV_INTERN
183 void
184 buf_unzip_LRU_add_block(
185 /*====================*/
186  buf_block_t* block,
187  ibool old);
189 /******************************************************************/
191 UNIV_INTERN
192 void
193 buf_LRU_make_block_young(
194 /*=====================*/
195  buf_page_t* bpage);
196 /******************************************************************/
198 UNIV_INTERN
199 void
200 buf_LRU_make_block_old(
201 /*===================*/
202  buf_page_t* bpage);
203 /**********************************************************************/
206 UNIV_INTERN
207 ulint
208 buf_LRU_old_ratio_update(
209 /*=====================*/
210  uint old_pct,
212  ibool adjust);
215 /********************************************************************/
218 UNIV_INTERN
219 void
220 buf_LRU_stat_update(void);
221 /*=====================*/
222 
223 /********************************************************************/
225 UNIV_INTERN
226 bool
227 buf_LRU_file_dump(void);
228 /*===================*/
229 
230 /********************************************************************/
232 UNIV_INTERN
233 bool
234 buf_LRU_file_restore(void);
235 /*======================*/
236 
237 #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
238 /**********************************************************************/
241 UNIV_INTERN
242 ibool
243 buf_LRU_validate(void);
244 /*==================*/
245 #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
246 #if defined UNIV_DEBUG_PRINT || defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
247 /**********************************************************************/
249 UNIV_INTERN
250 void
251 buf_LRU_print(void);
252 /*===============*/
253 #endif /* UNIV_DEBUG_PRINT || UNIV_DEBUG || UNIV_BUF_DEBUG */
254 
258 extern uint buf_LRU_old_ratio;
260 #define BUF_LRU_OLD_RATIO_DIV 1024
261 
264 #define BUF_LRU_OLD_RATIO_MAX BUF_LRU_OLD_RATIO_DIV
265 
270 #define BUF_LRU_OLD_RATIO_MIN 51
271 
272 #if BUF_LRU_OLD_RATIO_MIN >= BUF_LRU_OLD_RATIO_MAX
273 # error "BUF_LRU_OLD_RATIO_MIN >= BUF_LRU_OLD_RATIO_MAX"
274 #endif
275 #if BUF_LRU_OLD_RATIO_MAX > BUF_LRU_OLD_RATIO_DIV
276 # error "BUF_LRU_OLD_RATIO_MAX > BUF_LRU_OLD_RATIO_DIV"
277 #endif
278 
281 extern uint buf_LRU_old_threshold_ms;
282 /* @} */
283 
290 {
291  ulint io;
292  ulint unzip;
293 };
294 
297 
300 extern buf_LRU_stat_t buf_LRU_stat_cur;
301 
304 extern buf_LRU_stat_t buf_LRU_stat_sum;
305 
306 /********************************************************************/
308 #define buf_LRU_stat_inc_io() buf_LRU_stat_cur.io++
309 /********************************************************************/
311 #define buf_LRU_stat_inc_unzip() buf_LRU_stat_cur.unzip++
312 
313 #ifndef UNIV_NONINL
314 #include "buf0lru.ic"
315 #endif
316 
317 #endif