]> git.pld-linux.org Git - packages/mysql.git/blame - innodb_opt_lru_count.patch
- mention innodb_file_per_table
[packages/mysql.git] / innodb_opt_lru_count.patch
CommitLineData
b4e1fa2c
AM
1# name : innodb_opt_lru_count.patch
2# introduced : 11 or before
3# maintainer : Yasufumi
4#
5#!!! notice !!!
6# Any small change to this file in the main branch
7# should be done or reviewed by the maintainer!
db82db79
AM
8--- a/storage/innobase/buf/buf0buddy.c
9+++ b/storage/innobase/buf/buf0buddy.c
10@@ -123,7 +123,7 @@
11
12 ut_d(BUF_BUDDY_LIST_VALIDATE(buf_pool, i));
13
b4e1fa2c
AM
14- bpage = UT_LIST_GET_FIRST(buf_pool->zip_free[i]);
15+ bpage = UT_LIST_GET_LAST(buf_pool->zip_free[i]);
16
17 if (bpage) {
db82db79
AM
18 ut_a(buf_page_get_state(bpage) == BUF_BLOCK_ZIP_FREE);
19--- a/storage/innobase/buf/buf0buf.c
20+++ b/storage/innobase/buf/buf0buf.c
b4e1fa2c
AM
21@@ -881,9 +881,9 @@
22 block->page.in_zip_hash = FALSE;
23 block->page.in_flush_list = FALSE;
24 block->page.in_free_list = FALSE;
25- block->page.in_LRU_list = FALSE;
26 block->in_unzip_LRU_list = FALSE;
27 #endif /* UNIV_DEBUG */
28+ block->page.in_LRU_list = FALSE;
29 #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
30 block->n_pointers = 0;
31 #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
db82db79 32@@ -1428,7 +1428,7 @@
b4e1fa2c
AM
33
34 memcpy(dpage, bpage, sizeof *dpage);
35
36- ut_d(bpage->in_LRU_list = FALSE);
37+ bpage->in_LRU_list = FALSE;
38 ut_d(bpage->in_page_hash = FALSE);
39
40 /* relocate buf_pool->LRU */
db82db79 41@@ -3279,8 +3279,8 @@
b4e1fa2c
AM
42 bpage->in_zip_hash = FALSE;
43 bpage->in_flush_list = FALSE;
44 bpage->in_free_list = FALSE;
45- bpage->in_LRU_list = FALSE;
46 #endif /* UNIV_DEBUG */
47+ bpage->in_LRU_list = FALSE;
48
49 ut_d(bpage->in_page_hash = TRUE);
50
db82db79 51@@ -3445,7 +3445,7 @@
b4e1fa2c
AM
52 ibuf_merge_or_delete_for_page(NULL, space, offset, zip_size, TRUE);
53
54 /* Flush pages from the end of the LRU list if necessary */
55- buf_flush_free_margin(buf_pool);
56+ buf_flush_free_margin(buf_pool, FALSE);
57
58 frame = block->frame;
59
db82db79
AM
60--- a/storage/innobase/buf/buf0flu.c
61+++ b/storage/innobase/buf/buf0flu.c
d8778560 62@@ -431,19 +431,21 @@
b4e1fa2c
AM
63 buf_page_in_file(bpage) and in the LRU list */
64 {
65 #ifdef UNIV_DEBUG
66- buf_pool_t* buf_pool = buf_pool_from_bpage(bpage);
67- ut_ad(buf_pool_mutex_own(buf_pool));
68+ //buf_pool_t* buf_pool = buf_pool_from_bpage(bpage);
69+ //ut_ad(buf_pool_mutex_own(buf_pool));
70 #endif
71- ut_ad(mutex_own(buf_page_get_mutex(bpage)));
72- ut_ad(bpage->in_LRU_list);
73+ //ut_ad(mutex_own(buf_page_get_mutex(bpage)));
74+ //ut_ad(bpage->in_LRU_list);
75
76- if (UNIV_LIKELY(buf_page_in_file(bpage))) {
77+ if (UNIV_LIKELY(bpage->in_LRU_list && buf_page_in_file(bpage))) {
78
79 return(bpage->oldest_modification == 0
80 && buf_page_get_io_fix(bpage) == BUF_IO_NONE
81 && bpage->buf_fix_count == 0);
82 }
83
84+ /* permited not to own LRU_mutex.. */
85+/*
86 ut_print_timestamp(stderr);
87 fprintf(stderr,
88 " InnoDB: Error: buffer block state %lu"
d8778560 89@@ -451,6 +453,7 @@
b4e1fa2c
AM
90 (ulong) buf_page_get_state(bpage));
91 ut_print_buf(stderr, bpage, sizeof(buf_page_t));
92 putc('\n', stderr);
93+*/
94
95 return(FALSE);
96 }
db82db79 97@@ -1985,8 +1988,14 @@
b4e1fa2c
AM
98 buf_page_t* bpage;
99 ulint n_replaceable;
100 ulint distance = 0;
101+ ibool have_LRU_mutex = FALSE;
102
103- buf_pool_mutex_enter(buf_pool);
104+ if(UT_LIST_GET_LEN(buf_pool->unzip_LRU))
105+ have_LRU_mutex = TRUE;
106+retry:
107+ //buf_pool_mutex_enter(buf_pool);
108+ if (have_LRU_mutex)
109+ buf_pool_mutex_enter(buf_pool);
110
111 n_replaceable = UT_LIST_GET_LEN(buf_pool->free);
112
db82db79 113@@ -1997,7 +2006,13 @@
b4e1fa2c
AM
114 + BUF_FLUSH_EXTRA_MARGIN(buf_pool))
115 && (distance < BUF_LRU_FREE_SEARCH_LEN(buf_pool))) {
116
117- mutex_t* block_mutex = buf_page_get_mutex(bpage);
118+ mutex_t* block_mutex;
119+ if (!bpage->in_LRU_list) {
120+ /* reatart. but it is very optimistic */
121+ bpage = UT_LIST_GET_LAST(buf_pool->LRU);
122+ continue;
123+ }
124+ block_mutex = buf_page_get_mutex(bpage);
125
126 mutex_enter(block_mutex);
127
db82db79 128@@ -2012,11 +2027,18 @@
b4e1fa2c
AM
129 bpage = UT_LIST_GET_PREV(LRU, bpage);
130 }
131
132- buf_pool_mutex_exit(buf_pool);
133+ //buf_pool_mutex_exit(buf_pool);
134+ if (have_LRU_mutex)
135+ buf_pool_mutex_exit(buf_pool);
136
137 if (n_replaceable >= BUF_FLUSH_FREE_BLOCK_MARGIN(buf_pool)) {
138
139 return(0);
140+ } else if (!have_LRU_mutex) {
141+ /* confirm it again with LRU_mutex for exactness */
142+ have_LRU_mutex = TRUE;
143+ distance = 0;
144+ goto retry;
145 }
146
147 return(BUF_FLUSH_FREE_BLOCK_MARGIN(buf_pool)
db82db79 148@@ -2034,7 +2056,8 @@
b4e1fa2c
AM
149 void
150 buf_flush_free_margin(
151 /*==================*/
152- buf_pool_t* buf_pool) /*!< in: Buffer pool instance */
153+ buf_pool_t* buf_pool, /*!< in: Buffer pool instance */
154+ ibool wait)
155 {
156 ulint n_to_flush;
157
db82db79 158@@ -2045,7 +2068,7 @@
b4e1fa2c
AM
159
160 n_flushed = buf_flush_LRU(buf_pool, n_to_flush);
161
162- if (n_flushed == ULINT_UNDEFINED) {
163+ if (wait && n_flushed == ULINT_UNDEFINED) {
164 /* There was an LRU type flush batch already running;
165 let us wait for it to end */
166
db82db79 167@@ -2058,8 +2081,9 @@
b4e1fa2c
AM
168 Flushes pages from the end of all the LRU lists. */
169 UNIV_INTERN
170 void
171-buf_flush_free_margins(void)
172+buf_flush_free_margins(
173 /*========================*/
174+ ibool wait)
175 {
176 ulint i;
177
db82db79 178@@ -2068,7 +2092,7 @@
b4e1fa2c
AM
179
180 buf_pool = buf_pool_from_array(i);
181
182- buf_flush_free_margin(buf_pool);
183+ buf_flush_free_margin(buf_pool, wait);
184 }
185 }
186
db82db79
AM
187--- a/storage/innobase/buf/buf0lru.c
188+++ b/storage/innobase/buf/buf0lru.c
189@@ -923,7 +923,7 @@
b4e1fa2c
AM
190
191 /* No free block was found: try to flush the LRU list */
192
193- buf_flush_free_margin(buf_pool);
194+ buf_flush_free_margin(buf_pool, TRUE);
195 ++srv_buf_pool_wait_free;
196
197 os_aio_simulated_wake_handler_threads();
db82db79 198@@ -1120,7 +1120,7 @@
b4e1fa2c
AM
199
200 /* Remove the block from the LRU list */
201 UT_LIST_REMOVE(LRU, buf_pool->LRU, bpage);
202- ut_d(bpage->in_LRU_list = FALSE);
203+ bpage->in_LRU_list = FALSE;
204
205 buf_unzip_LRU_remove_block_if_needed(bpage);
206
db82db79 207@@ -1199,7 +1199,7 @@
b4e1fa2c
AM
208
209 ut_ad(!bpage->in_LRU_list);
210 UT_LIST_ADD_LAST(LRU, buf_pool->LRU, bpage);
211- ut_d(bpage->in_LRU_list = TRUE);
212+ bpage->in_LRU_list = TRUE;
213
214 if (UT_LIST_GET_LEN(buf_pool->LRU) > BUF_LRU_OLD_MIN_LEN) {
215
db82db79 216@@ -1269,7 +1269,7 @@
b4e1fa2c
AM
217 buf_pool->LRU_old_len++;
218 }
219
220- ut_d(bpage->in_LRU_list = TRUE);
221+ bpage->in_LRU_list = TRUE;
222
223 if (UT_LIST_GET_LEN(buf_pool->LRU) > BUF_LRU_OLD_MIN_LEN) {
224
db82db79 225@@ -1513,7 +1513,7 @@
b4e1fa2c
AM
226 buf_page_set_old(b, buf_page_is_old(b));
227 #endif /* UNIV_LRU_DEBUG */
228 } else {
229- ut_d(b->in_LRU_list = FALSE);
230+ b->in_LRU_list = FALSE;
231 buf_LRU_add_block_low(b, buf_page_is_old(b));
232 }
233
db82db79
AM
234--- a/storage/innobase/buf/buf0rea.c
235+++ b/storage/innobase/buf/buf0rea.c
b4e1fa2c
AM
236@@ -200,7 +200,7 @@
237 }
238
239 /* Flush pages from the end of the LRU list if necessary */
240- buf_flush_free_margin(buf_pool);
241+ buf_flush_free_margin(buf_pool, TRUE);
242
243 /* Increment number of I/O operations used for LRU policy. */
244 buf_LRU_stat_inc_io();
adf0fb13 245@@ -474,7 +474,7 @@
b4e1fa2c
AM
246 os_aio_simulated_wake_handler_threads();
247
248 /* Flush pages from the end of the LRU list if necessary */
249- buf_flush_free_margin(buf_pool);
250+ buf_flush_free_margin(buf_pool, TRUE);
251
252 #ifdef UNIV_DEBUG
253 if (buf_debug_prints && (count > 0)) {
adf0fb13 254@@ -562,7 +562,7 @@
b4e1fa2c
AM
255 os_aio_simulated_wake_handler_threads();
256
257 /* Flush pages from the end of all the LRU lists if necessary */
258- buf_flush_free_margins();
259+ buf_flush_free_margins(FALSE);
260
261 #ifdef UNIV_DEBUG
262 if (buf_debug_prints) {
adf0fb13 263@@ -656,7 +656,7 @@
b4e1fa2c
AM
264 os_aio_simulated_wake_handler_threads();
265
266 /* Flush pages from the end of all the LRU lists if necessary */
267- buf_flush_free_margins();
268+ buf_flush_free_margins(FALSE);
269
270 #ifdef UNIV_DEBUG
271 if (buf_debug_prints) {
db82db79
AM
272--- a/storage/innobase/include/buf0buf.h
273+++ b/storage/innobase/include/buf0buf.h
274@@ -1426,11 +1426,11 @@
b4e1fa2c
AM
275
276 UT_LIST_NODE_T(buf_page_t) LRU;
277 /*!< node of the LRU list */
278-#ifdef UNIV_DEBUG
279+//#ifdef UNIV_DEBUG
280 ibool in_LRU_list; /*!< TRUE if the page is in
281 the LRU list; used in
282 debugging */
283-#endif /* UNIV_DEBUG */
284+//#endif /* UNIV_DEBUG */
285 unsigned old:1; /*!< TRUE if the block is in the old
286 blocks in buf_pool->LRU_old */
287 unsigned freed_page_clock:31;/*!< the value of
db82db79
AM
288--- a/storage/innobase/include/buf0flu.h
289+++ b/storage/innobase/include/buf0flu.h
b4e1fa2c
AM
290@@ -65,13 +65,15 @@
291 void
292 buf_flush_free_margin(
293 /*==================*/
294- buf_pool_t* buf_pool);
295+ buf_pool_t* buf_pool,
296+ ibool wait);
297 /*********************************************************************//**
298 Flushes pages from the end of all the LRU lists. */
299 UNIV_INTERN
300 void
301-buf_flush_free_margins(void);
302+buf_flush_free_margins(
303 /*=========================*/
304+ ibool wait);
305 #endif /* !UNIV_HOTBACKUP */
306 /********************************************************************//**
307 Initializes a page for writing to the tablespace. */
This page took 0.229322 seconds and 4 git commands to generate.