~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/include/buf0lru.h

  • Committer: Monty Taylor
  • Date: 2008-09-15 17:24:04 UTC
  • Revision ID: monty@inaugust.com-20080915172404-ygh6hiyu0q7qpa9x
Removed strndup calls.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
#include "ut0byte.h"
14
14
#include "buf0types.h"
15
15
 
16
 
/** The return type of buf_LRU_free_block() */
17
 
enum buf_lru_free_block_status {
18
 
        /** freed */
19
 
        BUF_LRU_FREED = 0,
20
 
        /** not freed because the caller asked to remove the
21
 
        uncompressed frame but the control block cannot be
22
 
        relocated */
23
 
        BUF_LRU_CANNOT_RELOCATE,
24
 
        /** not freed because of some other reason */
25
 
        BUF_LRU_NOT_FREED
26
 
};
27
 
 
28
16
/**********************************************************************
29
17
Tries to remove LRU flushed blocks from the end of the LRU list and put them
30
18
to the free list. This is beneficial for the efficiency of the insert buffer
33
21
buffer. Otherwise, the flushed blocks could get modified again before read
34
22
operations need new buffer blocks, and the i/o work done in flushing would be
35
23
wasted. */
36
 
UNIV_INTERN
 
24
 
37
25
void
38
26
buf_LRU_try_free_flushed_blocks(void);
39
27
/*==================================*/
41
29
Returns TRUE if less than 25 % of the buffer pool is available. This can be
42
30
used in heuristics to prevent huge transactions eating up the whole buffer
43
31
pool for their locks. */
44
 
UNIV_INTERN
 
32
 
45
33
ibool
46
34
buf_LRU_buf_pool_running_out(void);
47
35
/*==============================*/
63
51
the data file(s) of that tablespace. A PROBLEM: if readahead is being started,
64
52
what guarantees that it will not try to read in pages after this operation has
65
53
completed? */
66
 
UNIV_INTERN
 
54
 
67
55
void
68
56
buf_LRU_invalidate_tablespace(
69
57
/*==========================*/
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. */
75
 
UNIV_INTERN
 
63
 
76
64
ulint
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. */
82
 
UNIV_INTERN
83
 
void
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. */
87
71
 
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
92
 
buf_pool_mutex. */
93
 
UNIV_INTERN
94
 
enum buf_lru_free_block_status
95
 
buf_LRU_free_block(
96
 
/*===============*/
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. */
109
 
UNIV_INTERN
110
72
ibool
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. */
125
 
UNIV_INTERN
126
 
buf_block_t*
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
 
81
                                of the LRU list */
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. */
135
 
UNIV_INTERN
 
86
 
136
87
buf_block_t*
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 */
143
 
 
 
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. */
146
 
UNIV_INTERN
 
95
 
147
96
void
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. */
153
 
UNIV_INTERN
 
102
 
154
103
void
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. */
164
 
UNIV_INTERN
165
 
void
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. */
173
 
UNIV_INTERN
 
113
 
174
114
void
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. */
180
 
UNIV_INTERN
 
120
 
181
121
void
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. */
188
 
UNIV_INTERN
189
 
void
190
 
buf_LRU_stat_update(void);
191
 
/*=====================*/
192
 
 
193
 
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
 
124
        buf_block_t*    block); /* in: control block */
 
125
#ifdef UNIV_DEBUG
194
126
/**************************************************************************
195
127
Validates the LRU list. */
196
 
UNIV_INTERN
 
128
 
197
129
ibool
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. */
204
 
UNIV_INTERN
 
134
 
205
135
void
206
136
buf_LRU_print(void);
207
137
/*===============*/
208
 
#endif /* UNIV_DEBUG_PRINT || UNIV_DEBUG || UNIV_BUF_DEBUG */
209
 
 
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. */
214
 
 
215
 
/** Statistics for selecting the LRU list for eviction. */
216
 
struct buf_LRU_stat_struct
217
 
{
218
 
        ulint   io;     /**< Counter of buffer pool I/O operations. */
219
 
        ulint   unzip;  /**< Counter of page_zip_decompress operations. */
220
 
};
221
 
 
222
 
typedef struct buf_LRU_stat_struct buf_LRU_stat_t;
223
 
 
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;
227
 
 
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;
231
 
 
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 */
238
139
 
239
140
#ifndef UNIV_NONINL
240
141
#include "buf0lru.ic"