Commit 8158bb03 authored by unknown's avatar unknown

set_var.cc, mysqld.cc, ha_innodb.h, ha_innodb.cc, srv0srv.c, srv0srv.h:

  Added innodb_commit_concurrency variable


innobase/include/srv0srv.h:
  Added innodb_commit_concurrency variable
innobase/srv/srv0srv.c:
  Added innodb_commit_concurrency variable
sql/ha_innodb.cc:
  Added innodb_commit_concurrency variable
sql/ha_innodb.h:
  Added innodb_commit_concurrency variable
sql/mysqld.cc:
  Added innodb_commit_concurrency variable
sql/set_var.cc:
  Added innodb_commit_concurrency variable
parent 98da6d5f
...@@ -94,6 +94,7 @@ extern ulint srv_max_dirty_pages_pct; ...@@ -94,6 +94,7 @@ extern ulint srv_max_dirty_pages_pct;
extern ulint srv_force_recovery; extern ulint srv_force_recovery;
extern ulong srv_thread_concurrency; extern ulong srv_thread_concurrency;
extern ulong srv_commit_concurrency;
extern ulint srv_max_n_threads; extern ulint srv_max_n_threads;
......
...@@ -261,6 +261,7 @@ Value 10 should be good if there are less than 4 processors + 4 disks in the ...@@ -261,6 +261,7 @@ Value 10 should be good if there are less than 4 processors + 4 disks in the
computer. Bigger computers need bigger values. */ computer. Bigger computers need bigger values. */
ulong srv_thread_concurrency = SRV_CONCURRENCY_THRESHOLD; ulong srv_thread_concurrency = SRV_CONCURRENCY_THRESHOLD;
ulong srv_commit_concurrency = 0;
os_fast_mutex_t srv_conc_mutex; /* this mutex protects srv_conc data os_fast_mutex_t srv_conc_mutex; /* this mutex protects srv_conc data
structures */ structures */
......
...@@ -48,6 +48,10 @@ have disables the InnoDB inlining in this file. */ ...@@ -48,6 +48,10 @@ have disables the InnoDB inlining in this file. */
pthread_mutex_t innobase_share_mutex, /* to protect innobase_open_files */ pthread_mutex_t innobase_share_mutex, /* to protect innobase_open_files */
prepare_commit_mutex; /* to force correct commit order in prepare_commit_mutex; /* to force correct commit order in
binlog */ binlog */
ulong commit_threads= 0;
pthread_mutex_t commit_threads_m;
pthread_cond_t commit_cond;
pthread_mutex_t commit_cond_m;
bool innodb_inited= 0; bool innodb_inited= 0;
/*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/
...@@ -1367,6 +1371,9 @@ innobase_init(void) ...@@ -1367,6 +1371,9 @@ innobase_init(void)
(hash_get_key) innobase_get_key, 0, 0); (hash_get_key) innobase_get_key, 0, 0);
pthread_mutex_init(&innobase_share_mutex, MY_MUTEX_INIT_FAST); pthread_mutex_init(&innobase_share_mutex, MY_MUTEX_INIT_FAST);
pthread_mutex_init(&prepare_commit_mutex, MY_MUTEX_INIT_FAST); pthread_mutex_init(&prepare_commit_mutex, MY_MUTEX_INIT_FAST);
pthread_mutex_init(&commit_threads_m, MY_MUTEX_INIT_FAST);
pthread_mutex_init(&commit_cond_m, MY_MUTEX_INIT_FAST);
pthread_cond_init(&commit_cond, NULL);
innodb_inited= 1; innodb_inited= 1;
/* If this is a replication slave and we needed to do a crash recovery, /* If this is a replication slave and we needed to do a crash recovery,
...@@ -1416,6 +1423,9 @@ innobase_end(void) ...@@ -1416,6 +1423,9 @@ innobase_end(void)
MYF(MY_ALLOW_ZERO_PTR)); MYF(MY_ALLOW_ZERO_PTR));
pthread_mutex_destroy(&innobase_share_mutex); pthread_mutex_destroy(&innobase_share_mutex);
pthread_mutex_destroy(&prepare_commit_mutex); pthread_mutex_destroy(&prepare_commit_mutex);
pthread_mutex_destroy(&commit_threads_m);
pthread_mutex_destroy(&commit_cond_m);
pthread_cond_destroy(&commit_cond);
} }
DBUG_RETURN(err); DBUG_RETURN(err);
...@@ -1542,7 +1552,9 @@ innobase_commit( ...@@ -1542,7 +1552,9 @@ innobase_commit(
reserve the kernel mutex, we have to release the search system latch reserve the kernel mutex, we have to release the search system latch
first to obey the latching order. */ first to obey the latching order. */
innobase_release_stat_resources(trx); if (trx->has_search_latch) {
trx_search_latch_release_if_reserved(trx);
}
/* The flag trx->active_trans is set to 1 in /* The flag trx->active_trans is set to 1 in
...@@ -1575,16 +1587,41 @@ innobase_commit( ...@@ -1575,16 +1587,41 @@ innobase_commit(
/* We need current binlog position for ibbackup to work. /* We need current binlog position for ibbackup to work.
Note, the position is current because of prepare_commit_mutex */ Note, the position is current because of prepare_commit_mutex */
retry:
if (srv_commit_concurrency > 0)
{
pthread_mutex_lock(&commit_cond_m);
commit_threads++;
if (commit_threads > srv_commit_concurrency)
{
commit_threads--;
pthread_cond_wait(&commit_cond, &commit_cond_m);
pthread_mutex_unlock(&commit_cond_m);
goto retry;
}
else
pthread_mutex_unlock(&commit_cond_m);
}
trx->mysql_log_file_name = mysql_bin_log.get_log_fname(); trx->mysql_log_file_name = mysql_bin_log.get_log_fname();
trx->mysql_log_offset = trx->mysql_log_offset =
(ib_longlong)mysql_bin_log.get_log_file()->pos_in_file; (ib_longlong)mysql_bin_log.get_log_file()->pos_in_file;
innobase_commit_low(trx); innobase_commit_low(trx);
if (srv_commit_concurrency > 0)
{
pthread_mutex_lock(&commit_cond_m);
commit_threads--;
pthread_cond_signal(&commit_cond);
pthread_mutex_unlock(&commit_cond_m);
}
if (trx->active_trans == 2) { if (trx->active_trans == 2) {
pthread_mutex_unlock(&prepare_commit_mutex); pthread_mutex_unlock(&prepare_commit_mutex);
} }
trx->active_trans = 0; trx->active_trans = 0;
} else { } else {
...@@ -1606,7 +1643,11 @@ innobase_commit( ...@@ -1606,7 +1643,11 @@ innobase_commit(
/* Tell the InnoDB server that there might be work for utility /* Tell the InnoDB server that there might be work for utility
threads: */ threads: */
if (trx->declared_to_be_inside_innodb) {
/* Release our possible ticket in the FIFO */
srv_conc_force_exit_innodb(trx);
}
srv_active_wake_master_thread(); srv_active_wake_master_thread();
DBUG_RETURN(0); DBUG_RETURN(0);
......
...@@ -232,6 +232,7 @@ extern ulong srv_n_spin_wait_rounds; ...@@ -232,6 +232,7 @@ extern ulong srv_n_spin_wait_rounds;
extern ulong srv_n_free_tickets_to_enter; extern ulong srv_n_free_tickets_to_enter;
extern ulong srv_thread_sleep_delay; extern ulong srv_thread_sleep_delay;
extern ulong srv_thread_concurrency; extern ulong srv_thread_concurrency;
extern ulong srv_commit_concurrency;
} }
extern TYPELIB innobase_lock_typelib; extern TYPELIB innobase_lock_typelib;
......
...@@ -5314,6 +5314,10 @@ log and this option does nothing anymore.", ...@@ -5314,6 +5314,10 @@ log and this option does nothing anymore.",
"Helps in performance tuning in heavily concurrent environments.", "Helps in performance tuning in heavily concurrent environments.",
(gptr*) &srv_thread_concurrency, (gptr*) &srv_thread_concurrency, (gptr*) &srv_thread_concurrency, (gptr*) &srv_thread_concurrency,
0, GET_LONG, REQUIRED_ARG, 20, 1, 1000, 0, 1, 0}, 0, GET_LONG, REQUIRED_ARG, 20, 1, 1000, 0, 1, 0},
{"innodb_commit_concurrency", OPT_INNODB_THREAD_CONCURRENCY,
"Helps in performance tuning in heavily concurrent environments.",
(gptr*) &srv_commit_concurrency, (gptr*) &srv_commit_concurrency,
0, GET_LONG, REQUIRED_ARG, 0, 0, 1000, 0, 1, 0},
{"innodb_thread_sleep_delay", OPT_INNODB_THREAD_SLEEP_DELAY, {"innodb_thread_sleep_delay", OPT_INNODB_THREAD_SLEEP_DELAY,
"Time of innodb thread sleeping before joining InnoDB queue (usec). Value 0" "Time of innodb thread sleeping before joining InnoDB queue (usec). Value 0"
" disable a sleep", " disable a sleep",
......
...@@ -411,6 +411,8 @@ sys_var_long_ptr sys_innodb_thread_sleep_delay("innodb_thread_sleep_delay", ...@@ -411,6 +411,8 @@ sys_var_long_ptr sys_innodb_thread_sleep_delay("innodb_thread_sleep_delay",
&srv_thread_sleep_delay); &srv_thread_sleep_delay);
sys_var_long_ptr sys_innodb_thread_concurrency("innodb_thread_concurrency", sys_var_long_ptr sys_innodb_thread_concurrency("innodb_thread_concurrency",
&srv_thread_concurrency); &srv_thread_concurrency);
sys_var_long_ptr sys_innodb_commit_concurrency("innodb_commit_concurrency",
&srv_commit_concurrency);
#endif #endif
/* Condition pushdown to storage engine */ /* Condition pushdown to storage engine */
...@@ -708,6 +710,7 @@ sys_var *sys_variables[]= ...@@ -708,6 +710,7 @@ sys_var *sys_variables[]=
&sys_innodb_concurrency_tickets, &sys_innodb_concurrency_tickets,
&sys_innodb_thread_sleep_delay, &sys_innodb_thread_sleep_delay,
&sys_innodb_thread_concurrency, &sys_innodb_thread_concurrency,
&sys_innodb_commit_concurrency,
#endif #endif
&sys_trust_routine_creators, &sys_trust_routine_creators,
&sys_engine_condition_pushdown, &sys_engine_condition_pushdown,
...@@ -828,6 +831,7 @@ struct show_var_st init_vars[]= { ...@@ -828,6 +831,7 @@ struct show_var_st init_vars[]= {
{sys_innodb_table_locks.name, (char*) &sys_innodb_table_locks, SHOW_SYS}, {sys_innodb_table_locks.name, (char*) &sys_innodb_table_locks, SHOW_SYS},
{sys_innodb_support_xa.name, (char*) &sys_innodb_support_xa, SHOW_SYS}, {sys_innodb_support_xa.name, (char*) &sys_innodb_support_xa, SHOW_SYS},
{sys_innodb_thread_concurrency.name, (char*) &sys_innodb_thread_concurrency, SHOW_SYS}, {sys_innodb_thread_concurrency.name, (char*) &sys_innodb_thread_concurrency, SHOW_SYS},
{sys_innodb_commit_concurrency.name, (char*) &sys_innodb_commit_concurrency, SHOW_SYS},
{sys_innodb_thread_sleep_delay.name, (char*) &sys_innodb_thread_sleep_delay, SHOW_SYS}, {sys_innodb_thread_sleep_delay.name, (char*) &sys_innodb_thread_sleep_delay, SHOW_SYS},
#endif #endif
{sys_interactive_timeout.name,(char*) &sys_interactive_timeout, SHOW_SYS}, {sys_interactive_timeout.name,(char*) &sys_interactive_timeout, SHOW_SYS},
......
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