Created
September 8, 2010 13:07
-
-
Save serbaut/570107 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit ca984963f07f2694abe9e73b725a484b6516bc97 | |
Author: Joakim Sernbrant <joakim.sernbrant@trioptima.com> | |
Date: Fri Jul 16 13:59:11 2010 +0200 | |
sort LRU_DUMP_FILE | |
diff --git a/storage/innodb_plugin/buf/buf0lru.c b/storage/innodb_plugin/buf/buf0lru.c | |
index a3d7f3f..ec00bfa 100644 | |
--- a/storage/innodb_plugin/buf/buf0lru.c | |
+++ b/storage/innodb_plugin/buf/buf0lru.c | |
@@ -2111,6 +2111,23 @@ func_exit: | |
Dump the LRU page list to the specific file. */ | |
#define LRU_DUMP_FILE "ib_lru_dump" | |
+typedef struct { | |
+ unsigned space:32; | |
+ unsigned offset:32; | |
+} buf_page_pos_t ; | |
+ | |
+static int buf_page_cmp(const void *a, const void *b) | |
+{ | |
+ const buf_page_pos_t *bp1 = (const buf_page_pos_t *)a; | |
+ const buf_page_pos_t *bp2 = (const buf_page_pos_t *)b; | |
+ | |
+ if (bp1->space < bp2->space) return -1; | |
+ if (bp1->space > bp2->space) return 1; | |
+ if (bp1->offset < bp2->offset) return -1; | |
+ if (bp1->offset > bp2->offset) return 1; | |
+ return 0; | |
+} | |
+ | |
UNIV_INTERN | |
ibool | |
buf_LRU_file_dump(void) | |
@@ -2154,17 +2171,26 @@ buf_LRU_file_dump(void) | |
} | |
mutex_enter(&LRU_list_mutex); | |
+ | |
+ buf_page_pos_t *bpages = ut_malloc(UT_LIST_GET_LEN(buf_pool->LRU) * sizeof(buf_page_pos_t)); | |
bpage = UT_LIST_GET_LAST(buf_pool->LRU); | |
+ for (i=0; i<UT_LIST_GET_LEN(buf_pool->LRU); i++) { | |
+ bpages[i].space = bpage->space; | |
+ bpages[i].offset = bpage->offset; | |
+ bpage = UT_LIST_GET_PREV(LRU, bpage); | |
+ } | |
+ | |
+ qsort(bpages, UT_LIST_GET_LEN(buf_pool->LRU), sizeof *bpages, buf_page_cmp); | |
buffers = offset = 0; | |
- while (bpage != NULL) { | |
+ for (i=0; i<UT_LIST_GET_LEN(buf_pool->LRU); i++) { | |
if (offset == 0) { | |
memset(buffer, 0, UNIV_PAGE_SIZE); | |
} | |
- mach_write_to_4(buffer + offset * 4, bpage->space); | |
+ mach_write_to_4(buffer + offset * 4, bpages[i].space); | |
offset++; | |
- mach_write_to_4(buffer + offset * 4, bpage->offset); | |
+ mach_write_to_4(buffer + offset * 4, bpages[i].offset); | |
offset++; | |
if (offset == UNIV_PAGE_SIZE/4) { | |
@@ -2174,6 +2200,7 @@ buf_LRU_file_dump(void) | |
UNIV_PAGE_SIZE); | |
if (!success) { | |
mutex_exit(&LRU_list_mutex); | |
+ ut_free(bpages); | |
fprintf(stderr, | |
" InnoDB: cannot write page %lu of %s\n", | |
buffers, LRU_DUMP_FILE); | |
@@ -2182,10 +2209,9 @@ buf_LRU_file_dump(void) | |
buffers++; | |
offset = 0; | |
} | |
- | |
- bpage = UT_LIST_GET_PREV(LRU, bpage); | |
} | |
mutex_exit(&LRU_list_mutex); | |
+ ut_free(bpages); | |
if (offset == 0) { | |
memset(buffer, 0, UNIV_PAGE_SIZE); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment