Index: storage/innobase/srv/srv0srv.cc =================================================================== --- storage/innobase/srv/srv0srv.cc (revision 7133) +++ storage/innobase/srv/srv0srv.cc (working copy) @@ -290,6 +290,8 @@ srv_stats_t srv_stats; +my_bool opt_bp_flush_optimize = 0; + /* structure to pass status variables to MySQL */ export_var_t export_vars; @@ -354,6 +356,8 @@ ulint srv_truncated_status_writes = 0; ulint srv_available_undo_logs = 0; +ulint srv_bp_optimize_counter = 0; + /* Set the following to 0 if you want InnoDB to write messages on stderr on startup/shutdown. */ ibool srv_print_verbose_log = TRUE; @@ -1413,6 +1417,8 @@ export_vars.innodb_truncated_status_writes = srv_truncated_status_writes; + export_vars.innodb_bp_optimize_counter = srv_bp_optimize_counter; + export_vars.innodb_available_undo_logs = srv_available_undo_logs; #ifdef UNIV_DEBUG Index: storage/innobase/buf/buf0flu.cc =================================================================== --- storage/innobase/buf/buf0flu.cc (revision 7133) +++ storage/innobase/buf/buf0flu.cc (working copy) @@ -1898,6 +1898,15 @@ } if (!buf_flush_start(buf_pool, type)) { + if (opt_bp_flush_optimize + && type == BUF_FLUSH_LIST + && min_n == ULINT_MAX + && buf_pool_oldest_lsn_for_instance(buf_pool) >= lsn_limit) { + /* Check if the oldest lsn has exceeded lsn_limit. */ + srv_bp_optimize_counter++; + return (true); + + } return(false); } Index: storage/innobase/buf/buf0buf.cc =================================================================== --- storage/innobase/buf/buf0buf.cc (revision 7133) +++ storage/innobase/buf/buf0buf.cc (working copy) @@ -346,6 +346,37 @@ chunk->blocks->frame, chunk)); } +lsn_t +buf_pool_oldest_lsn_for_instance( +/*==============================*/ + buf_pool_t *buf_pool) +{ + lsn_t lsn = 0; + + buf_flush_list_mutex_enter(buf_pool); + + buf_page_t* bpage; + + /* We don't let log-checkpoint halt because pages from system + temporary are not yet flushed to the disk. Anyway, object + residing in system temporary doesn't generate REDO logging. */ + for (bpage = UT_LIST_GET_LAST(buf_pool->flush_list); + bpage != NULL + && fsp_is_system_temporary(bpage->id.space()); + bpage = UT_LIST_GET_PREV(list, bpage)) { + /* Do nothing. */ + } + + if (bpage != NULL) { + ut_ad(bpage->in_flush_list); + lsn = bpage->oldest_modification; + } + + buf_flush_list_mutex_exit(buf_pool); + + return lsn; +} + /********************************************************************//** Gets the smallest oldest_modification lsn for any page in the pool. Returns zero if all modified pages have been flushed to disk. @@ -367,28 +398,9 @@ buf_pool = buf_pool_from_array(i); - buf_flush_list_mutex_enter(buf_pool); + lsn = buf_pool_oldest_lsn_for_instance(buf_pool); - buf_page_t* bpage; - - /* We don't let log-checkpoint halt because pages from system - temporary are not yet flushed to the disk. Anyway, object - residing in system temporary doesn't generate REDO logging. */ - for (bpage = UT_LIST_GET_LAST(buf_pool->flush_list); - bpage != NULL - && fsp_is_system_temporary(bpage->id.space()); - bpage = UT_LIST_GET_PREV(list, bpage)) { - /* Do nothing. */ - } - - if (bpage != NULL) { - ut_ad(bpage->in_flush_list); - lsn = bpage->oldest_modification; - } - - buf_flush_list_mutex_exit(buf_pool); - - if (!oldest_lsn || oldest_lsn > lsn) { + if (lsn && (!oldest_lsn || oldest_lsn > lsn)) { oldest_lsn = lsn; } } Index: storage/innobase/handler/ha_innodb.cc =================================================================== --- storage/innobase/handler/ha_innodb.cc (revision 7133) +++ storage/innobase/handler/ha_innodb.cc (working copy) @@ -684,6 +684,8 @@ {"ahi_drop_lookups", (char*) &export_vars.innodb_ahi_drop_lookups, SHOW_LONG}, #endif /* UNIV_DEBUG */ + {"bp_optimize_counter", + (char*) &export_vars.innodb_bp_optimize_counter, SHOW_LONG}, {NullS, NullS, SHOW_LONG} }; @@ -17175,6 +17177,8 @@ NULL, innodb_save_page_no, 0, 0, UINT_MAX32, 0); #endif /* UNIV_DEBUG */ +static MYSQL_SYSVAR_BOOL(bp_flush_optimize, opt_bp_flush_optimize, PLUGIN_VAR_OPCMDARG, "For test", NULL, NULL, FALSE); + static struct st_mysql_sys_var* innobase_system_variables[]= { MYSQL_SYSVAR(api_trx_level), MYSQL_SYSVAR(api_bk_commit_interval), @@ -17334,6 +17338,7 @@ MYSQL_SYSVAR(fil_make_page_dirty_debug), MYSQL_SYSVAR(saved_page_number_debug), #endif /* UNIV_DEBUG */ + MYSQL_SYSVAR(bp_flush_optimize), NULL }; Index: storage/innobase/include/srv0srv.h =================================================================== --- storage/innobase/include/srv0srv.h (revision 7133) +++ storage/innobase/include/srv0srv.h (working copy) @@ -393,6 +393,8 @@ extern ulint srv_truncated_status_writes; extern ulint srv_available_undo_logs; +extern ulint srv_bp_optimize_counter; + #if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG extern my_bool srv_ibuf_disable_background_merge; #endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ @@ -426,6 +428,8 @@ extern my_bool srv_cmp_per_index_enabled; +extern my_bool opt_bp_flush_optimize; + /** Status variables to be passed to MySQL */ extern struct export_var_t export_vars; @@ -856,6 +860,7 @@ index lookups when freeing file pages */ #endif /* UNIV_DEBUG */ + ulint innodb_bp_optimize_counter; }; /** Thread slot in the thread table. */ Index: storage/innobase/include/buf0buf.h =================================================================== --- storage/innobase/include/buf0buf.h (revision 7133) +++ storage/innobase/include/buf0buf.h (working copy) @@ -428,6 +428,12 @@ ulint buf_pool_get_n_pages(void); /*=======================*/ + +lsn_t +buf_pool_oldest_lsn_for_instance( +/*==============================*/ + buf_pool_t *buf_pool); + /********************************************************************//** Gets the smallest oldest_modification lsn for any page in the pool. Returns zero if all modified pages have been flushed to disk.