]> git.pld-linux.org Git - packages/mysql.git/blame - innodb_opt_lru_count.patch
localize vars
[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
1bfc1981 21@@ -890,9 +890,9 @@
b4e1fa2c
AM
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 */
29ffd636 32@@ -1403,7 +1403,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 */
29ffd636 41@@ -3225,8 +3225,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
29ffd636 51@@ -3391,7 +3391,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 }
29ffd636 97@@ -2049,8 +2052,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
29ffd636 113@@ -2061,7 +2070,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
29ffd636 128@@ -2076,11 +2091,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)
29ffd636 148@@ -2098,7 +2120,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
29ffd636 158@@ -2109,7 +2132,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
29ffd636 167@@ -2122,8 +2145,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
29ffd636 178@@ -2132,7 +2156,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
29ffd636 189@@ -934,7 +934,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();
29ffd636 198@@ -1131,7 +1131,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
29ffd636 207@@ -1210,7 +1210,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
29ffd636 216@@ -1280,7 +1280,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
29ffd636 225@@ -1524,7 +1524,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
734d6226 236@@ -367,7 +367,7 @@
b4e1fa2c
AM
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();
734d6226 245@@ -641,7 +641,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)) {
734d6226 254@@ -729,7 +729,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) {
734d6226 263@@ -823,7 +823,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
29ffd636 274@@ -1424,11 +1424,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.064887 seconds and 4 git commands to generate.