Skip to content

Commit

Permalink
MDEV-10296 - Multi-instance table cache
Browse files Browse the repository at this point in the history
Improve scalability by implementing multi-instance table cache.
  • Loading branch information
Sergey Vojtovich committed Sep 16, 2016
1 parent 6c1c27e commit 7e9ac7b
Show file tree
Hide file tree
Showing 9 changed files with 186 additions and 185 deletions.
3 changes: 3 additions & 0 deletions mysql-test/r/mysqld--help.result
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,8 @@ The following options may be given as the first argument:
The number of cached table definitions
--table-open-cache=#
The number of cached open tables
--table-open-cache-instances=#
The number of table cache instances
--tc-heuristic-recover=name
Decision to use in heuristic recover process. One of: OFF,
COMMIT, ROLLBACK
Expand Down Expand Up @@ -1457,6 +1459,7 @@ sysdate-is-now FALSE
table-cache 431
table-definition-cache 400
table-open-cache 431
table-open-cache-instances 1
tc-heuristic-recover OFF
thread-cache-size 151
thread-pool-idle-timeout 60
Expand Down
14 changes: 14 additions & 0 deletions mysql-test/suite/sys_vars/r/sysvars_server_embedded.result
Original file line number Diff line number Diff line change
Expand Up @@ -3887,6 +3887,20 @@ NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL
READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME TABLE_OPEN_CACHE_INSTANCES
SESSION_VALUE NULL
GLOBAL_VALUE 1
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 1
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT The number of table cache instances
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 64
NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL
READ_ONLY YES
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME THREAD_CACHE_SIZE
SESSION_VALUE NULL
GLOBAL_VALUE 151
Expand Down
14 changes: 14 additions & 0 deletions mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result
Original file line number Diff line number Diff line change
Expand Up @@ -4657,6 +4657,20 @@ NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL
READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME TABLE_OPEN_CACHE_INSTANCES
SESSION_VALUE NULL
GLOBAL_VALUE 1
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 1
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT The number of table cache instances
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 64
NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL
READ_ONLY YES
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME THREAD_CACHE_SIZE
SESSION_VALUE NULL
GLOBAL_VALUE 151
Expand Down
4 changes: 1 addition & 3 deletions sql/mysqld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4974,8 +4974,7 @@ static int init_server_components()
all things are initialized so that unireg_abort() doesn't fail
*/
mdl_init();
tdc_init();
if (hostname_cache_init())
if (tdc_init() || hostname_cache_init())
unireg_abort(1);

query_cache_set_min_res_unit(query_cache_min_res_unit);
Expand Down Expand Up @@ -7643,7 +7642,6 @@ struct my_option my_long_options[]=
MYSQL_TO_BE_IMPLEMENTED_OPTION("eq-range-index-dive-limit"),
MYSQL_COMPATIBILITY_OPTION("server-id-bits"),
MYSQL_TO_BE_IMPLEMENTED_OPTION("slave-rows-search-algorithms"), // HAVE_REPLICATION
MYSQL_COMPATIBILITY_OPTION("table-open-cache-instances"),
MYSQL_TO_BE_IMPLEMENTED_OPTION("slave-allow-batching"), // HAVE_REPLICATION
MYSQL_COMPATIBILITY_OPTION("slave-checkpoint-period"), // HAVE_REPLICATION
MYSQL_COMPATIBILITY_OPTION("slave-checkpoint-group"), // HAVE_REPLICATION
Expand Down
3 changes: 1 addition & 2 deletions sql/sql_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -878,8 +878,7 @@ void close_thread_table(THD *thd, TABLE **table_ptr)
Do this *before* entering the TABLE_SHARE::tdc.LOCK_table_share
critical section.
*/
if (table->file != NULL)
MYSQL_UNBIND_TABLE(table->file);
MYSQL_UNBIND_TABLE(table->file);

tc_release_table(table);
DBUG_VOID_RETURN;
Expand Down
5 changes: 5 additions & 0 deletions sql/sys_vars.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3227,6 +3227,11 @@ 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(
"table_open_cache_instances", "The number of table cache instances",
READ_ONLY GLOBAL_VAR(tc_instances), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(1, 64), DEFAULT(1), BLOCK_SIZE(1));

static Sys_var_ulong Sys_thread_cache_size(
"thread_cache_size",
"How many threads we should keep in a cache for reuse. These are freed after 5 minutes of idle time",
Expand Down
4 changes: 2 additions & 2 deletions sql/table.h
Original file line number Diff line number Diff line change
Expand Up @@ -1021,13 +1021,13 @@ struct TABLE
One should use methods of I_P_List template instead.
*/
TABLE *share_all_next, **share_all_prev;
TABLE *global_free_next, **global_free_prev;
friend struct All_share_tables;
friend class Table_cache_instance;

public:

THD *in_use; /* Which thread uses this */
/* Time when table was released to table cache. Valid for unused tables. */
ulonglong tc_time;
Field **field; /* Pointer to fields */

uchar *record[2]; /* Pointer to records */
Expand Down
Loading

0 comments on commit 7e9ac7b

Please sign in to comment.