Skip to content

Commit d63f42a

Browse files
committed
Allow fixed table_open_cache_instances
Introduced table_open_cache_instances_fix variable. It activates all table_open_cache_instances early. Can be useful for cases when table cache warm up period is undesired. Such as benchmarking.
1 parent a7528a6 commit d63f42a

9 files changed

+50
-0
lines changed

mysql-test/main/mysqld--help.result

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,6 +1549,10 @@ The following specify which files/extra groups are read (specified before remain
15491549
The number of cached open tables
15501550
--table-open-cache-instances=#
15511551
Maximum number of table cache instances
1552+
--table-open-cache-instances-fix
1553+
Activate all table_open_cache_instances early. Can be
1554+
useful for cases when table cache warm up period is
1555+
undesired. Such as benchmarking
15521556
--tc-heuristic-recover=name
15531557
Decision to use in heuristic recover process. One of: OFF,
15541558
COMMIT, ROLLBACK
@@ -2055,6 +2059,7 @@ sysdate-is-now FALSE
20552059
system-versioning-alter-history ERROR
20562060
system-versioning-insert-history FALSE
20572061
table-definition-cache 400
2062+
table-open-cache-instances-fix FALSE
20582063
tc-heuristic-recover OFF
20592064
tcp-keepalive-interval 0
20602065
tcp-keepalive-probes 0

mysql-test/suite/sys_vars/r/sysvars_server_embedded.result

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3942,6 +3942,16 @@ NUMERIC_BLOCK_SIZE 1
39423942
ENUM_VALUE_LIST NULL
39433943
READ_ONLY YES
39443944
COMMAND_LINE_ARGUMENT REQUIRED
3945+
VARIABLE_NAME TABLE_OPEN_CACHE_INSTANCES_FIX
3946+
VARIABLE_SCOPE GLOBAL
3947+
VARIABLE_TYPE BOOLEAN
3948+
VARIABLE_COMMENT Activate all table_open_cache_instances early. Can be useful for cases when table cache warm up period is undesired. Such as benchmarking
3949+
NUMERIC_MIN_VALUE NULL
3950+
NUMERIC_MAX_VALUE NULL
3951+
NUMERIC_BLOCK_SIZE NULL
3952+
ENUM_VALUE_LIST OFF,ON
3953+
READ_ONLY YES
3954+
COMMAND_LINE_ARGUMENT OPTIONAL
39453955
VARIABLE_NAME TCP_KEEPALIVE_INTERVAL
39463956
VARIABLE_SCOPE GLOBAL
39473957
VARIABLE_TYPE INT

mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4722,6 +4722,16 @@ NUMERIC_BLOCK_SIZE 1
47224722
ENUM_VALUE_LIST NULL
47234723
READ_ONLY YES
47244724
COMMAND_LINE_ARGUMENT REQUIRED
4725+
VARIABLE_NAME TABLE_OPEN_CACHE_INSTANCES_FIX
4726+
VARIABLE_SCOPE GLOBAL
4727+
VARIABLE_TYPE BOOLEAN
4728+
VARIABLE_COMMENT Activate all table_open_cache_instances early. Can be useful for cases when table cache warm up period is undesired. Such as benchmarking
4729+
NUMERIC_MIN_VALUE NULL
4730+
NUMERIC_MAX_VALUE NULL
4731+
NUMERIC_BLOCK_SIZE NULL
4732+
ENUM_VALUE_LIST OFF,ON
4733+
READ_ONLY YES
4734+
COMMAND_LINE_ARGUMENT OPTIONAL
47254735
VARIABLE_NAME TCP_KEEPALIVE_INTERVAL
47264736
VARIABLE_SCOPE GLOBAL
47274737
VARIABLE_TYPE INT
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
SHOW VARIABLES LIKE 'table_open_cache_instances_fix';
2+
Variable_name Value
3+
table_open_cache_instances_fix ON
4+
SHOW VARIABLES LIKE 'table_open_cache_instances';
5+
Variable_name Value
6+
table_open_cache_instances 4
7+
SHOW STATUS LIKE 'table_open_cache_active_instances';
8+
Variable_name Value
9+
Table_open_cache_active_instances 4
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--table-open-cache-instances-fix --table-open-cache=100 --table-open-cache-instances=4
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SHOW VARIABLES LIKE 'table_open_cache_instances_fix';
2+
SHOW VARIABLES LIKE 'table_open_cache_instances';
3+
SHOW STATUS LIKE 'table_open_cache_active_instances';

sql/sys_vars.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4299,6 +4299,14 @@ static Sys_var_ulong Sys_table_cache_size(
42994299
BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0),
43004300
ON_UPDATE(fix_table_open_cache));
43014301

4302+
static Sys_var_mybool Sys_table_cache_instances_fix(
4303+
"table_open_cache_instances_fix",
4304+
"Activate all table_open_cache_instances early. Can be useful for "
4305+
"cases when table cache warm up period is undesired. Such as "
4306+
"benchmarking",
4307+
READ_ONLY GLOBAL_VAR(tc_instances_fix), CMD_LINE(OPT_ARG),
4308+
DEFAULT(FALSE));
4309+
43024310
static Sys_var_uint Sys_table_cache_instances(
43034311
"table_open_cache_instances", "Maximum number of table cache instances",
43044312
READ_ONLY GLOBAL_VAR(tc_instances), CMD_LINE(REQUIRED_ARG),

sql/table_cache.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ I_P_List <TDC_element,
7171
I_P_List_fast_push_back<TDC_element> > unused_shares;
7272

7373
static bool tdc_inited;
74+
my_bool tc_instances_fix;
7475

7576

7677
/**
@@ -612,6 +613,8 @@ bool tdc_init(void)
612613
DBUG_RETURN(true);
613614
tc_allocated_size= (tc_instances + 1) * sizeof *tc;
614615
update_malloc_size(tc_allocated_size, 0);
616+
if (tc_instances_fix)
617+
tc_active_instances.store(tc_instances, std::memory_order_relaxed);
615618
tdc_inited= true;
616619
mysql_mutex_init(key_LOCK_unused_shares, &LOCK_unused_shares,
617620
MY_MUTEX_INIT_FAST);

sql/table_cache.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ struct TDC_element
6464
extern ulong tdc_size;
6565
extern ulong tc_size;
6666
extern uint32 tc_instances;
67+
extern my_bool tc_instances_fix;
6768

6869
extern bool tdc_init(void);
6970
extern void tdc_start_shutdown(void);

0 commit comments

Comments
 (0)