diff --git a/buf/buf0buddy.c b/buf/buf0buddy.c index 041d84a50b1..d073273add8 100644 --- a/buf/buf0buddy.c +++ b/buf/buf0buddy.c @@ -28,6 +28,9 @@ UNIV_INTERN ulint buf_buddy_used[BUF_BUDDY_SIZES + 1]; /** Counts of blocks relocated by the buddy system. Protected by buf_pool_mutex. */ UNIV_INTERN ib_uint64_t buf_buddy_relocated[BUF_BUDDY_SIZES + 1]; +/** Durations of block relocations. +Protected by buf_pool_mutex. */ +UNIV_INTERN ullint buf_buddy_relocated_duration[BUF_BUDDY_SIZES + 1]; /** Preferred minimum number of frames allocated from the buffer pool to the buddy system. Unless this number is exceeded or the buffer @@ -531,6 +534,7 @@ buf_buddy_relocate( { buf_page_t* bpage; const ulint size = BUF_BUDDY_LOW << i; + ullint usec = ut_time_us(NULL); ut_ad(buf_pool_mutex_own()); ut_ad(!mutex_own(&buf_pool_zip_mutex)); @@ -603,6 +607,8 @@ buf_buddy_relocate( success: UNIV_MEM_INVALID(src, size); buf_buddy_relocated[i]++; + buf_buddy_relocated_duration[i] + += ut_time_us(NULL) - usec; return(TRUE); } diff --git a/handler/i_s.cc b/handler/i_s.cc index c37a26935da..a83d68d0e93 100644 --- a/handler/i_s.cc +++ b/handler/i_s.cc @@ -992,6 +992,22 @@ static ST_FIELD_INFO i_s_zip_fields_info[] = STRUCT_FLD(old_name, "Block Size"), STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + {STRUCT_FLD(field_name, "used"), + STRUCT_FLD(field_length, 21), + STRUCT_FLD(field_type, MYSQL_TYPE_LONG), + STRUCT_FLD(value, 0), + STRUCT_FLD(field_flags, 0), + STRUCT_FLD(old_name, "Currently in Use"), + STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + + {STRUCT_FLD(field_name, "free"), + STRUCT_FLD(field_length, 21), + STRUCT_FLD(field_type, MYSQL_TYPE_LONG), + STRUCT_FLD(value, 0), + STRUCT_FLD(field_flags, 0), + STRUCT_FLD(old_name, "Currently Available"), + STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + {STRUCT_FLD(field_name, "relocated"), STRUCT_FLD(field_length, 21), STRUCT_FLD(field_type, MYSQL_TYPE_LONG), @@ -1000,6 +1016,14 @@ static ST_FIELD_INFO i_s_zip_fields_info[] = STRUCT_FLD(old_name, "Total Number of Relocations"), STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + {STRUCT_FLD(field_name, "relocated_usec"), + STRUCT_FLD(field_length, 42), + STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), + STRUCT_FLD(value, 0), + STRUCT_FLD(field_flags, 0), + STRUCT_FLD(old_name, "Total Duration of Relocations"), + STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + {STRUCT_FLD(field_name, "compressed"), STRUCT_FLD(field_length, 21), STRUCT_FLD(field_type, MYSQL_TYPE_LONG), @@ -1017,28 +1041,28 @@ static ST_FIELD_INFO i_s_zip_fields_info[] = " Successful Compressions"), STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - {STRUCT_FLD(field_name, "decompressed"), - STRUCT_FLD(field_length, 21), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), + {STRUCT_FLD(field_name, "compressed_usec"), + STRUCT_FLD(field_length, 42), + STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), STRUCT_FLD(value, 0), STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, "Total Number of Decompressions"), + STRUCT_FLD(old_name, "Total Duration of Compressions"), STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - {STRUCT_FLD(field_name, "used"), + {STRUCT_FLD(field_name, "decompressed"), STRUCT_FLD(field_length, 21), STRUCT_FLD(field_type, MYSQL_TYPE_LONG), STRUCT_FLD(value, 0), STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, "Currently in Use"), + STRUCT_FLD(old_name, "Total Number of Decompressions"), STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - {STRUCT_FLD(field_name, "free"), - STRUCT_FLD(field_length, 21), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), + {STRUCT_FLD(field_name, "decompressed_usec"), + STRUCT_FLD(field_length, 42), + STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), STRUCT_FLD(value, 0), STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, "Currently Available"), + STRUCT_FLD(old_name, "Total Duration of Decompressions"), STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, END_OF_ST_FIELD_INFO @@ -1076,10 +1100,17 @@ i_s_zip_fill_low( for (uint x = 0; x <= BUF_BUDDY_SIZES; x++) { table->field[0]->store(BUF_BUDDY_LOW << x); - table->field[1]->store(buf_buddy_relocated[x]); + table->field[1]->store(buf_buddy_used[x]); + table->field[2]->store(UNIV_LIKELY(x < BUF_BUDDY_SIZES) + ? UT_LIST_GET_LEN(buf_pool->zip_free[x]) + : 0); + table->field[3]->store(buf_buddy_relocated[x]); + table->field[4]->store(buf_buddy_relocated_duration[x]); + if (reset) { /* This is protected by buf_pool_mutex. */ buf_buddy_relocated[x] = 0; + buf_buddy_relocated_duration[x] = 0; } if (x > y) { @@ -1090,23 +1121,25 @@ i_s_zip_fill_low( mutex protection, but it could cause a measureable performance hit in page0zip.c. */ const uint i = x - y; - table->field[2]->store(page_zip_compress_count[i]); - table->field[3]->store(page_zip_compress_ok[i]); - table->field[4]->store(page_zip_decompress_count[i]); + table->field[5]->store(page_zip_compress_count[i]); + table->field[6]->store(page_zip_compress_ok[i]); + table->field[7]->store(page_zip_compress_duration[i]); + table->field[8]->store(page_zip_decompress_count[i]); + table->field[9]->store(page_zip_decompress_duration[i]); if (reset) { page_zip_compress_count[i] = 0; page_zip_compress_ok[i] = 0; page_zip_decompress_count[i] = 0; + page_zip_compress_duration[i] = 0; + page_zip_decompress_duration[i] = 0; } } else { - table->field[2]->store(0); - table->field[3]->store(0); - table->field[4]->store(0); + table->field[5]->store(0); + table->field[6]->store(0); + table->field[7]->store(0); + table->field[8]->store(0); + table->field[9]->store(0); } - table->field[5]->store(buf_buddy_used[x]); - table->field[6]->store(UNIV_LIKELY(x < BUF_BUDDY_SIZES) - ? UT_LIST_GET_LEN(buf_pool->zip_free[x]) - : 0); if (schema_table_store_record(thd, table)) { status = 1; diff --git a/include/buf0buddy.h b/include/buf0buddy.h index bf2e4f885f7..ef9a4e9dd48 100644 --- a/include/buf0buddy.h +++ b/include/buf0buddy.h @@ -69,6 +69,9 @@ extern ulint buf_buddy_used[BUF_BUDDY_SIZES + 1]; /** Counts of blocks relocated by the buddy system. Protected by buf_pool_mutex. */ extern ib_uint64_t buf_buddy_relocated[BUF_BUDDY_SIZES + 1]; +/** Durations of block relocations. +Protected by buf_pool_mutex. */ +extern ullint buf_buddy_relocated_duration[BUF_BUDDY_SIZES + 1]; #ifndef UNIV_NONINL # include "buf0buddy.ic" diff --git a/include/page0types.h b/include/page0types.h index 13f44dd5b23..f11b3038bee 100644 --- a/include/page0types.h +++ b/include/page0types.h @@ -54,6 +54,10 @@ extern ulint page_zip_compress_count[8]; extern ulint page_zip_compress_ok[8]; /** Number of page decompressions, indexed by page_zip_des_t::ssize */ extern ulint page_zip_decompress_count[8]; +/** Duration of page compressions, indexed by page_zip_des_t::ssize */ +extern ullint page_zip_compress_duration[8]; +/** Duration of page decompressions, indexed by page_zip_des_t::ssize */ +extern ullint page_zip_decompress_duration[8]; /************************************************************************** Write data to the compressed page. The data must already be written to diff --git a/page/page0zip.c b/page/page0zip.c index 692e791b23d..2c0004e11c9 100644 --- a/page/page0zip.c +++ b/page/page0zip.c @@ -30,6 +30,10 @@ UNIV_INTERN ulint page_zip_compress_count[8]; UNIV_INTERN ulint page_zip_compress_ok[8]; /** Number of page decompressions, indexed by page_zip_des_t::ssize */ UNIV_INTERN ulint page_zip_decompress_count[8]; +/** Duration of page compressions, indexed by page_zip_des_t::ssize */ +UNIV_INTERN ullint page_zip_compress_duration[8]; +/** Duration of page decompressions, indexed by page_zip_des_t::ssize */ +UNIV_INTERN ullint page_zip_decompress_duration[8]; /* Please refer to ../include/page0zip.ic for a description of the compressed page format. */ @@ -1104,6 +1108,7 @@ page_zip_compress( ulint* offsets = NULL; ulint n_blobs = 0; byte* storage;/* storage of uncompressed columns */ + ullint usec = ut_time_us(NULL); #ifdef PAGE_ZIP_COMPRESS_DBG FILE* logfile = NULL; #endif @@ -1169,12 +1174,8 @@ page_zip_compress( if (UNIV_UNLIKELY(n_dense * PAGE_ZIP_DIR_SLOT_SIZE >= page_zip_get_size(page_zip))) { -#ifdef PAGE_ZIP_COMPRESS_DBG - if (logfile) { - fclose(logfile); - } -#endif /* PAGE_ZIP_COMPRESS_DBG */ - return(FALSE); + + goto err_exit; } heap = mem_heap_create(page_zip_get_size(page_zip) @@ -1300,11 +1301,14 @@ page_zip_compress( zlib_error: deflateEnd(&c_stream); mem_heap_free(heap); +err_exit: #ifdef PAGE_ZIP_COMPRESS_DBG if (logfile) { fclose(logfile); } #endif /* PAGE_ZIP_COMPRESS_DBG */ + page_zip_compress_duration[page_zip->ssize] + += ut_time_us(NULL) - usec; return(FALSE); } @@ -1362,6 +1366,8 @@ zlib_error: fclose(logfile); } #endif /* PAGE_ZIP_COMPRESS_DBG */ + page_zip_compress_duration[page_zip->ssize] + += ut_time_us(NULL) - usec; return(TRUE); } @@ -2779,6 +2785,7 @@ page_zip_decompress( ulint trx_id_col = ULINT_UNDEFINED; mem_heap_t* heap; ulint* offsets; + ullint usec = ut_time_us(NULL); ut_ad(page_zip_simple_validate(page_zip)); UNIV_MEM_ASSERT_W(page, UNIV_PAGE_SIZE); @@ -2935,6 +2942,8 @@ err_exit: page_zip_fields_free(index); mem_heap_free(heap); page_zip_decompress_count[page_zip->ssize]++; + page_zip_decompress_duration[page_zip->ssize] + += ut_time_us(NULL) - usec; return(TRUE); }