Drizzled Public API Documentation

buf0lru.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002 
00003 Copyright (C) 1995, 2009, Innobase Oy. All Rights Reserved.
00004 
00005 This program is free software; you can redistribute it and/or modify it under
00006 the terms of the GNU General Public License as published by the Free Software
00007 Foundation; version 2 of the License.
00008 
00009 This program is distributed in the hope that it will be useful, but WITHOUT
00010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
00012 
00013 You should have received a copy of the GNU General Public License along with
00014 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
00015 St, Fifth Floor, Boston, MA 02110-1301 USA
00016 
00017 *****************************************************************************/
00018 
00019 /**************************************************/
00026 #pragma once
00027 #ifndef buf0lru_h
00028 #define buf0lru_h
00029 
00030 #include <sys/types.h>
00031 #include "univ.i"
00032 #include "ut0byte.h"
00033 #include "buf0types.h"
00034 
00036 enum buf_lru_free_block_status {
00038   BUF_LRU_FREED = 0,
00042   BUF_LRU_CANNOT_RELOCATE,
00044   BUF_LRU_NOT_FREED
00045 };
00046 
00047 /******************************************************************/
00055 UNIV_INTERN
00056 void
00057 buf_LRU_try_free_flushed_blocks(
00058 /*============================*/
00059   buf_pool_t* buf_pool);  
00060 /******************************************************************/
00065 UNIV_INTERN
00066 ibool
00067 buf_LRU_buf_pool_running_out(void);
00068 /*==============================*/
00069 
00070 /*#######################################################################
00071 These are low-level functions
00072 #########################################################################*/
00073 
00075 #define BUF_LRU_OLD_MIN_LEN 512 /* 8 megabytes of 16k pages */
00076 
00078 #define BUF_LRU_FREE_SEARCH_LEN(b)  (5 + 2 * BUF_READ_AHEAD_AREA(b))
00079 
00080 /******************************************************************/
00085 UNIV_INTERN
00086 void
00087 buf_LRU_invalidate_tablespace(
00088 /*==========================*/
00089   ulint id);  
00090 /********************************************************************/
00092 UNIV_INTERN
00093 void
00094 buf_LRU_insert_zip_clean(
00095 /*=====================*/
00096   buf_page_t* bpage); 
00098 /******************************************************************/
00111 UNIV_INTERN
00112 enum buf_lru_free_block_status
00113 buf_LRU_free_block(
00114 /*===============*/
00115   buf_page_t* bpage,  
00116   ibool   zip,  
00118   ibool*    buf_pool_mutex_released);
00122 /******************************************************************/
00125 UNIV_INTERN
00126 ibool
00127 buf_LRU_search_and_free_block(
00128 /*==========================*/
00129   buf_pool_t* buf_pool, 
00130   ulint   n_iterations);  
00140 /******************************************************************/
00144 UNIV_INTERN
00145 buf_block_t*
00146 buf_LRU_get_free_only(
00147 /*==================*/
00148   buf_pool_t* buf_pool);  
00149 /******************************************************************/
00154 UNIV_INTERN
00155 buf_block_t*
00156 buf_LRU_get_free_block(
00157 /*===================*/
00158   buf_pool_t* buf_pool, 
00159   ulint   zip_size);  
00162 /******************************************************************/
00164 UNIV_INTERN
00165 void
00166 buf_LRU_block_free_non_file_page(
00167 /*=============================*/
00168   buf_block_t*  block); 
00169 /******************************************************************/
00171 UNIV_INTERN
00172 void
00173 buf_LRU_add_block(
00174 /*==============*/
00175   buf_page_t* bpage,  
00176   ibool   old); 
00180 /******************************************************************/
00182 UNIV_INTERN
00183 void
00184 buf_unzip_LRU_add_block(
00185 /*====================*/
00186   buf_block_t*  block,  
00187   ibool   old); 
00189 /******************************************************************/
00191 UNIV_INTERN
00192 void
00193 buf_LRU_make_block_young(
00194 /*=====================*/
00195   buf_page_t* bpage); 
00196 /******************************************************************/
00198 UNIV_INTERN
00199 void
00200 buf_LRU_make_block_old(
00201 /*===================*/
00202   buf_page_t* bpage); 
00203 /**********************************************************************/
00206 UNIV_INTERN
00207 ulint
00208 buf_LRU_old_ratio_update(
00209 /*=====================*/
00210   uint  old_pct,
00212   ibool adjust);
00215 /********************************************************************/
00218 UNIV_INTERN
00219 void
00220 buf_LRU_stat_update(void);
00221 /*=====================*/
00222 
00223 #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
00224 /**********************************************************************/
00227 UNIV_INTERN
00228 ibool
00229 buf_LRU_validate(void);
00230 /*==================*/
00231 #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
00232 #if defined UNIV_DEBUG_PRINT || defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
00233 /**********************************************************************/
00235 UNIV_INTERN
00236 void
00237 buf_LRU_print(void);
00238 /*===============*/
00239 #endif /* UNIV_DEBUG_PRINT || UNIV_DEBUG || UNIV_BUF_DEBUG */
00240 
00244 extern uint buf_LRU_old_ratio;
00246 #define BUF_LRU_OLD_RATIO_DIV 1024
00247 
00250 #define BUF_LRU_OLD_RATIO_MAX BUF_LRU_OLD_RATIO_DIV
00251 
00256 #define BUF_LRU_OLD_RATIO_MIN 51
00257 
00258 #if BUF_LRU_OLD_RATIO_MIN >= BUF_LRU_OLD_RATIO_MAX
00259 # error "BUF_LRU_OLD_RATIO_MIN >= BUF_LRU_OLD_RATIO_MAX"
00260 #endif
00261 #if BUF_LRU_OLD_RATIO_MAX > BUF_LRU_OLD_RATIO_DIV
00262 # error "BUF_LRU_OLD_RATIO_MAX > BUF_LRU_OLD_RATIO_DIV"
00263 #endif
00264 
00267 extern uint buf_LRU_old_threshold_ms;
00268 /* @} */
00269 
00275 struct buf_LRU_stat_struct
00276 {
00277   ulint io; 
00278   ulint unzip;  
00279 };
00280 
00282 typedef struct buf_LRU_stat_struct buf_LRU_stat_t;
00283 
00286 extern buf_LRU_stat_t buf_LRU_stat_cur;
00287 
00290 extern buf_LRU_stat_t buf_LRU_stat_sum;
00291 
00292 /********************************************************************/
00294 #define buf_LRU_stat_inc_io() buf_LRU_stat_cur.io++
00295 /********************************************************************/
00297 #define buf_LRU_stat_inc_unzip() buf_LRU_stat_cur.unzip++
00298 
00299 #ifndef UNIV_NONINL
00300 #include "buf0lru.ic"
00301 #endif
00302 
00303 #endif