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