summaryrefslogtreecommitdiff
path: root/storage/perfschema/pfs_instr_class.cc
diff options
context:
space:
mode:
Diffstat (limited to 'storage/perfschema/pfs_instr_class.cc')
-rw-r--r--storage/perfschema/pfs_instr_class.cc69
1 files changed, 45 insertions, 24 deletions
diff --git a/storage/perfschema/pfs_instr_class.cc b/storage/perfschema/pfs_instr_class.cc
index 0a4b47404a4..05c85104a94 100644
--- a/storage/perfschema/pfs_instr_class.cc
+++ b/storage/perfschema/pfs_instr_class.cc
@@ -135,9 +135,12 @@ static PFS_thread_class *thread_class_array= NULL;
*/
PFS_table_share *table_share_array= NULL;
-PFS_instr_class global_table_io_class;
-PFS_instr_class global_table_lock_class;
-PFS_instr_class global_idle_class;
+PFS_ALIGNED PFS_single_stat global_idle_stat;
+PFS_ALIGNED PFS_table_io_stat global_table_io_stat;
+PFS_ALIGNED PFS_table_lock_stat global_table_lock_stat;
+PFS_ALIGNED PFS_instr_class global_table_io_class;
+PFS_ALIGNED PFS_instr_class global_table_lock_class;
+PFS_ALIGNED PFS_instr_class global_idle_class;
/** Class-timer map */
enum_timer_name *class_timers[] =
@@ -165,7 +168,7 @@ enum_timer_name *class_timers[] =
@sa table_share_hash_get_key
@sa get_table_share_hash_pins
*/
-static LF_HASH table_share_hash;
+LF_HASH table_share_hash;
/** True if table_share_hash is initialized. */
static bool table_share_hash_inited= false;
@@ -193,19 +196,17 @@ uint mutex_class_start= 0;
uint rwlock_class_start= 0;
uint cond_class_start= 0;
uint file_class_start= 0;
-uint table_class_start= 0;
uint wait_class_max= 0;
uint socket_class_start= 0;
void init_event_name_sizing(const PFS_global_param *param)
{
- mutex_class_start= 0;
+ mutex_class_start= 3; /* global table io, table lock, idle */
rwlock_class_start= mutex_class_start + param->m_mutex_class_sizing;
cond_class_start= rwlock_class_start + param->m_rwlock_class_sizing;
file_class_start= cond_class_start + param->m_cond_class_sizing;
socket_class_start= file_class_start + param->m_file_class_sizing;
- table_class_start= socket_class_start + param->m_socket_class_sizing;
- wait_class_max= table_class_start + 3; /* global table io, lock, idle */
+ wait_class_max= socket_class_start + param->m_socket_class_sizing;
}
void register_global_classes()
@@ -213,19 +214,19 @@ void register_global_classes()
/* Table IO class */
init_instr_class(&global_table_io_class, "wait/io/table/sql/handler", 25,
0, PFS_CLASS_TABLE_IO);
- global_table_io_class.m_event_name_index= table_class_start;
+ global_table_io_class.m_event_name_index= GLOBAL_TABLE_IO_EVENT_INDEX;
configure_instr_class(&global_table_io_class);
/* Table lock class */
init_instr_class(&global_table_lock_class, "wait/lock/table/sql/handler", 27,
0, PFS_CLASS_TABLE_LOCK);
- global_table_lock_class.m_event_name_index= table_class_start + 1;
+ global_table_lock_class.m_event_name_index= GLOBAL_TABLE_LOCK_EVENT_INDEX;
configure_instr_class(&global_table_lock_class);
/* Idle class */
init_instr_class(&global_idle_class, "idle", 4,
0, PFS_CLASS_IDLE);
- global_idle_class.m_event_name_index= table_class_start + 2;
+ global_idle_class.m_event_name_index= GLOBAL_IDLE_EVENT_INDEX;
configure_instr_class(&global_idle_class);
}
@@ -384,6 +385,7 @@ int init_table_share_hash(void)
{
lf_hash_init(&table_share_hash, sizeof(PFS_table_share*), LF_HASH_UNIQUE,
0, 0, table_share_hash_get_key, &my_charset_bin);
+ table_share_hash.size= table_share_max;
table_share_hash_inited= true;
}
return 0;
@@ -715,7 +717,7 @@ PFS_sync_key register_mutex_class(const char *name, uint name_length,
*/
entry= &mutex_class_array[index];
init_instr_class(entry, name, name_length, flags, PFS_CLASS_MUTEX);
- entry->m_lock_stat.reset();
+ entry->m_mutex_stat.reset();
entry->m_event_name_index= mutex_class_start + index;
entry->m_singleton= NULL;
entry->m_enabled= false; /* disabled by default */
@@ -781,8 +783,7 @@ PFS_sync_key register_rwlock_class(const char *name, uint name_length,
{
entry= &rwlock_class_array[index];
init_instr_class(entry, name, name_length, flags, PFS_CLASS_RWLOCK);
- entry->m_read_lock_stat.reset();
- entry->m_write_lock_stat.reset();
+ entry->m_rwlock_stat.reset();
entry->m_event_name_index= rwlock_class_start + index;
entry->m_singleton= NULL;
entry->m_enabled= false; /* disabled by default */
@@ -1193,7 +1194,7 @@ static void set_keys(PFS_table_share *pfs, const TABLE_SHARE *share)
pfs_key->m_name_length= len;
}
- pfs_key_last= pfs->m_keys + MAX_KEY;
+ pfs_key_last= pfs->m_keys + MAX_INDEXES;
for ( ; pfs_key < pfs_key_last; pfs_key++)
pfs_key->m_name_length= 0;
}
@@ -1256,7 +1257,7 @@ PFS_table_share* find_or_create_table_share(PFS_thread *thread,
const uint retry_max= 3;
bool enabled= true;
bool timed= true;
- static uint table_share_monotonic_index= 0;
+ static uint PFS_ALIGNED table_share_monotonic_index= 0;
uint index;
uint attempts= 0;
PFS_table_share *pfs;
@@ -1299,8 +1300,7 @@ search:
while (++attempts <= table_share_max)
{
/* See create_mutex() */
- PFS_atomic::add_u32(& table_share_monotonic_index, 1);
- index= table_share_monotonic_index % table_share_max;
+ index= PFS_atomic::add_u32(& table_share_monotonic_index, 1) % table_share_max;
pfs= table_share_array + index;
if (pfs->m_lock.is_free())
@@ -1353,17 +1353,28 @@ search:
void PFS_table_share::aggregate_io(void)
{
- uint index= global_table_io_class.m_event_name_index;
- PFS_single_stat *table_io_total= & global_instr_class_waits_array[index];
- m_table_stat.sum_io(table_io_total);
+ uint safe_key_count= sanitize_index_count(m_key_count);
+ PFS_table_io_stat *from_stat;
+ PFS_table_io_stat *from_stat_last;
+ PFS_table_io_stat sum_io;
+
+ /* Aggregate stats for each index, if any */
+ from_stat= & m_table_stat.m_index_stat[0];
+ from_stat_last= from_stat + safe_key_count;
+ for ( ; from_stat < from_stat_last ; from_stat++)
+ sum_io.aggregate(from_stat);
+
+ /* Aggregate stats for the table */
+ sum_io.aggregate(& m_table_stat.m_index_stat[MAX_INDEXES]);
+
+ /* Add this table stats to the global sink. */
+ global_table_io_stat.aggregate(& sum_io);
m_table_stat.fast_reset_io();
}
void PFS_table_share::aggregate_lock(void)
{
- uint index= global_table_lock_class.m_event_name_index;
- PFS_single_stat *table_lock_total= & global_instr_class_waits_array[index];
- m_table_stat.sum_lock(table_lock_total);
+ global_table_lock_stat.aggregate(& m_table_stat.m_lock_stat);
m_table_stat.fast_reset_lock();
}
@@ -1418,6 +1429,16 @@ PFS_table_share *sanitize_table_share(PFS_table_share *unsafe)
SANITIZE_ARRAY_BODY(PFS_table_share, table_share_array, table_share_max, unsafe);
}
+/** Reset the wait statistics per instrument class. */
+void reset_events_waits_by_class()
+{
+ reset_file_class_io();
+ reset_socket_class_io();
+ global_idle_stat.reset();
+ global_table_io_stat.reset();
+ global_table_lock_stat.reset();
+}
+
/** Reset the io statistics per file class. */
void reset_file_class_io(void)
{