Commit 43a62af1 authored by Sergey Vojtovich's avatar Sergey Vojtovich

Applying InnoDB snapshot, fixes BUG#35077.

Detailed revision comments:

r6525 | marko | 2010-01-28 16:23:15 +0200 (Thu, 28 Jan 2010) | 11 lines
branches/zip: buf_LRU_invalidate_tablespace(): Do not unnecessarily
acquire the block_mutex for every block in the LRU list. Only acquire
it when holding buf_pool_mutex is not sufficient. This should speed up
the function and considerably reduce traffic on the memory bus and
caches.

I noticed this deficiency when working on Issue #157.
This deficiency popped up again in Issue #449 (Bug #35077),
which this fix does not fully address.

rb://78 revision 1 approved by Heikki Tuuri.
parent 6a4c518f
...@@ -347,20 +347,34 @@ buf_LRU_invalidate_tablespace( ...@@ -347,20 +347,34 @@ buf_LRU_invalidate_tablespace(
all_freed = TRUE; all_freed = TRUE;
rescan:
bpage = UT_LIST_GET_LAST(buf_pool->LRU); bpage = UT_LIST_GET_LAST(buf_pool->LRU);
while (bpage != NULL) { while (bpage != NULL) {
mutex_t* block_mutex = buf_page_get_mutex(bpage);
buf_page_t* prev_bpage; buf_page_t* prev_bpage;
ut_a(buf_page_in_file(bpage)); ut_a(buf_page_in_file(bpage));
mutex_enter(block_mutex);
prev_bpage = UT_LIST_GET_PREV(LRU, bpage); prev_bpage = UT_LIST_GET_PREV(LRU, bpage);
if (buf_page_get_space(bpage) == id) { /* bpage->space and bpage->io_fix are protected by
if (bpage->buf_fix_count > 0 buf_pool_mutex and block_mutex. It is safe to check
|| buf_page_get_io_fix(bpage) != BUF_IO_NONE) { them while holding buf_pool_mutex only. */
if (buf_page_get_space(bpage) != id) {
/* Skip this block, as it does not belong to
the space that is being invalidated. */
} else if (buf_page_get_io_fix(bpage) != BUF_IO_NONE) {
/* We cannot remove this page during this scan
yet; maybe the system is currently reading it
in, or flushing the modifications to the file */
all_freed = FALSE;
} else {
mutex_t* block_mutex = buf_page_get_mutex(bpage);
mutex_enter(block_mutex);
if (bpage->buf_fix_count > 0) {
/* We cannot remove this page during /* We cannot remove this page during
this scan yet; maybe the system is this scan yet; maybe the system is
...@@ -423,12 +437,12 @@ buf_LRU_invalidate_tablespace( ...@@ -423,12 +437,12 @@ buf_LRU_invalidate_tablespace(
buf_buddy_free() may have relocated buf_buddy_free() may have relocated
prev_bpage. Rescan the LRU list. */ prev_bpage. Rescan the LRU list. */
bpage = UT_LIST_GET_LAST(buf_pool->LRU); goto rescan;
continue;
}
} }
next_page: next_page:
mutex_exit(block_mutex); mutex_exit(block_mutex);
}
bpage = prev_bpage; bpage = prev_bpage;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment