From 98c4f167c505627644369acfc4e278fab50d29d3 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Tue, 10 Dec 2013 19:00:36 +0400 Subject: 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. --- sql/sql_test.cc | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'sql/sql_test.cc') diff --git a/sql/sql_test.cc b/sql/sql_test.cc index 1a241521fd7..151ceed4006 100644 --- a/sql/sql_test.cc +++ b/sql/sql_test.cc @@ -92,21 +92,23 @@ static void print_cached_tables(void) mysql_mutex_lock(&LOCK_open); while ((share= tdc_it.next())) { - TABLE_SHARE::TABLE_list::Iterator it(share->tdc.used_tables); + TABLE_SHARE::All_share_tables_list::Iterator it(share->tdc.all_tables); while ((entry= it++)) { - printf("%-14.14s %-32s%6ld%8ld%6d %s\n", - entry->s->db.str, entry->s->table_name.str, entry->s->version, - entry->in_use->thread_id, entry->db_stat ? 1 : 0, - lock_descriptions[(int)entry->reginfo.lock_type]); - } - it.init(share->tdc.free_tables); - while ((entry= it++)) - { - unused++; - printf("%-14.14s %-32s%6ld%8ld%6d %s\n", - entry->s->db.str, entry->s->table_name.str, entry->s->version, - 0L, entry->db_stat ? 1 : 0, "Not in use"); + if (entry->in_use) + { + printf("%-14.14s %-32s%6ld%8ld%6d %s\n", + entry->s->db.str, entry->s->table_name.str, entry->s->version, + entry->in_use->thread_id, entry->db_stat ? 1 : 0, + lock_descriptions[(int)entry->reginfo.lock_type]); + } + else + { + unused++; + printf("%-14.14s %-32s%6ld%8ld%6d %s\n", + entry->s->db.str, entry->s->table_name.str, entry->s->version, + 0L, entry->db_stat ? 1 : 0, "Not in use"); + } } } tdc_it.deinit(); -- cgit v1.2.1