Commit a2b1c58c authored by Sergey Vojtovich's avatar Sergey Vojtovich

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.
parent 8613633f
......@@ -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
......
......@@ -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
......
......@@ -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));
......
......@@ -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;
......
......@@ -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);
......
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