public
Created

  • Download Gist
sort_lru_dump.patch
Diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
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);

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.