~stewart/drizzle/embedded-innodb-create-select-transaction-arrgh

« back to all changes in this revision

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

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************
 
2
The database buffer pool LRU replacement algorithm
 
3
 
 
4
(c) 1995 Innobase Oy
 
5
 
 
6
Created 11/5/1995 Heikki Tuuri
 
7
*******************************************************/
 
8
 
 
9
#ifndef buf0lru_h
 
10
#define buf0lru_h
 
11
 
 
12
#include "univ.i"
 
13
#include "ut0byte.h"
 
14
#include "buf0types.h"
 
15
 
 
16
/**********************************************************************
 
17
Tries to remove LRU flushed blocks from the end of the LRU list and put them
 
18
to the free list. This is beneficial for the efficiency of the insert buffer
 
19
operation, as flushed pages from non-unique non-clustered indexes are here
 
20
taken out of the buffer pool, and their inserts redirected to the insert
 
21
buffer. Otherwise, the flushed blocks could get modified again before read
 
22
operations need new buffer blocks, and the i/o work done in flushing would be
 
23
wasted. */
 
24
 
 
25
void
 
26
buf_LRU_try_free_flushed_blocks(void);
 
27
/*==================================*/
 
28
/**********************************************************************
 
29
Returns TRUE if less than 25 % of the buffer pool is available. This can be
 
30
used in heuristics to prevent huge transactions eating up the whole buffer
 
31
pool for their locks. */
 
32
 
 
33
ibool
 
34
buf_LRU_buf_pool_running_out(void);
 
35
/*==============================*/
 
36
                                /* out: TRUE if less than 25 % of buffer pool
 
37
                                left */
 
38
 
 
39
/*#######################################################################
 
40
These are low-level functions
 
41
#########################################################################*/
 
42
 
 
43
/* Minimum LRU list length for which the LRU_old pointer is defined */
 
44
 
 
45
#define BUF_LRU_OLD_MIN_LEN     80
 
46
 
 
47
#define BUF_LRU_FREE_SEARCH_LEN         (5 + 2 * BUF_READ_AHEAD_AREA)
 
48
 
 
49
/**********************************************************************
 
50
Invalidates all pages belonging to a given tablespace when we are deleting
 
51
the data file(s) of that tablespace. A PROBLEM: if readahead is being started,
 
52
what guarantees that it will not try to read in pages after this operation has
 
53
completed? */
 
54
 
 
55
void
 
56
buf_LRU_invalidate_tablespace(
 
57
/*==========================*/
 
58
        ulint   id);    /* in: space id */
 
59
/**********************************************************************
 
60
Gets the minimum LRU_position field for the blocks in an initial segment
 
61
(determined by BUF_LRU_INITIAL_RATIO) of the LRU list. The limit is not
 
62
guaranteed to be precise, because the ulint_clock may wrap around. */
 
63
 
 
64
ulint
 
65
buf_LRU_get_recent_limit(void);
 
66
/*==========================*/
 
67
                        /* out: the limit; zero if could not determine it */
 
68
/**********************************************************************
 
69
Look for a replaceable block from the end of the LRU list and put it to
 
70
the free list if found. */
 
71
 
 
72
ibool
 
73
buf_LRU_search_and_free_block(
 
74
/*==========================*/
 
75
                                /* out: TRUE if freed */
 
76
        ulint   n_iterations);   /* in: how many times this has been called
 
77
                                repeatedly without result: a high value means
 
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 */
 
82
/**********************************************************************
 
83
Returns a free block from the buf_pool. The block is taken off the
 
84
free list. If it is empty, blocks are moved from the end of the
 
85
LRU list to the free list. */
 
86
 
 
87
buf_block_t*
 
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 */
 
93
/**********************************************************************
 
94
Puts a block back to the free list. */
 
95
 
 
96
void
 
97
buf_LRU_block_free_non_file_page(
 
98
/*=============================*/
 
99
        buf_block_t*    block); /* in: block, must not contain a file page */
 
100
/**********************************************************************
 
101
Adds a block to the LRU list. */
 
102
 
 
103
void
 
104
buf_LRU_add_block(
 
105
/*==============*/
 
106
        buf_block_t*    block,  /* in: control block */
 
107
        ibool           old);   /* in: TRUE if should be put to the old
 
108
                                blocks in the LRU list, else put to the
 
109
                                start; if the LRU list is very short, added to
 
110
                                the start regardless of this parameter */
 
111
/**********************************************************************
 
112
Moves a block to the start of the LRU list. */
 
113
 
 
114
void
 
115
buf_LRU_make_block_young(
 
116
/*=====================*/
 
117
        buf_block_t*    block); /* in: control block */
 
118
/**********************************************************************
 
119
Moves a block to the end of the LRU list. */
 
120
 
 
121
void
 
122
buf_LRU_make_block_old(
 
123
/*===================*/
 
124
        buf_block_t*    block); /* in: control block */
 
125
#ifdef UNIV_DEBUG
 
126
/**************************************************************************
 
127
Validates the LRU list. */
 
128
 
 
129
ibool
 
130
buf_LRU_validate(void);
 
131
/*==================*/
 
132
/**************************************************************************
 
133
Prints the LRU list. */
 
134
 
 
135
void
 
136
buf_LRU_print(void);
 
137
/*===============*/
 
138
#endif /* UNIV_DEBUG */
 
139
 
 
140
#ifndef UNIV_NONINL
 
141
#include "buf0lru.ic"
 
142
#endif
 
143
 
 
144
#endif