diff options
| author | Sergey Vojtovich <svoj@mariadb.org> | 2016-09-16 18:35:56 +0400 |
|---|---|---|
| committer | Sergey Vojtovich <svoj@mariadb.org> | 2016-09-16 18:41:21 +0400 |
| commit | a2b1c58c19f44ddaac3ec4d4714ffb0b2bec5f35 (patch) | |
| tree | d306d586f785a3224f64880277377d1a4aa49ba5 | |
| parent | 8613633f2648637f916b949a25d36cfea4120758 (diff) | |
| download | mariadb-git-a2b1c58c19f44ddaac3ec4d4714ffb0b2bec5f35.tar.gz | |
MDEV-10296 - Multi-instance table cache
Fixed sysvars_server_[not]embedded failure: changed type of
table_open_cache_instances from ulong to uint.
Added casts foratomic operations around tc_active_instances and
tc_contention_warning_reported: needed on some platforms.
| -rw-r--r-- | mysql-test/suite/sys_vars/r/sysvars_server_embedded.result | 2 | ||||
| -rw-r--r-- | mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result | 2 | ||||
| -rw-r--r-- | sql/sys_vars.cc | 2 | ||||
| -rw-r--r-- | sql/table_cache.cc | 17 | ||||
| -rw-r--r-- | sql/table_cache.h | 2 |
5 files changed, 14 insertions, 11 deletions
diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result index 80146d0b224..d8f2663857f 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result @@ -3893,7 +3893,7 @@ GLOBAL_VALUE 8 GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 8 VARIABLE_SCOPE GLOBAL -VARIABLE_TYPE BIGINT UNSIGNED +VARIABLE_TYPE INT UNSIGNED VARIABLE_COMMENT Maximum number of table cache instances NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 64 diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result index b38f9f0ac72..3c88437551b 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result @@ -4663,7 +4663,7 @@ GLOBAL_VALUE 8 GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 8 VARIABLE_SCOPE GLOBAL -VARIABLE_TYPE BIGINT UNSIGNED +VARIABLE_TYPE INT UNSIGNED VARIABLE_COMMENT Maximum number of table cache instances NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 64 diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 59c1d1d9e12..55f2864a93e 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -3227,7 +3227,7 @@ static Sys_var_ulong Sys_table_cache_size( BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(fix_table_open_cache)); -static Sys_var_ulong Sys_table_cache_instances( +static Sys_var_uint Sys_table_cache_instances( "table_open_cache_instances", "Maximum number of table cache instances", READ_ONLY GLOBAL_VAR(tc_instances), CMD_LINE(REQUIRED_ARG), VALID_RANGE(1, 64), DEFAULT(8), BLOCK_SIZE(1)); diff --git a/sql/table_cache.cc b/sql/table_cache.cc index 26a4ad8f904..5aa5b8c8c82 100644 --- a/sql/table_cache.cc +++ b/sql/table_cache.cc @@ -55,7 +55,7 @@ /** Configuration. */ ulong tdc_size; /**< Table definition cache threshold for LRU eviction. */ ulong tc_size; /**< Table cache threshold for LRU eviction. */ -ulong tc_instances; +uint32 tc_instances; static uint32 tc_active_instances= 1; static uint32 tc_contention_warning_reported; @@ -172,8 +172,9 @@ struct Table_cache_instance { if (n_instances < tc_instances) { - if (my_atomic_cas32_weak_explicit(&tc_active_instances, &n_instances, - n_instances + 1, + if (my_atomic_cas32_weak_explicit((int32*) &tc_active_instances, + (int32*) &n_instances, + (int32) n_instances + 1, MY_MEMORY_ORDER_RELAXED, MY_MEMORY_ORDER_RELAXED)) { @@ -186,8 +187,8 @@ struct Table_cache_instance n_instances + 1); } } - else if (!my_atomic_fas32_explicit(&tc_contention_warning_reported, 1, - MY_MEMORY_ORDER_RELAXED)) + else if (!my_atomic_fas32_explicit((int32) &tc_contention_warning_reported, + 1, MY_MEMORY_ORDER_RELAXED)) { sql_print_warning("Detected table cache mutex contention at instance %d: " "%d%% waits. Additional table cache instance " @@ -353,7 +354,8 @@ void tc_purge(bool mark_flushed) void tc_add_table(THD *thd, TABLE *table) { - uint32 i= thd->thread_id % my_atomic_load32_explicit(&tc_active_instances, MY_MEMORY_ORDER_RELAXED); + uint32 i= thd->thread_id % my_atomic_load32_explicit((int32*) &tc_active_instances, + MY_MEMORY_ORDER_RELAXED); TABLE *LRU_table= 0; TDC_element *element= table->s->tdc; @@ -395,7 +397,8 @@ void tc_add_table(THD *thd, TABLE *table) static TABLE *tc_acquire_table(THD *thd, TDC_element *element) { uint32 n_instances= - my_atomic_load32_explicit(&tc_active_instances, MY_MEMORY_ORDER_RELAXED); + my_atomic_load32_explicit((int32*) &tc_active_instances, + MY_MEMORY_ORDER_RELAXED); uint32 i= thd->thread_id % n_instances; TABLE *table; diff --git a/sql/table_cache.h b/sql/table_cache.h index 24b04acf9bc..cac69296cc2 100644 --- a/sql/table_cache.h +++ b/sql/table_cache.h @@ -68,7 +68,7 @@ enum enum_tdc_remove_table_type extern ulong tdc_size; extern ulong tc_size; -extern ulong tc_instances; +extern uint32 tc_instances; extern bool tdc_init(void); extern void tdc_start_shutdown(void); |
