List:Commits« Previous MessageNext Message »
From:Marc Alff Date:May 26 2011 9:06am
Subject:bzr push into mysql-trunk-pfs-tuning branch (marc.alff:3376 to 3377)
View as plain text  
 3377 Marc Alff	2011-05-26
      Added internal stats

    added:
      storage/perfschema/pfs_internal_stat.cc
      storage/perfschema/pfs_internal_stat.h
    modified:
      storage/perfschema/CMakeLists.txt
      storage/perfschema/ha_perfschema.cc
      storage/perfschema/pfs.cc
      storage/perfschema/pfs_instr.cc
 3376 Marc Alff	2011-05-20
      Disabled static PSI_CALL due to unresolved build issues

    modified:
      include/psi_provider.h
=== modified file 'storage/perfschema/CMakeLists.txt'
--- a/storage/perfschema/CMakeLists.txt	2011-02-14 14:23:55 +0000
+++ b/storage/perfschema/CMakeLists.txt	2011-05-26 09:05:41 +0000
@@ -40,6 +40,7 @@ pfs_events_waits.h
 pfs_global.h
 pfs_instr.h
 pfs_instr_class.h
+pfs_internal_stat.h
 pfs_lock.h
 pfs_server.h
 pfs_setup_actor.h
@@ -87,6 +88,7 @@ pfs_events_waits.cc
 pfs_global.cc
 pfs_instr.cc
 pfs_instr_class.cc
+pfs_internal_stat.cc
 pfs_server.cc
 pfs_setup_actor.cc
 pfs_setup_object.cc

=== modified file 'storage/perfschema/ha_perfschema.cc'
--- a/storage/perfschema/ha_perfschema.cc	2011-02-14 14:23:55 +0000
+++ b/storage/perfschema/ha_perfschema.cc	2011-05-26 09:05:41 +0000
@@ -28,6 +28,7 @@
 #include "pfs_column_values.h"
 #include "pfs_instr_class.h"
 #include "pfs_instr.h"
+#include "pfs_internal_stat.h"
 
 #ifdef MY_ATOMIC_MODE_DUMMY
 /*
@@ -150,6 +151,202 @@ static struct st_mysql_show_var pfs_stat
     (char*) &stage_class_lost, SHOW_LONG},
   {"Performance_schema_statement_classes_lost",
     (char*) &statement_class_lost, SHOW_LONG},
+
+#ifdef HAVE_INTERNAL_STAT
+
+  {"pfs_register_mutex_v1",
+    (char*) &pfs_internal_register_mutex_v1, SHOW_LONG},
+  {"pfs_register_rwlock_v1",
+    (char*) &pfs_internal_register_rwlock_v1, SHOW_LONG},
+  {"pfs_register_cond_v1",
+    (char*) &pfs_internal_register_cond_v1, SHOW_LONG},
+  {"pfs_register_thread_v1",
+    (char*) &pfs_internal_register_thread_v1, SHOW_LONG},
+  {"pfs_register_file_v1",
+    (char*) &pfs_internal_register_file_v1, SHOW_LONG},
+  {"pfs_register_stage_v1",
+    (char*) &pfs_internal_register_stage_v1, SHOW_LONG},
+  {"pfs_register_statement_v1",
+    (char*) &pfs_internal_register_statement_v1, SHOW_LONG},
+  {"pfs_init_mutex_v1",
+    (char*) &pfs_internal_init_mutex_v1, SHOW_LONG},
+  {"pfs_destroy_mutex_v1",
+    (char*) &pfs_internal_destroy_mutex_v1, SHOW_LONG},
+  {"pfs_init_rwlock_v1",
+    (char*) &pfs_internal_init_rwlock_v1, SHOW_LONG},
+  {"pfs_destroy_rwlock_v1",
+    (char*) &pfs_internal_destroy_rwlock_v1, SHOW_LONG},
+  {"pfs_init_cond_v1",
+    (char*) &pfs_internal_init_cond_v1, SHOW_LONG},
+  {"pfs_destroy_cond_v1",
+    (char*) &pfs_internal_destroy_cond_v1, SHOW_LONG},
+  {"pfs_get_table_share_v1",
+    (char*) &pfs_internal_get_table_share_v1, SHOW_LONG},
+  {"pfs_release_table_share_v1",
+    (char*) &pfs_internal_release_table_share_v1, SHOW_LONG},
+  {"pfs_drop_table_share_v1",
+    (char*) &pfs_internal_drop_table_share_v1, SHOW_LONG},
+  {"pfs_open_table_v1",
+    (char*) &pfs_internal_open_table_v1, SHOW_LONG},
+  {"pfs_close_table_v1",
+    (char*) &pfs_internal_close_table_v1, SHOW_LONG},
+  {"pfs_create_file_v1",
+    (char*) &pfs_internal_create_file_v1, SHOW_LONG},
+  {"pfs_spawn_thread_v1",
+    (char*) &pfs_internal_spawn_thread_v1, SHOW_LONG},
+  {"pfs_new_thread_v1",
+    (char*) &pfs_internal_new_thread_v1, SHOW_LONG},
+  {"pfs_set_thread_id_v1",
+    (char*) &pfs_internal_set_thread_id_v1, SHOW_LONG},
+  {"pfs_get_thread_v1",
+    (char*) &pfs_internal_get_thread_v1, SHOW_LONG},
+  {"pfs_set_thread_user_v1",
+    (char*) &pfs_internal_set_thread_user_v1, SHOW_LONG},
+  {"pfs_set_thread_user_host_v1",
+    (char*) &pfs_internal_set_thread_user_host_v1, SHOW_LONG},
+  {"pfs_set_thread_db_v1",
+    (char*) &pfs_internal_set_thread_db_v1, SHOW_LONG},
+  {"pfs_set_thread_command_v1",
+    (char*) &pfs_internal_set_thread_command_v1, SHOW_LONG},
+  {"pfs_set_thread_start_time_v1",
+    (char*) &pfs_internal_set_thread_start_time_v1, SHOW_LONG},
+  {"pfs_set_thread_state_v1",
+    (char*) &pfs_internal_set_thread_state_v1, SHOW_LONG},
+  {"pfs_set_thread_info_v1",
+    (char*) &pfs_internal_set_thread_info_v1, SHOW_LONG},
+  {"pfs_set_thread_v1",
+    (char*) &pfs_internal_set_thread_v1, SHOW_LONG},
+  {"pfs_delete_current_thread_v1",
+    (char*) &pfs_internal_delete_current_thread_v1, SHOW_LONG},
+  {"pfs_delete_thread_v1",
+    (char*) &pfs_internal_delete_thread_v1, SHOW_LONG},
+  {"pfs_get_thread_mutex_locker_v1",
+    (char*) &pfs_internal_get_thread_mutex_locker_v1, SHOW_LONG},
+  {"pfs_get_thread_rwlock_locker_v1",
+    (char*) &pfs_internal_get_thread_rwlock_locker_v1, SHOW_LONG},
+  {"pfs_get_thread_cond_locker_v1",
+    (char*) &pfs_internal_get_thread_cond_locker_v1, SHOW_LONG},
+  {"pfs_get_thread_table_io_locker_v1",
+    (char*) &pfs_internal_get_thread_table_io_locker_v1, SHOW_LONG},
+  {"pfs_get_thread_table_lock_locker_v1",
+    (char*) &pfs_internal_get_thread_table_lock_locker_v1, SHOW_LONG},
+  {"pfs_get_thread_file_name_locker_v1",
+    (char*) &pfs_internal_get_thread_file_name_locker_v1, SHOW_LONG},
+  {"pfs_get_thread_file_stream_locker_v1",
+    (char*) &pfs_internal_get_thread_file_stream_locker_v1, SHOW_LONG},
+  {"pfs_get_thread_file_descriptor_locker_v1",
+    (char*) &pfs_internal_get_thread_file_descriptor_locker_v1, SHOW_LONG},
+  {"pfs_unlock_mutex_v1",
+    (char*) &pfs_internal_unlock_mutex_v1, SHOW_LONG},
+  {"pfs_unlock_rwlock_v1",
+    (char*) &pfs_internal_unlock_rwlock_v1, SHOW_LONG},
+  {"pfs_signal_cond_v1",
+    (char*) &pfs_internal_signal_cond_v1, SHOW_LONG},
+  {"pfs_broadcast_cond_v1",
+    (char*) &pfs_internal_broadcast_cond_v1, SHOW_LONG},
+  {"pfs_start_mutex_wait_v1",
+    (char*) &pfs_internal_start_mutex_wait_v1, SHOW_LONG},
+  {"pfs_end_mutex_wait_v1",
+    (char*) &pfs_internal_end_mutex_wait_v1, SHOW_LONG},
+  {"pfs_start_rwlock_rdwait_v1",
+    (char*) &pfs_internal_start_rwlock_rdwait_v1, SHOW_LONG},
+  {"pfs_end_rwlock_rdwait_v1",
+    (char*) &pfs_internal_end_rwlock_rdwait_v1, SHOW_LONG},
+  {"pfs_start_rwlock_wrwait_v1",
+    (char*) &pfs_internal_start_rwlock_wrwait_v1, SHOW_LONG},
+  {"pfs_end_rwlock_wrwait_v1",
+    (char*) &pfs_internal_end_rwlock_wrwait_v1, SHOW_LONG},
+  {"pfs_start_cond_wait_v1",
+    (char*) &pfs_internal_start_cond_wait_v1, SHOW_LONG},
+  {"pfs_end_cond_wait_v1",
+    (char*) &pfs_internal_end_cond_wait_v1, SHOW_LONG},
+  {"pfs_start_table_io_wait_v1",
+    (char*) &pfs_internal_start_table_io_wait_v1, SHOW_LONG},
+  {"pfs_end_table_io_wait_v1",
+    (char*) &pfs_internal_end_table_io_wait_v1, SHOW_LONG},
+  {"pfs_start_table_lock_wait_v1",
+    (char*) &pfs_internal_start_table_lock_wait_v1, SHOW_LONG},
+  {"pfs_end_table_lock_wait_v1",
+    (char*) &pfs_internal_end_table_lock_wait_v1, SHOW_LONG},
+  {"pfs_start_file_open_wait_v1",
+    (char*) &pfs_internal_start_file_open_wait_v1, SHOW_LONG},
+  {"pfs_end_file_open_wait_v1",
+    (char*) &pfs_internal_end_file_open_wait_v1, SHOW_LONG},
+  {"pfs_end_file_open_wait_and_bind_to_descriptor_v1",
+    (char*) &pfs_internal_end_file_open_wait_and_bind_to_descriptor_v1, SHOW_LONG},
+  {"pfs_start_file_wait_v1",
+    (char*) &pfs_internal_start_file_wait_v1, SHOW_LONG},
+  {"pfs_end_file_wait_v1",
+    (char*) &pfs_internal_end_file_wait_v1, SHOW_LONG},
+  {"pfs_start_stage_v1",
+    (char*) &pfs_internal_start_stage_v1, SHOW_LONG},
+  {"pfs_end_stage_v1",
+    (char*) &pfs_internal_end_stage_v1, SHOW_LONG},
+  {"pfs_get_thread_statement_locker_v1",
+    (char*) &pfs_internal_get_thread_statement_locker_v1, SHOW_LONG},
+  {"pfs_refine_statement_v1",
+    (char*) &pfs_internal_refine_statement_v1, SHOW_LONG},
+  {"pfs_start_statement_v1",
+    (char*) &pfs_internal_start_statement_v1, SHOW_LONG},
+  {"pfs_set_statement_text_v1",
+    (char*) &pfs_internal_set_statement_text_v1, SHOW_LONG},
+  {"pfs_set_statement_lock_time_v1",
+    (char*) &pfs_internal_set_statement_lock_time_v1, SHOW_LONG},
+  {"pfs_set_statement_rows_sent_v1",
+    (char*) &pfs_internal_set_statement_rows_sent_v1, SHOW_LONG},
+  {"pfs_set_statement_rows_examined_v1",
+    (char*) &pfs_internal_set_statement_rows_examined_v1, SHOW_LONG},
+  {"pfs_inc_statement_created_tmp_disk_tables_v1",
+    (char*) &pfs_internal_inc_statement_created_tmp_disk_tables_v1, SHOW_LONG},
+  {"pfs_inc_statement_created_tmp_tables_v1",
+    (char*) &pfs_internal_inc_statement_created_tmp_tables_v1, SHOW_LONG},
+  {"pfs_inc_statement_select_full_join_v1",
+    (char*) &pfs_internal_inc_statement_select_full_join_v1, SHOW_LONG},
+  {"pfs_inc_statement_select_full_range_join_v1",
+    (char*) &pfs_internal_inc_statement_select_full_range_join_v1, SHOW_LONG},
+  {"pfs_inc_statement_select_range_v1",
+    (char*) &pfs_internal_inc_statement_select_range_v1, SHOW_LONG},
+  {"pfs_inc_statement_select_range_check_v1",
+    (char*) &pfs_internal_inc_statement_select_range_check_v1, SHOW_LONG},
+  {"pfs_inc_statement_select_scan_v1",
+    (char*) &pfs_internal_inc_statement_select_scan_v1, SHOW_LONG},
+  {"pfs_inc_statement_sort_merge_passes_v1",
+    (char*) &pfs_internal_inc_statement_sort_merge_passes_v1, SHOW_LONG},
+  {"pfs_inc_statement_sort_range_v1",
+    (char*) &pfs_internal_inc_statement_sort_range_v1, SHOW_LONG},
+  {"pfs_inc_statement_sort_rows_v1",
+    (char*) &pfs_internal_inc_statement_sort_rows_v1, SHOW_LONG},
+  {"pfs_inc_statement_sort_scan_v1",
+    (char*) &pfs_internal_inc_statement_sort_scan_v1, SHOW_LONG},
+  {"pfs_set_statement_no_index_used_v1",
+    (char*) &pfs_internal_set_statement_no_index_used_v1, SHOW_LONG},
+  {"pfs_set_statement_no_good_index_used_v1",
+    (char*) &pfs_internal_set_statement_no_good_index_used_v1, SHOW_LONG},
+  {"pfs_end_statement_v1",
+    (char*) &pfs_internal_end_statement_v1, SHOW_LONG},
+
+  {"pfs_create_mutex",
+    (char*) &pfs_internal_create_mutex, SHOW_LONG},
+  {"pfs_create_mutex_scan",
+    (char*) &pfs_internal_create_mutex_scan, SHOW_LONG},
+  {"pfs_create_rwlock",
+    (char*) &pfs_internal_create_rwlock, SHOW_LONG},
+  {"pfs_create_rwlock_scan",
+    (char*) &pfs_internal_create_rwlock_scan, SHOW_LONG},
+  {"pfs_create_cond",
+    (char*) &pfs_internal_create_cond, SHOW_LONG},
+  {"pfs_create_cond_scan",
+    (char*) &pfs_internal_create_cond_scan, SHOW_LONG},
+  {"pfs_create_thread",
+    (char*) &pfs_internal_create_thread, SHOW_LONG},
+  {"pfs_create_thread_scan",
+    (char*) &pfs_internal_create_thread_scan, SHOW_LONG},
+  {"pfs_create_table",
+    (char*) &pfs_internal_create_table, SHOW_LONG},
+  {"pfs_create_table_scan",
+    (char*) &pfs_internal_create_table_scan, SHOW_LONG},
+#endif
+
   {NullS, NullS, SHOW_LONG}
 };
 

=== modified file 'storage/perfschema/pfs.cc'
--- a/storage/perfschema/pfs.cc	2011-05-17 13:51:11 +0000
+++ b/storage/perfschema/pfs.cc	2011-05-26 09:05:41 +0000
@@ -35,6 +35,7 @@
 #include "pfs_events_statements.h"
 #include "pfs_setup_actor.h"
 #include "pfs_setup_object.h"
+#include "pfs_internal_stat.h"
 #include "sql_error.h"
 
 /**
@@ -1194,6 +1195,8 @@ void pfs_register_mutex_v1(const char *c
                               PSI_mutex_info_v1 *info,
                               int count)
 {
+  PFS_INTERNAL_INC(pfs_internal_register_mutex_v1);
+
   REGISTER_BODY_V1(PSI_mutex_key,
                    mutex_instrument_prefix,
                    register_mutex_class)
@@ -1207,6 +1210,8 @@ void pfs_register_rwlock_v1(const char *
                                PSI_rwlock_info_v1 *info,
                                int count)
 {
+  PFS_INTERNAL_INC(pfs_internal_register_rwlock_v1);
+
   REGISTER_BODY_V1(PSI_rwlock_key,
                    rwlock_instrument_prefix,
                    register_rwlock_class)
@@ -1220,6 +1225,8 @@ void pfs_register_cond_v1(const char *ca
                              PSI_cond_info_v1 *info,
                              int count)
 {
+  PFS_INTERNAL_INC(pfs_internal_register_cond_v1);
+
   REGISTER_BODY_V1(PSI_cond_key,
                    cond_instrument_prefix,
                    register_cond_class)
@@ -1233,6 +1240,8 @@ void pfs_register_thread_v1(const char *
                                PSI_thread_info_v1 *info,
                                int count)
 {
+  PFS_INTERNAL_INC(pfs_internal_register_thread_v1);
+
   REGISTER_BODY_V1(PSI_thread_key,
                    thread_instrument_prefix,
                    register_thread_class)
@@ -1246,6 +1255,8 @@ void pfs_register_file_v1(const char *ca
                              PSI_file_info_v1 *info,
                              int count)
 {
+  PFS_INTERNAL_INC(pfs_internal_register_file_v1);
+
   REGISTER_BODY_V1(PSI_file_key,
                    file_instrument_prefix,
                    register_file_class)
@@ -1255,6 +1266,8 @@ void pfs_register_stage_v1(const char *c
                               PSI_stage_info_v1 **info_array,
                               int count)
 {
+  PFS_INTERNAL_INC(pfs_internal_register_stage_v1);
+
   char formatted_name[PFS_MAX_INFO_NAME_LENGTH];
   int prefix_length;
   int len;
@@ -1298,6 +1311,8 @@ void pfs_register_statement_v1(const cha
                                   PSI_statement_info_v1 *info,
                                   int count)
 {
+  PFS_INTERNAL_INC(pfs_internal_register_statement_v1);
+
   char formatted_name[PFS_MAX_INFO_NAME_LENGTH];
   int prefix_length;
   int len;
@@ -1351,6 +1366,8 @@ void pfs_register_statement_v1(const cha
 PSI_mutex*
 pfs_init_mutex_v1(PSI_mutex_key key, const void *identity)
 {
+  PFS_INTERNAL_INC(pfs_internal_init_mutex_v1);
+
   INIT_BODY_V1(mutex, key, identity);
 }
 
@@ -1360,6 +1377,8 @@ pfs_init_mutex_v1(PSI_mutex_key key, con
 */
 void pfs_destroy_mutex_v1(PSI_mutex* mutex)
 {
+  PFS_INTERNAL_INC(pfs_internal_destroy_mutex_v1);
+
   PFS_mutex *pfs= reinterpret_cast<PFS_mutex*> (mutex);
 
   if (unlikely(pfs == NULL))
@@ -1375,6 +1394,8 @@ void pfs_destroy_mutex_v1(PSI_mutex* mut
 PSI_rwlock*
 pfs_init_rwlock_v1(PSI_rwlock_key key, const void *identity)
 {
+  PFS_INTERNAL_INC(pfs_internal_init_rwlock_v1);
+
   INIT_BODY_V1(rwlock, key, identity);
 }
 
@@ -1384,6 +1405,8 @@ pfs_init_rwlock_v1(PSI_rwlock_key key, c
 */
 void pfs_destroy_rwlock_v1(PSI_rwlock* rwlock)
 {
+  PFS_INTERNAL_INC(pfs_internal_destroy_rwlock_v1);
+
   PFS_rwlock *pfs= reinterpret_cast<PFS_rwlock*> (rwlock);
 
   if (unlikely(pfs == NULL))
@@ -1399,6 +1422,8 @@ void pfs_destroy_rwlock_v1(PSI_rwlock* r
 PSI_cond*
 pfs_init_cond_v1(PSI_cond_key key, const void *identity)
 {
+  PFS_INTERNAL_INC(pfs_internal_init_cond_v1);
+
   INIT_BODY_V1(cond, key, identity);
 }
 
@@ -1408,6 +1433,8 @@ pfs_init_cond_v1(PSI_cond_key key, const
 */
 void pfs_destroy_cond_v1(PSI_cond* cond)
 {
+  PFS_INTERNAL_INC(pfs_internal_destroy_cond_v1);
+
   PFS_cond *pfs= reinterpret_cast<PFS_cond*> (cond);
 
   if (unlikely(pfs == NULL))
@@ -1423,6 +1450,8 @@ void pfs_destroy_cond_v1(PSI_cond* cond)
 PSI_table_share*
 pfs_get_table_share_v1(my_bool temporary, TABLE_SHARE *share)
 {
+  PFS_INTERNAL_INC(pfs_internal_get_table_share_v1);
+
   /* An instrumented thread is required, for LF_PINS. */
   PFS_thread *pfs_thread= get_pfs_thread();
   if (unlikely(pfs_thread == NULL))
@@ -1438,6 +1467,8 @@ pfs_get_table_share_v1(my_bool temporary
 */
 void pfs_release_table_share_v1(PSI_table_share* share)
 {
+  PFS_INTERNAL_INC(pfs_internal_release_table_share_v1);
+
   PFS_table_share* pfs= reinterpret_cast<PFS_table_share*> (share);
 
   if (unlikely(pfs == NULL))
@@ -1454,6 +1485,8 @@ void
 pfs_drop_table_share_v1(const char *schema_name, int schema_name_length,
                     const char *table_name, int table_name_length)
 {
+  PFS_INTERNAL_INC(pfs_internal_drop_table_share_v1);
+
   PFS_thread *pfs_thread= get_pfs_thread();
   if (unlikely(pfs_thread == NULL))
     return;
@@ -1469,6 +1502,8 @@ pfs_drop_table_share_v1(const char *sche
 PSI_table*
 pfs_open_table_v1(PSI_table_share *share, const void *identity)
 {
+  PFS_INTERNAL_INC(pfs_internal_open_table_v1);
+
   PFS_table_share *pfs_table_share= reinterpret_cast<PFS_table_share*> (share);
 
   if (unlikely(pfs_table_share == NULL))
@@ -1497,6 +1532,8 @@ pfs_open_table_v1(PSI_table_share *share
 */
 void pfs_close_table_v1(PSI_table *table)
 {
+  PFS_INTERNAL_INC(pfs_internal_close_table_v1);
+
   PFS_table *pfs= reinterpret_cast<PFS_table*> (table);
 
   if (unlikely(pfs == NULL))
@@ -1512,6 +1549,8 @@ void pfs_close_table_v1(PSI_table *table
 */
 void pfs_create_file_v1(PSI_file_key key, const char *name, File file)
 {
+  PFS_INTERNAL_INC(pfs_internal_create_file_v1);
+
   if (! flag_global_instrumentation)
     return;
   int index= (int) file;
@@ -1618,6 +1657,8 @@ int pfs_spawn_thread_v1(PSI_thread_key k
                            pthread_t *thread, const pthread_attr_t *attr,
                            void *(*start_routine)(void*), void *arg)
 {
+  PFS_INTERNAL_INC(pfs_internal_spawn_thread_v1);
+
   PFS_spawn_thread_arg *psi_arg;
 
   /* psi_arg can not be global, and can not be a local variable. */
@@ -1645,6 +1686,8 @@ int pfs_spawn_thread_v1(PSI_thread_key k
 PSI_thread*
 pfs_new_thread_v1(PSI_thread_key key, const void *identity, ulong thread_id)
 {
+  PFS_INTERNAL_INC(pfs_internal_new_thread_v1);
+
   PFS_thread *pfs;
 
   PFS_thread_class *klass= find_thread_class(key);
@@ -1662,6 +1705,8 @@ pfs_new_thread_v1(PSI_thread_key key, co
 */
 void pfs_set_thread_id_v1(PSI_thread *thread, unsigned long id)
 {
+  PFS_INTERNAL_INC(pfs_internal_set_thread_id_v1);
+
   DBUG_ASSERT(thread);
   PFS_thread *pfs= reinterpret_cast<PFS_thread*> (thread);
   pfs->m_thread_id= id;
@@ -1674,6 +1719,8 @@ void pfs_set_thread_id_v1(PSI_thread *th
 PSI_thread*
 pfs_get_thread_v1(void)
 {
+  PFS_INTERNAL_INC(pfs_internal_get_thread_v1);
+
   if (unlikely(! THR_PFS_initialized))
     return NULL;
   PFS_thread *pfs= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
@@ -1686,6 +1733,8 @@ pfs_get_thread_v1(void)
 */
 void pfs_set_thread_user_v1(const char *user, int user_len)
 {
+  PFS_INTERNAL_INC(pfs_internal_set_thread_user_v1);
+
   PFS_thread *pfs= get_pfs_thread();
 
   DBUG_ASSERT((user != NULL) || (user_len == 0));
@@ -1733,6 +1782,8 @@ void pfs_set_thread_user_v1(const char *
 void pfs_set_thread_user_host_v1(const char *user, int user_len,
                                     const char *host, int host_len)
 {
+  PFS_INTERNAL_INC(pfs_internal_set_thread_user_host_v1);
+
   PFS_thread *pfs= get_pfs_thread();
 
   DBUG_ASSERT((user != NULL) || (user_len == 0));
@@ -1783,6 +1834,8 @@ void pfs_set_thread_user_host_v1(const c
 */
 void pfs_set_thread_db_v1(const char* db, int db_len)
 {
+  PFS_INTERNAL_INC(pfs_internal_set_thread_db_v1);
+
   PFS_thread *pfs= get_pfs_thread();
 
   DBUG_ASSERT((db != NULL) || (db_len == 0));
@@ -1805,6 +1858,8 @@ void pfs_set_thread_db_v1(const char* db
 */
 void pfs_set_thread_command_v1(int command)
 {
+  PFS_INTERNAL_INC(pfs_internal_set_thread_command_v1);
+
   PFS_thread *pfs= get_pfs_thread();
 
   DBUG_ASSERT(command >= 0);
@@ -1824,6 +1879,8 @@ void pfs_set_thread_command_v1(int comma
 */
 void pfs_set_thread_start_time_v1(time_t start_time)
 {
+  PFS_INTERNAL_INC(pfs_internal_set_thread_start_time_v1);
+
   PFS_thread *pfs= get_pfs_thread();
 
   if (likely(pfs != NULL))
@@ -1840,6 +1897,8 @@ void pfs_set_thread_start_time_v1(time_t
 */
 void pfs_set_thread_state_v1(const char* state)
 {
+  PFS_INTERNAL_INC(pfs_internal_set_thread_state_v1);
+
   PFS_thread *pfs= get_pfs_thread();
 
   if (likely(pfs != NULL))
@@ -1859,6 +1918,8 @@ void pfs_set_thread_state_v1(const char*
 */
 void pfs_set_thread_info_v1(const char* info, int info_len)
 {
+  PFS_INTERNAL_INC(pfs_internal_set_thread_info_v1);
+
   PFS_thread *pfs= get_pfs_thread();
 
   if (likely(pfs != NULL))
@@ -1876,6 +1937,8 @@ void pfs_set_thread_info_v1(const char*
 */
 void pfs_set_thread_v1(PSI_thread* thread)
 {
+  PFS_INTERNAL_INC(pfs_internal_set_thread_v1);
+
   PFS_thread *pfs= reinterpret_cast<PFS_thread*> (thread);
   if (THR_PFS_initialized)
     my_pthread_setspecific_ptr(THR_PFS, pfs);
@@ -1887,6 +1950,8 @@ void pfs_set_thread_v1(PSI_thread* threa
 */
 void pfs_delete_current_thread_v1(void)
 {
+  PFS_INTERNAL_INC(pfs_internal_delete_current_thread_v1);
+
   PFS_thread *thread= get_pfs_thread();
   if (thread != NULL)
   {
@@ -1903,6 +1968,8 @@ void pfs_delete_current_thread_v1(void)
 */
 void pfs_delete_thread_v1(PSI_thread *thread)
 {
+  PFS_INTERNAL_INC(pfs_internal_delete_thread_v1);
+
   PFS_thread *pfs= reinterpret_cast<PFS_thread*> (thread);
 
   if (pfs != NULL)
@@ -1920,6 +1987,8 @@ PSI_mutex_locker*
 pfs_get_thread_mutex_locker_v1(PSI_mutex_locker_state *state,
                            PSI_mutex *mutex, PSI_mutex_operation op)
 {
+  PFS_INTERNAL_INC(pfs_internal_get_thread_mutex_locker_v1);
+
   DBUG_ASSERT((int) op >= 0);
   DBUG_ASSERT((uint) op < array_elements(mutex_operation_map));
   DBUG_ASSERT(state != NULL);
@@ -2012,6 +2081,8 @@ PSI_rwlock_locker*
 pfs_get_thread_rwlock_locker_v1(PSI_rwlock_locker_state *state,
                             PSI_rwlock *rwlock, PSI_rwlock_operation op)
 {
+  PFS_INTERNAL_INC(pfs_internal_get_thread_rwlock_locker_v1);
+
   DBUG_ASSERT(static_cast<int> (op) >= 0);
   DBUG_ASSERT(static_cast<uint> (op) < array_elements(rwlock_operation_map));
   DBUG_ASSERT(state != NULL);
@@ -2105,6 +2176,8 @@ pfs_get_thread_cond_locker_v1(PSI_cond_l
                           PSI_cond *cond, PSI_mutex *mutex,
                           PSI_cond_operation op)
 {
+  PFS_INTERNAL_INC(pfs_internal_get_thread_cond_locker_v1);
+
   /*
     Note about the unused PSI_mutex *mutex parameter:
     In the pthread library, a call to pthread_cond_wait()
@@ -2255,6 +2328,8 @@ PSI_table_locker*
 pfs_get_thread_table_io_locker_v1(PSI_table_locker_state *state,
                               PSI_table *table, PSI_table_io_operation op, uint index)
 {
+  PFS_INTERNAL_INC(pfs_internal_get_thread_table_io_locker_v1);
+
   DBUG_ASSERT(static_cast<int> (op) >= 0);
   DBUG_ASSERT(static_cast<uint> (op) < array_elements(table_io_operation_map));
   DBUG_ASSERT(state != NULL);
@@ -2348,6 +2423,8 @@ PSI_table_locker*
 pfs_get_thread_table_lock_locker_v1(PSI_table_locker_state *state,
                                 PSI_table *table, PSI_table_lock_operation op, ulong op_flags)
 {
+  PFS_INTERNAL_INC(pfs_internal_get_thread_table_lock_locker_v1);
+
   DBUG_ASSERT(state != NULL);
   DBUG_ASSERT((op == PSI_TABLE_LOCK) || (op == PSI_TABLE_EXTERNAL_LOCK));
 
@@ -2463,6 +2540,8 @@ pfs_get_thread_file_name_locker_v1(PSI_f
                                PSI_file_operation op,
                                const char *name, const void *identity)
 {
+  PFS_INTERNAL_INC(pfs_internal_get_thread_file_name_locker_v1);
+
   DBUG_ASSERT(static_cast<int> (op) >= 0);
   DBUG_ASSERT(static_cast<uint> (op) < array_elements(file_operation_map));
   DBUG_ASSERT(state != NULL);
@@ -2540,6 +2619,8 @@ PSI_file_locker*
 pfs_get_thread_file_stream_locker_v1(PSI_file_locker_state *state,
                                  PSI_file *file, PSI_file_operation op)
 {
+  PFS_INTERNAL_INC(pfs_internal_get_thread_file_stream_locker_v1);
+
   DBUG_ASSERT(static_cast<int> (op) >= 0);
   DBUG_ASSERT(static_cast<uint> (op) < array_elements(file_operation_map));
   DBUG_ASSERT(state != NULL);
@@ -2630,6 +2711,8 @@ PSI_file_locker*
 pfs_get_thread_file_descriptor_locker_v1(PSI_file_locker_state *state,
                                      File file, PSI_file_operation op)
 {
+  PFS_INTERNAL_INC(pfs_internal_get_thread_file_descriptor_locker_v1);
+
   int index= static_cast<int> (file);
   DBUG_ASSERT(static_cast<int> (op) >= 0);
   DBUG_ASSERT(static_cast<uint> (op) < array_elements(file_operation_map));
@@ -2732,6 +2815,8 @@ pfs_get_thread_file_descriptor_locker_v1
 */
 void pfs_unlock_mutex_v1(PSI_mutex *mutex)
 {
+  PFS_INTERNAL_INC(pfs_internal_unlock_mutex_v1);
+
   PFS_mutex *pfs_mutex= reinterpret_cast<PFS_mutex*> (mutex);
 
   if (unlikely(pfs_mutex == NULL))
@@ -2777,6 +2862,8 @@ void pfs_unlock_mutex_v1(PSI_mutex *mute
 */
 void pfs_unlock_rwlock_v1(PSI_rwlock *rwlock)
 {
+  PFS_INTERNAL_INC(pfs_internal_unlock_rwlock_v1);
+
   PFS_rwlock *pfs_rwlock= reinterpret_cast<PFS_rwlock*> (rwlock);
 
   if (unlikely(pfs_rwlock == NULL))
@@ -2860,6 +2947,8 @@ void pfs_unlock_rwlock_v1(PSI_rwlock *rw
 */
 void pfs_signal_cond_v1(PSI_cond* cond)
 {
+  PFS_INTERNAL_INC(pfs_internal_signal_cond_v1);
+
   PFS_cond *pfs_cond= reinterpret_cast<PFS_cond*> (cond);
 
   if (unlikely(pfs_cond == NULL))
@@ -2874,6 +2963,8 @@ void pfs_signal_cond_v1(PSI_cond* cond)
 */
 void pfs_broadcast_cond_v1(PSI_cond* cond)
 {
+  PFS_INTERNAL_INC(pfs_internal_broadcast_cond_v1);
+
   PFS_cond *pfs_cond= reinterpret_cast<PFS_cond*> (cond);
 
   if (unlikely(pfs_cond == NULL))
@@ -2889,6 +2980,8 @@ void pfs_broadcast_cond_v1(PSI_cond* con
 void pfs_start_mutex_wait_v1(PSI_mutex_locker* locker,
                                 const char *src_file, uint src_line)
 {
+  PFS_INTERNAL_INC(pfs_internal_start_mutex_wait_v1);
+
   PSI_mutex_locker_state *state= reinterpret_cast<PSI_mutex_locker_state*> (locker);
   DBUG_ASSERT(state != NULL);
 
@@ -2918,6 +3011,8 @@ void pfs_start_mutex_wait_v1(PSI_mutex_l
 */
 void pfs_end_mutex_wait_v1(PSI_mutex_locker* locker, int rc)
 {
+  PFS_INTERNAL_INC(pfs_internal_end_mutex_wait_v1);
+
   PSI_mutex_locker_state *state= reinterpret_cast<PSI_mutex_locker_state*> (locker);
   DBUG_ASSERT(state != NULL);
   ulonglong timer_end= 0;
@@ -2987,6 +3082,8 @@ void pfs_end_mutex_wait_v1(PSI_mutex_loc
 void pfs_start_rwlock_rdwait_v1(PSI_rwlock_locker* locker,
                                    const char *src_file, uint src_line)
 {
+  PFS_INTERNAL_INC(pfs_internal_start_rwlock_rdwait_v1);
+
   ulonglong timer_start= 0;
   PSI_rwlock_locker_state *state= reinterpret_cast<PSI_rwlock_locker_state*> (locker);
   DBUG_ASSERT(state != NULL);
@@ -3014,6 +3111,8 @@ void pfs_start_rwlock_rdwait_v1(PSI_rwlo
 */
 void pfs_end_rwlock_rdwait_v1(PSI_rwlock_locker* locker, int rc)
 {
+  PFS_INTERNAL_INC(pfs_internal_end_rwlock_rdwait_v1);
+
   PSI_rwlock_locker_state *state= reinterpret_cast<PSI_rwlock_locker_state*> (locker);
   DBUG_ASSERT(state != NULL);
   ulonglong timer_end= 0;
@@ -3091,6 +3190,8 @@ void pfs_end_rwlock_rdwait_v1(PSI_rwlock
 void pfs_start_rwlock_wrwait_v1(PSI_rwlock_locker* locker,
                                    const char *src_file, uint src_line)
 {
+  PFS_INTERNAL_INC(pfs_internal_start_rwlock_wrwait_v1);
+
   ulonglong timer_start= 0;
   PSI_rwlock_locker_state *state= reinterpret_cast<PSI_rwlock_locker_state*> (locker);
   DBUG_ASSERT(state != NULL);
@@ -3118,6 +3219,8 @@ void pfs_start_rwlock_wrwait_v1(PSI_rwlo
 */
 void pfs_end_rwlock_wrwait_v1(PSI_rwlock_locker* locker, int rc)
 {
+  PFS_INTERNAL_INC(pfs_internal_end_rwlock_wrwait_v1);
+
   PSI_rwlock_locker_state *state= reinterpret_cast<PSI_rwlock_locker_state*> (locker);
   DBUG_ASSERT(state != NULL);
   ulonglong timer_end= 0;
@@ -3188,6 +3291,8 @@ void pfs_end_rwlock_wrwait_v1(PSI_rwlock
 void pfs_start_cond_wait_v1(PSI_cond_locker* locker,
                                const char *src_file, uint src_line)
 {
+  PFS_INTERNAL_INC(pfs_internal_start_cond_wait_v1);
+
   ulonglong timer_start= 0;
   PSI_cond_locker_state *state= reinterpret_cast<PSI_cond_locker_state*> (locker);
   DBUG_ASSERT(state != NULL);
@@ -3215,6 +3320,8 @@ void pfs_start_cond_wait_v1(PSI_cond_loc
 */
 void pfs_end_cond_wait_v1(PSI_cond_locker* locker, int rc)
 {
+  PFS_INTERNAL_INC(pfs_internal_end_cond_wait_v1);
+
   PSI_cond_locker_state *state= reinterpret_cast<PSI_cond_locker_state*> (locker);
   DBUG_ASSERT(state != NULL);
   ulonglong timer_end= 0;
@@ -3278,6 +3385,8 @@ void pfs_end_cond_wait_v1(PSI_cond_locke
 void pfs_start_table_io_wait_v1(PSI_table_locker* locker,
                                    const char *src_file, uint src_line)
 {
+  PFS_INTERNAL_INC(pfs_internal_start_table_io_wait_v1);
+
   ulonglong timer_start= 0;
   PSI_table_locker_state *state= reinterpret_cast<PSI_table_locker_state*> (locker);
   DBUG_ASSERT(state != NULL);
@@ -3307,6 +3416,8 @@ void pfs_start_table_io_wait_v1(PSI_tabl
 */
 void pfs_end_table_io_wait_v1(PSI_table_locker* locker)
 {
+  PFS_INTERNAL_INC(pfs_internal_end_table_io_wait_v1);
+
   PSI_table_locker_state *state= reinterpret_cast<PSI_table_locker_state*> (locker);
   DBUG_ASSERT(state != NULL);
   ulonglong timer_end= 0;
@@ -3378,6 +3489,8 @@ void pfs_end_table_io_wait_v1(PSI_table_
 void pfs_start_table_lock_wait_v1(PSI_table_locker* locker,
                                      const char *src_file, uint src_line)
 {
+  PFS_INTERNAL_INC(pfs_internal_start_table_lock_wait_v1);
+
   ulonglong timer_start= 0;
   PSI_table_locker_state *state= reinterpret_cast<PSI_table_locker_state*> (locker);
   DBUG_ASSERT(state != NULL);
@@ -3407,6 +3520,8 @@ void pfs_start_table_lock_wait_v1(PSI_ta
 */
 void pfs_end_table_lock_wait_v1(PSI_table_locker* locker)
 {
+  PFS_INTERNAL_INC(pfs_internal_end_table_lock_wait_v1);
+
   PSI_table_locker_state *state= reinterpret_cast<PSI_table_locker_state*> (locker);
   DBUG_ASSERT(state != NULL);
   ulonglong timer_end= 0;
@@ -3464,6 +3579,8 @@ PSI_file* pfs_start_file_open_wait_v1(PS
                                          const char *src_file,
                                          uint src_line)
 {
+  PFS_INTERNAL_INC(pfs_internal_start_file_open_wait_v1);
+
   PSI_file_locker_state *state= reinterpret_cast<PSI_file_locker_state*> (locker);
   DBUG_ASSERT(state != NULL);
 
@@ -3478,6 +3595,8 @@ PSI_file* pfs_start_file_open_wait_v1(PS
 */
 void pfs_end_file_open_wait_v1(PSI_file_locker *locker)
 {
+  PFS_INTERNAL_INC(pfs_internal_end_file_open_wait_v1);
+
   pfs_end_file_wait_v1(locker, 0);
 }
 
@@ -3488,6 +3607,8 @@ void pfs_end_file_open_wait_v1(PSI_file_
 void pfs_end_file_open_wait_and_bind_to_descriptor_v1
   (PSI_file_locker *locker, File file)
 {
+  PFS_INTERNAL_INC(pfs_internal_end_file_open_wait_and_bind_to_descriptor_v1);
+
   int index= (int) file;
   PSI_file_locker_state *state= reinterpret_cast<PSI_file_locker_state*> (locker);
   DBUG_ASSERT(state != NULL);
@@ -3519,6 +3640,8 @@ void pfs_start_file_wait_v1(PSI_file_loc
                                const char *src_file,
                                uint src_line)
 {
+  PFS_INTERNAL_INC(pfs_internal_start_file_wait_v1);
+
   ulonglong timer_start= 0;
   PSI_file_locker_state *state= reinterpret_cast<PSI_file_locker_state*> (locker);
   DBUG_ASSERT(state != NULL);
@@ -3550,6 +3673,8 @@ void pfs_start_file_wait_v1(PSI_file_loc
 void pfs_end_file_wait_v1(PSI_file_locker *locker,
                              size_t count)
 {
+  PFS_INTERNAL_INC(pfs_internal_end_file_wait_v1);
+
   PSI_file_locker_state *state= reinterpret_cast<PSI_file_locker_state*> (locker);
   DBUG_ASSERT(state != NULL);
   ulonglong timer_end= 0;
@@ -3634,6 +3759,8 @@ void pfs_end_file_wait_v1(PSI_file_locke
 
 void pfs_start_stage_v1(PSI_stage_key key, const char *src_file, int src_line)
 {
+  PFS_INTERNAL_INC(pfs_internal_start_stage_v1);
+
   ulonglong timer_value= 0;
 
   if (! flag_global_instrumentation)
@@ -3727,6 +3854,8 @@ void pfs_start_stage_v1(PSI_stage_key ke
 
 void pfs_end_stage_v1()
 {
+  PFS_INTERNAL_INC(pfs_internal_end_stage_v1);
+
   ulonglong timer_value= 0;
 
   if (! flag_global_instrumentation)
@@ -3787,6 +3916,8 @@ PSI_statement_locker*
 pfs_get_thread_statement_locker_v1(PSI_statement_locker_state *state,
                                PSI_statement_key key)
 {
+  PFS_INTERNAL_INC(pfs_internal_get_thread_statement_locker_v1);
+
   DBUG_ASSERT(state != NULL);
   if (! flag_global_instrumentation)
     return NULL;
@@ -3906,6 +4037,8 @@ PSI_statement_locker*
 pfs_refine_statement_v1(PSI_statement_locker *locker,
                     PSI_statement_key key)
 {
+  PFS_INTERNAL_INC(pfs_internal_refine_statement_v1);
+
   PSI_statement_locker_state *state= reinterpret_cast<PSI_statement_locker_state*> (locker);
 
   if (unlikely(state == NULL))
@@ -3953,6 +4086,8 @@ void pfs_start_statement_v1(PSI_statemen
                                const char *db, uint db_len,
                                const char *src_file, uint src_line)
 {
+  PFS_INTERNAL_INC(pfs_internal_start_statement_v1);
+
   PSI_statement_locker_state *state= reinterpret_cast<PSI_statement_locker_state*> (locker);
 
   if (unlikely(state == NULL))
@@ -3986,6 +4121,8 @@ void pfs_start_statement_v1(PSI_statemen
 void pfs_set_statement_text_v1(PSI_statement_locker *locker,
                                   const char *text, uint text_len)
 {
+  PFS_INTERNAL_INC(pfs_internal_set_statement_text_v1);
+
   PSI_statement_locker_state *state= reinterpret_cast<PSI_statement_locker_state*> (locker);
 
   if (unlikely(state == NULL))
@@ -4045,99 +4182,133 @@ void pfs_set_statement_text_v1(PSI_state
 void pfs_set_statement_lock_time_v1(PSI_statement_locker *locker,
                                        ulonglong count)
 {
+  PFS_INTERNAL_INC(pfs_internal_set_statement_lock_time_v1);
+
   SET_STATEMENT_ATTR_BODY(locker, m_lock_time, count);
 }
 
 void pfs_set_statement_rows_sent_v1(PSI_statement_locker *locker,
                                        ulonglong count)
 {
+  PFS_INTERNAL_INC(pfs_internal_set_statement_rows_sent_v1);
+
   SET_STATEMENT_ATTR_BODY(locker, m_rows_sent, count);
 }
 
 void pfs_set_statement_rows_examined_v1(PSI_statement_locker *locker,
                                            ulonglong count)
 {
+  PFS_INTERNAL_INC(pfs_internal_set_statement_rows_examined_v1);
+
   SET_STATEMENT_ATTR_BODY(locker, m_rows_examined, count);
 }
 
 void pfs_inc_statement_created_tmp_disk_tables_v1(PSI_statement_locker *locker,
                                                     ulonglong count)
 {
+  PFS_INTERNAL_INC(pfs_internal_inc_statement_created_tmp_disk_tables_v1);
+
   INC_STATEMENT_ATTR_BODY(locker, m_created_tmp_disk_tables, count);
 }
 
 void pfs_inc_statement_created_tmp_tables_v1(PSI_statement_locker *locker,
                                                 ulonglong count)
 {
+  PFS_INTERNAL_INC(pfs_internal_inc_statement_created_tmp_tables_v1);
+
   INC_STATEMENT_ATTR_BODY(locker, m_created_tmp_tables, count);
 }
 
 void pfs_inc_statement_select_full_join_v1(PSI_statement_locker *locker,
                                               ulonglong count)
 {
+  PFS_INTERNAL_INC(pfs_internal_inc_statement_select_full_join_v1);
+
   INC_STATEMENT_ATTR_BODY(locker, m_select_full_join, count);
 }
 
 void pfs_inc_statement_select_full_range_join_v1(PSI_statement_locker *locker,
                                                     ulonglong count)
 {
+  PFS_INTERNAL_INC(pfs_internal_inc_statement_select_full_range_join_v1);
+
   INC_STATEMENT_ATTR_BODY(locker, m_select_full_range_join, count);
 }
 
 void pfs_inc_statement_select_range_v1(PSI_statement_locker *locker,
                                           ulonglong count)
 {
+  PFS_INTERNAL_INC(pfs_internal_inc_statement_select_range_v1);
+
   INC_STATEMENT_ATTR_BODY(locker, m_select_range, count);
 }
 
 void pfs_inc_statement_select_range_check_v1(PSI_statement_locker *locker,
                                                 ulonglong count)
 {
+  PFS_INTERNAL_INC(pfs_internal_inc_statement_select_range_check_v1);
+
   INC_STATEMENT_ATTR_BODY(locker, m_select_range_check, count);
 }
 
 void pfs_inc_statement_select_scan_v1(PSI_statement_locker *locker,
                                          ulonglong count)
 {
+  PFS_INTERNAL_INC(pfs_internal_inc_statement_select_scan_v1);
+
   INC_STATEMENT_ATTR_BODY(locker, m_select_scan, count);
 }
 
 void pfs_inc_statement_sort_merge_passes_v1(PSI_statement_locker *locker,
                                                ulonglong count)
 {
+  PFS_INTERNAL_INC(pfs_internal_inc_statement_sort_merge_passes_v1);
+
   INC_STATEMENT_ATTR_BODY(locker, m_sort_merge_passes, count);
 }
 
 void pfs_inc_statement_sort_range_v1(PSI_statement_locker *locker,
                                         ulonglong count)
 {
+  PFS_INTERNAL_INC(pfs_internal_inc_statement_sort_range_v1);
+
   INC_STATEMENT_ATTR_BODY(locker, m_sort_range, count);
 }
 
 void pfs_inc_statement_sort_rows_v1(PSI_statement_locker *locker,
                                        ulonglong count)
 {
+  PFS_INTERNAL_INC(pfs_internal_inc_statement_sort_rows_v1);
+
   INC_STATEMENT_ATTR_BODY(locker, m_sort_rows, count);
 }
 
 void pfs_inc_statement_sort_scan_v1(PSI_statement_locker *locker,
                                        ulonglong count)
 {
+  PFS_INTERNAL_INC(pfs_internal_inc_statement_sort_scan_v1);
+
   INC_STATEMENT_ATTR_BODY(locker, m_sort_scan, count);
 }
 
 void pfs_set_statement_no_index_used_v1(PSI_statement_locker *locker)
 {
+  PFS_INTERNAL_INC(pfs_internal_set_statement_no_index_used_v1);
+
   SET_STATEMENT_ATTR_BODY(locker, m_no_index_used, 1);
 }
 
 void pfs_set_statement_no_good_index_used_v1(PSI_statement_locker *locker)
 {
+  PFS_INTERNAL_INC(pfs_internal_set_statement_no_good_index_used_v1);
+
   SET_STATEMENT_ATTR_BODY(locker, m_no_good_index_used, 1);
 }
 
 void pfs_end_statement_v1(PSI_statement_locker *locker, void *stmt_da)
 {
+  PFS_INTERNAL_INC(pfs_internal_end_statement_v1);
+
   PSI_statement_locker_state *state= reinterpret_cast<PSI_statement_locker_state*> (locker);
 
   if (unlikely(state == NULL))

=== modified file 'storage/perfschema/pfs_instr.cc'
--- a/storage/perfschema/pfs_instr.cc	2011-02-15 14:31:13 +0000
+++ b/storage/perfschema/pfs_instr.cc	2011-05-26 09:05:41 +0000
@@ -27,6 +27,7 @@
 #include "pfs_instr.h"
 #include "pfs_global.h"
 #include "pfs_instr_class.h"
+#include "pfs_internal_stat.h"
 
 /**
   @addtogroup Performance_schema_buffers
@@ -562,8 +563,11 @@ void PFS_scan::init(uint random, uint ma
   @param identity                     the mutex address
   @return a mutex instance, or NULL
 */
+#ifdef NEVER
 PFS_mutex* create_mutex(PFS_mutex_class *klass, const void *identity)
 {
+  PFS_INTERNAL_INC(pfs_internal_create_mutex);
+
   PFS_scan scan;
   uint random= randomized_index(identity, mutex_max);
 
@@ -575,6 +579,8 @@ PFS_mutex* create_mutex(PFS_mutex_class
     PFS_mutex *pfs_last= mutex_array + scan.last();
     for ( ; pfs < pfs_last; pfs++)
     {
+      PFS_INTERNAL_INC(pfs_internal_create_mutex_scan);
+
       if (pfs->m_lock.is_free())
       {
         if (pfs->m_lock.free_to_dirty())
@@ -597,6 +603,45 @@ PFS_mutex* create_mutex(PFS_mutex_class
   mutex_lost++;
   return NULL;
 }
+#endif
+
+PFS_mutex* create_mutex(PFS_mutex_class *klass, const void *identity)
+{
+  PFS_INTERNAL_INC(pfs_internal_create_mutex);
+
+  static uint monotonic_index= 0;
+  uint index;
+  uint attempts= 0;
+
+  while (++attempts <= mutex_max)
+  {
+    PFS_INTERNAL_INC(pfs_internal_create_mutex_scan);
+
+    PFS_atomic::add_u32(& monotonic_index, 1);
+    index= monotonic_index % mutex_max;
+    PFS_mutex *pfs= mutex_array + index;
+
+    if (pfs->m_lock.is_free())
+    {
+      if (pfs->m_lock.free_to_dirty())
+      {
+        pfs->m_identity= identity;
+        pfs->m_class= klass;
+        pfs->m_wait_stat.reset();
+        pfs->m_lock_stat.reset();
+        pfs->m_owner= NULL;
+        pfs->m_last_locked= 0;
+        pfs->m_lock.dirty_to_allocated();
+        if (klass->is_singleton())
+          klass->m_singleton= pfs;
+        return pfs;
+      }
+    }
+  }
+
+  mutex_lost++;
+  return NULL;
+}
 
 /**
   Destroy instrumentation for a mutex instance.
@@ -621,8 +666,11 @@ void destroy_mutex(PFS_mutex *pfs)
   @param identity                     the rwlock address
   @return a rwlock instance, or NULL
 */
+#ifdef NEVER
 PFS_rwlock* create_rwlock(PFS_rwlock_class *klass, const void *identity)
 {
+  PFS_INTERNAL_INC(pfs_internal_create_rwlock);
+
   PFS_scan scan;
   uint random= randomized_index(identity, rwlock_max);
 
@@ -634,6 +682,8 @@ PFS_rwlock* create_rwlock(PFS_rwlock_cla
     PFS_rwlock *pfs_last= rwlock_array + scan.last();
     for ( ; pfs < pfs_last; pfs++)
     {
+      PFS_INTERNAL_INC(pfs_internal_create_rwlock_scan);
+
       if (pfs->m_lock.is_free())
       {
         if (pfs->m_lock.free_to_dirty())
@@ -659,7 +709,48 @@ PFS_rwlock* create_rwlock(PFS_rwlock_cla
   rwlock_lost++;
   return NULL;
 }
+#endif
 
+PFS_rwlock* create_rwlock(PFS_rwlock_class *klass, const void *identity)
+{
+  PFS_INTERNAL_INC(pfs_internal_create_rwlock);
+
+  static uint monotonic_index= 0;
+  uint index;
+  uint attempts= 0;
+
+  while (++attempts <= rwlock_max)
+  {
+    PFS_INTERNAL_INC(pfs_internal_create_rwlock_scan);
+
+    PFS_atomic::add_u32(& monotonic_index, 1);
+    index= monotonic_index % rwlock_max;
+    PFS_rwlock *pfs= rwlock_array + index;
+
+    if (pfs->m_lock.is_free())
+    {
+      if (pfs->m_lock.free_to_dirty())
+      {
+        pfs->m_identity= identity;
+        pfs->m_class= klass;
+        pfs->m_wait_stat.reset();
+        pfs->m_lock.dirty_to_allocated();
+        pfs->m_read_lock_stat.reset();
+        pfs->m_write_lock_stat.reset();
+        pfs->m_writer= NULL;
+        pfs->m_readers= 0;
+        pfs->m_last_written= 0;
+        pfs->m_last_read= 0;
+        if (klass->is_singleton())
+          klass->m_singleton= pfs;
+        return pfs;
+      }
+    }
+  }
+
+  rwlock_lost++;
+  return NULL;
+}
 /**
   Destroy instrumentation for a rwlock instance.
   @param pfs                          the rwlock to destroy
@@ -685,6 +776,8 @@ void destroy_rwlock(PFS_rwlock *pfs)
 */
 PFS_cond* create_cond(PFS_cond_class *klass, const void *identity)
 {
+  PFS_INTERNAL_INC(pfs_internal_create_cond);
+
   PFS_scan scan;
   uint random= randomized_index(identity, cond_max);
 
@@ -696,6 +789,8 @@ PFS_cond* create_cond(PFS_cond_class *kl
     PFS_cond *pfs_last= cond_array + scan.last();
     for ( ; pfs < pfs_last; pfs++)
     {
+      PFS_INTERNAL_INC(pfs_internal_create_cond_scan);
+
       if (pfs->m_lock.is_free())
       {
         if (pfs->m_lock.free_to_dirty())
@@ -753,6 +848,8 @@ PFS_thread* PFS_thread::get_current_thre
 PFS_thread* create_thread(PFS_thread_class *klass, const void *identity,
                           ulong thread_id)
 {
+  PFS_INTERNAL_INC(pfs_internal_create_thread);
+
   PFS_scan scan;
   uint index;
   uint random= randomized_index(identity, thread_max);
@@ -765,6 +862,8 @@ PFS_thread* create_thread(PFS_thread_cla
     PFS_thread *pfs_last= thread_array + scan.last();
     for ( ; pfs < pfs_last; pfs++)
     {
+      PFS_INTERNAL_INC(pfs_internal_create_thread_scan);
+
       if (pfs->m_lock.is_free())
       {
         if (pfs->m_lock.free_to_dirty())
@@ -1190,6 +1289,8 @@ void destroy_file(PFS_thread *thread, PF
 PFS_table* create_table(PFS_table_share *share, PFS_thread *opening_thread,
                         const void *identity)
 {
+  PFS_INTERNAL_INC(pfs_internal_create_table);
+
   PFS_scan scan;
   uint random= randomized_index(identity, table_max);
 
@@ -1201,6 +1302,8 @@ PFS_table* create_table(PFS_table_share
     PFS_table *pfs_last= table_array + scan.last();
     for ( ; pfs < pfs_last; pfs++)
     {
+      PFS_INTERNAL_INC(pfs_internal_create_table_scan);
+
       if (pfs->m_lock.is_free())
       {
         if (pfs->m_lock.free_to_dirty())

=== added file 'storage/perfschema/pfs_internal_stat.cc'
--- a/storage/perfschema/pfs_internal_stat.cc	1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/pfs_internal_stat.cc	2011-05-26 09:05:41 +0000
@@ -0,0 +1,118 @@
+/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; version 2 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software Foundation,
+  51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#include "my_global.h"
+#include "pfs_internal_stat.h"
+
+#ifdef HAVE_INTERNAL_STAT
+
+ulong pfs_internal_register_mutex_v1= 0;
+ulong pfs_internal_register_rwlock_v1= 0;
+ulong pfs_internal_register_cond_v1= 0;
+ulong pfs_internal_register_thread_v1= 0;
+ulong pfs_internal_register_file_v1= 0;
+ulong pfs_internal_register_stage_v1= 0;
+ulong pfs_internal_register_statement_v1= 0;
+ulong pfs_internal_init_mutex_v1= 0;
+ulong pfs_internal_destroy_mutex_v1= 0;
+ulong pfs_internal_init_rwlock_v1= 0;
+ulong pfs_internal_destroy_rwlock_v1= 0;
+ulong pfs_internal_init_cond_v1= 0;
+ulong pfs_internal_destroy_cond_v1= 0;
+ulong pfs_internal_get_table_share_v1= 0;
+ulong pfs_internal_release_table_share_v1= 0;
+ulong pfs_internal_drop_table_share_v1= 0;
+ulong pfs_internal_open_table_v1= 0;
+ulong pfs_internal_close_table_v1= 0;
+ulong pfs_internal_create_file_v1= 0;
+ulong pfs_internal_spawn_thread_v1= 0;
+ulong pfs_internal_new_thread_v1= 0;
+ulong pfs_internal_set_thread_id_v1= 0;
+ulong pfs_internal_get_thread_v1= 0;
+ulong pfs_internal_set_thread_user_v1= 0;
+ulong pfs_internal_set_thread_user_host_v1= 0;
+ulong pfs_internal_set_thread_db_v1= 0;
+ulong pfs_internal_set_thread_command_v1= 0;
+ulong pfs_internal_set_thread_start_time_v1= 0;
+ulong pfs_internal_set_thread_state_v1= 0;
+ulong pfs_internal_set_thread_info_v1= 0;
+ulong pfs_internal_set_thread_v1= 0;
+ulong pfs_internal_delete_current_thread_v1= 0;
+ulong pfs_internal_delete_thread_v1= 0;
+ulong pfs_internal_get_thread_mutex_locker_v1= 0;
+ulong pfs_internal_get_thread_rwlock_locker_v1= 0;
+ulong pfs_internal_get_thread_cond_locker_v1= 0;
+ulong pfs_internal_get_thread_table_io_locker_v1= 0;
+ulong pfs_internal_get_thread_table_lock_locker_v1= 0;
+ulong pfs_internal_get_thread_file_name_locker_v1= 0;
+ulong pfs_internal_get_thread_file_stream_locker_v1= 0;
+ulong pfs_internal_get_thread_file_descriptor_locker_v1= 0;
+ulong pfs_internal_unlock_mutex_v1= 0;
+ulong pfs_internal_unlock_rwlock_v1= 0;
+ulong pfs_internal_signal_cond_v1= 0;
+ulong pfs_internal_broadcast_cond_v1= 0;
+ulong pfs_internal_start_mutex_wait_v1= 0;
+ulong pfs_internal_end_mutex_wait_v1= 0;
+ulong pfs_internal_start_rwlock_rdwait_v1= 0;
+ulong pfs_internal_end_rwlock_rdwait_v1= 0;
+ulong pfs_internal_start_rwlock_wrwait_v1= 0;
+ulong pfs_internal_end_rwlock_wrwait_v1= 0;
+ulong pfs_internal_start_cond_wait_v1= 0;
+ulong pfs_internal_end_cond_wait_v1= 0;
+ulong pfs_internal_start_table_io_wait_v1= 0;
+ulong pfs_internal_end_table_io_wait_v1= 0;
+ulong pfs_internal_start_table_lock_wait_v1= 0;
+ulong pfs_internal_end_table_lock_wait_v1= 0;
+ulong pfs_internal_start_file_open_wait_v1= 0;
+ulong pfs_internal_end_file_open_wait_v1= 0;
+ulong pfs_internal_end_file_open_wait_and_bind_to_descriptor_v1= 0;
+ulong pfs_internal_start_file_wait_v1= 0;
+ulong pfs_internal_end_file_wait_v1= 0;
+ulong pfs_internal_start_stage_v1= 0;
+ulong pfs_internal_end_stage_v1= 0;
+ulong pfs_internal_get_thread_statement_locker_v1= 0;
+ulong pfs_internal_refine_statement_v1= 0;
+ulong pfs_internal_start_statement_v1= 0;
+ulong pfs_internal_set_statement_text_v1= 0;
+ulong pfs_internal_set_statement_lock_time_v1= 0;
+ulong pfs_internal_set_statement_rows_sent_v1= 0;
+ulong pfs_internal_set_statement_rows_examined_v1= 0;
+ulong pfs_internal_inc_statement_created_tmp_disk_tables_v1= 0;
+ulong pfs_internal_inc_statement_created_tmp_tables_v1= 0;
+ulong pfs_internal_inc_statement_select_full_join_v1= 0;
+ulong pfs_internal_inc_statement_select_full_range_join_v1= 0;
+ulong pfs_internal_inc_statement_select_range_v1= 0;
+ulong pfs_internal_inc_statement_select_range_check_v1= 0;
+ulong pfs_internal_inc_statement_select_scan_v1= 0;
+ulong pfs_internal_inc_statement_sort_merge_passes_v1= 0;
+ulong pfs_internal_inc_statement_sort_range_v1= 0;
+ulong pfs_internal_inc_statement_sort_rows_v1= 0;
+ulong pfs_internal_inc_statement_sort_scan_v1= 0;
+ulong pfs_internal_set_statement_no_index_used_v1= 0;
+ulong pfs_internal_set_statement_no_good_index_used_v1= 0;
+ulong pfs_internal_end_statement_v1= 0;
+
+ulong pfs_internal_create_mutex= 0;
+ulong pfs_internal_create_mutex_scan= 0;
+ulong pfs_internal_create_rwlock= 0;
+ulong pfs_internal_create_rwlock_scan= 0;
+ulong pfs_internal_create_cond= 0;
+ulong pfs_internal_create_cond_scan= 0;
+ulong pfs_internal_create_thread= 0;
+ulong pfs_internal_create_thread_scan= 0;
+ulong pfs_internal_create_table= 0;
+ulong pfs_internal_create_table_scan= 0;
+
+#endif

=== added file 'storage/perfschema/pfs_internal_stat.h'
--- a/storage/perfschema/pfs_internal_stat.h	1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/pfs_internal_stat.h	2011-05-26 09:05:41 +0000
@@ -0,0 +1,126 @@
+/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; version 2 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software Foundation,
+  51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#ifndef PFS_INTERNAL_STAT_H
+#define PFS_INTERNAL_STAT_H
+
+/* No cmake option yet */
+#define HAVE_INTERNAL_STAT
+
+#ifdef HAVE_INTERNAL_STAT
+extern ulong pfs_internal_register_mutex_v1;
+extern ulong pfs_internal_register_rwlock_v1;
+extern ulong pfs_internal_register_cond_v1;
+extern ulong pfs_internal_register_thread_v1;
+extern ulong pfs_internal_register_file_v1;
+extern ulong pfs_internal_register_stage_v1;
+extern ulong pfs_internal_register_statement_v1;
+extern ulong pfs_internal_init_mutex_v1;
+extern ulong pfs_internal_destroy_mutex_v1;
+extern ulong pfs_internal_init_rwlock_v1;
+extern ulong pfs_internal_destroy_rwlock_v1;
+extern ulong pfs_internal_init_cond_v1;
+extern ulong pfs_internal_destroy_cond_v1;
+extern ulong pfs_internal_get_table_share_v1;
+extern ulong pfs_internal_release_table_share_v1;
+extern ulong pfs_internal_drop_table_share_v1;
+extern ulong pfs_internal_open_table_v1;
+extern ulong pfs_internal_close_table_v1;
+extern ulong pfs_internal_create_file_v1;
+extern ulong pfs_internal_spawn_thread_v1;
+extern ulong pfs_internal_new_thread_v1;
+extern ulong pfs_internal_set_thread_id_v1;
+extern ulong pfs_internal_get_thread_v1;
+extern ulong pfs_internal_set_thread_user_v1;
+extern ulong pfs_internal_set_thread_user_host_v1;
+extern ulong pfs_internal_set_thread_db_v1;
+extern ulong pfs_internal_set_thread_command_v1;
+extern ulong pfs_internal_set_thread_start_time_v1;
+extern ulong pfs_internal_set_thread_state_v1;
+extern ulong pfs_internal_set_thread_info_v1;
+extern ulong pfs_internal_set_thread_v1;
+extern ulong pfs_internal_delete_current_thread_v1;
+extern ulong pfs_internal_delete_thread_v1;
+extern ulong pfs_internal_get_thread_mutex_locker_v1;
+extern ulong pfs_internal_get_thread_rwlock_locker_v1;
+extern ulong pfs_internal_get_thread_cond_locker_v1;
+extern ulong pfs_internal_get_thread_table_io_locker_v1;
+extern ulong pfs_internal_get_thread_table_lock_locker_v1;
+extern ulong pfs_internal_get_thread_file_name_locker_v1;
+extern ulong pfs_internal_get_thread_file_stream_locker_v1;
+extern ulong pfs_internal_get_thread_file_descriptor_locker_v1;
+extern ulong pfs_internal_unlock_mutex_v1;
+extern ulong pfs_internal_unlock_rwlock_v1;
+extern ulong pfs_internal_signal_cond_v1;
+extern ulong pfs_internal_broadcast_cond_v1;
+extern ulong pfs_internal_start_mutex_wait_v1;
+extern ulong pfs_internal_end_mutex_wait_v1;
+extern ulong pfs_internal_start_rwlock_rdwait_v1;
+extern ulong pfs_internal_end_rwlock_rdwait_v1;
+extern ulong pfs_internal_start_rwlock_wrwait_v1;
+extern ulong pfs_internal_end_rwlock_wrwait_v1;
+extern ulong pfs_internal_start_cond_wait_v1;
+extern ulong pfs_internal_end_cond_wait_v1;
+extern ulong pfs_internal_start_table_io_wait_v1;
+extern ulong pfs_internal_end_table_io_wait_v1;
+extern ulong pfs_internal_start_table_lock_wait_v1;
+extern ulong pfs_internal_end_table_lock_wait_v1;
+extern ulong pfs_internal_start_file_open_wait_v1;
+extern ulong pfs_internal_end_file_open_wait_v1;
+extern ulong pfs_internal_end_file_open_wait_and_bind_to_descriptor_v1;
+extern ulong pfs_internal_start_file_wait_v1;
+extern ulong pfs_internal_end_file_wait_v1;
+extern ulong pfs_internal_start_stage_v1;
+extern ulong pfs_internal_end_stage_v1;
+extern ulong pfs_internal_get_thread_statement_locker_v1;
+extern ulong pfs_internal_refine_statement_v1;
+extern ulong pfs_internal_start_statement_v1;
+extern ulong pfs_internal_set_statement_text_v1;
+extern ulong pfs_internal_set_statement_lock_time_v1;
+extern ulong pfs_internal_set_statement_rows_sent_v1;
+extern ulong pfs_internal_set_statement_rows_examined_v1;
+extern ulong pfs_internal_inc_statement_created_tmp_disk_tables_v1;
+extern ulong pfs_internal_inc_statement_created_tmp_tables_v1;
+extern ulong pfs_internal_inc_statement_select_full_join_v1;
+extern ulong pfs_internal_inc_statement_select_full_range_join_v1;
+extern ulong pfs_internal_inc_statement_select_range_v1;
+extern ulong pfs_internal_inc_statement_select_range_check_v1;
+extern ulong pfs_internal_inc_statement_select_scan_v1;
+extern ulong pfs_internal_inc_statement_sort_merge_passes_v1;
+extern ulong pfs_internal_inc_statement_sort_range_v1;
+extern ulong pfs_internal_inc_statement_sort_rows_v1;
+extern ulong pfs_internal_inc_statement_sort_scan_v1;
+extern ulong pfs_internal_set_statement_no_index_used_v1;
+extern ulong pfs_internal_set_statement_no_good_index_used_v1;
+extern ulong pfs_internal_end_statement_v1;
+
+extern ulong pfs_internal_create_mutex;
+extern ulong pfs_internal_create_mutex_scan;
+extern ulong pfs_internal_create_rwlock;
+extern ulong pfs_internal_create_rwlock_scan;
+extern ulong pfs_internal_create_cond;
+extern ulong pfs_internal_create_cond_scan;
+extern ulong pfs_internal_create_thread;
+extern ulong pfs_internal_create_thread_scan;
+extern ulong pfs_internal_create_table;
+extern ulong pfs_internal_create_table_scan;
+
+#define PFS_INTERNAL_INC(X) X++
+
+#else
+#define PFS_INTERNAL_INC(X) do {} while (0)
+#endif
+
+#endif

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk-pfs-tuning branch (marc.alff:3376 to 3377) Marc Alff26 May