diff options
author | Sergey Vojtovich <svoj@mariadb.org> | 2013-12-10 19:00:36 +0400 |
---|---|---|
committer | Sergey Vojtovich <svoj@mariadb.org> | 2013-12-10 19:00:36 +0400 |
commit | 98c4f167c505627644369acfc4e278fab50d29d3 (patch) | |
tree | ddb6f3c7198382d26bee8d2ecac95f4d97e1b93e /sql/sql_base.cc | |
parent | b2c56742b5543f77a12b86731c51151d0d3e421d (diff) | |
download | mariadb-git-98c4f167c505627644369acfc4e278fab50d29d3.tar.gz |
MDEV-4956 - Reduce usage of LOCK_open: TABLE_SHARE::tdc.used_tables
- tc_acquire_table and tc_release_table do not access
TABLE_SHARE::tdc.used_tables anymore
- in tc_acquire_table(): release LOCK_tdc after we relase LOCK_open
(saves a few CPU cycles in critical section)
- in tc_release_table(): if we reached table cache threshold, evict
to-be-released table without moving it to unused_tables. unused_tables
must be empty at this point.
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r-- | sql/sql_base.cc | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 62def81b6ed..d5ef6fb4633 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -309,9 +309,11 @@ OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *db, const char *wild) share->table_name.str); (*start_list)->in_use= 0; mysql_mutex_lock(&LOCK_open); - TABLE_SHARE::TABLE_list::Iterator it(share->tdc.used_tables); - while (it++) - ++(*start_list)->in_use; + TABLE_SHARE::All_share_tables_list::Iterator it(share->tdc.all_tables); + TABLE *table; + while ((table= it++)) + if (table->in_use) + ++(*start_list)->in_use; mysql_mutex_unlock(&LOCK_open); (*start_list)->locked= 0; /* Obsolete. */ start_list= &(*start_list)->next; @@ -371,16 +373,19 @@ void free_io_cache(TABLE *table) void kill_delayed_threads_for_table(TABLE_SHARE *share) { - TABLE_SHARE::TABLE_list::Iterator it(share->tdc.used_tables); + TABLE_SHARE::All_share_tables_list::Iterator it(share->tdc.all_tables); TABLE *tab; mysql_mutex_assert_owner(&LOCK_open); + if (!delayed_insert_threads) + return; + while ((tab= it++)) { THD *in_use= tab->in_use; - if ((in_use->system_thread & SYSTEM_THREAD_DELAYED_INSERT) && + if (in_use && (in_use->system_thread & SYSTEM_THREAD_DELAYED_INSERT) && ! in_use->killed) { in_use->killed= KILL_SYSTEM_THREAD; |