List:Commits« Previous MessageNext Message »
From:Christopher Powers Date:February 3 2011 5:40am
Subject:bzr push into mysql-trunk-wl5379 branch (chris.powers:3220 to 3222) WL#4896
View as plain text  
 3222 Christopher Powers	2011-02-02
      WL#4896 "Performance Schema Net IO"
      
      - Updated abi files
      - Fixed compiler warnings
      - Updates to table definition of socket_instances

    modified:
      include/mysql/psi/psi_abi_v1.h.pp
      include/mysql/psi/psi_abi_v2.h.pp
      storage/perfschema/pfs.cc
      storage/perfschema/table_socket_instances.cc*
      storage/perfschema/table_socket_instances.h*
 3221 Christopher Powers	2011-02-02
      WL#4896 "Performance Schema Net IO"
      
      - Added SOCKET_SUMMARY_BY_INSTANCE definition
      - Added support for remaining socket operations
      - Added aggregatation

    modified:
      include/mysql/psi/psi.h*
      scripts/mysql_system_tables.sql*
      storage/perfschema/pfs.cc
      storage/perfschema/pfs_column_types.h
      storage/perfschema/pfs_instr.cc*
      storage/perfschema/pfs_instr.h*
      storage/perfschema/pfs_instr_class.cc
      storage/perfschema/pfs_instr_class.h*
      storage/perfschema/pfs_stat.h*
      storage/perfschema/table_events_waits.cc
      storage/perfschema/table_events_waits_summary.cc*
 3220 Christopher Powers	2011-01-26
      Merge w/ mysql-trunk-wl5379

    modified:
      storage/perfschema/CMakeLists.txt*
      storage/perfschema/pfs.cc*
      storage/perfschema/pfs_column_types.h*
      storage/perfschema/pfs_engine_table.cc*
      storage/perfschema/pfs_events_waits.h*
      storage/perfschema/pfs_instr_class.cc*
      storage/perfschema/table_events_waits.cc*
=== modified file 'include/mysql/psi/psi.h' (properties changed: -x to +x)
--- a/include/mysql/psi/psi.h	2011-01-26 22:26:41 +0000
+++ b/include/mysql/psi/psi.h	2011-02-03 05:03:04 +0000
@@ -276,18 +276,26 @@ enum PSI_socket_operation
   PSI_SOCKET_BIND= 2,
   /** Socket close, as in @c shutdown(). */
   PSI_SOCKET_CLOSE= 3,
-  /** Generic socket send, such as @c send(), @c sendto(), @c sendmsg(). */
+  /** Socket send, @c send(). */
   PSI_SOCKET_SEND= 4,
-  /** Generic socket receive, such as @c recv(), @c recvfrom), @c recvmsg(). */
+  /** Socket receive, @c recv(). */
   PSI_SOCKET_RECV= 5,
-  /** Generic socket seek, such as @c fseek() or @c seek(). */
-  PSI_SOCKET_SEEK= 6,
+  /** Socket send, @c sendto(). */
+  PSI_SOCKET_SENDTO= 6,
+  /** Socket receive, @c recvfrom). */
+  PSI_SOCKET_RECVFROM= 7,
+  /** Socket send, @c sendmsg(). */
+  PSI_SOCKET_SENDMSG= 8,
+  /** Socket receive, @c recvmsg(). */
+  PSI_SOCKET_RECVMSG= 9,
+  /** Socket seek, such as @c fseek() or @c seek(). */
+  PSI_SOCKET_SEEK= 10,
   /** Socket options, as in @c getsockopt() and @c setsockopt(). */
-  PSI_SOCKET_OPT= 7,
+  PSI_SOCKET_OPT= 11,
   /** Socket status, as in @c sockatmark() and @c isfdtype(). */
-  PSI_SOCKET_STAT= 8,
+  PSI_SOCKET_STAT= 12,
   /** Socket shutdown, as in @c shutdown(). */
-  PSI_SOCKET_SHUTDOWN= 9
+  PSI_SOCKET_SHUTDOWN= 13
 };
 
 /**
@@ -1078,6 +1086,7 @@ typedef struct PSI_file_locker* (*get_th
 typedef struct PSI_file_locker* (*get_thread_file_descriptor_locker_v1_t)
   (struct PSI_file_locker_state_v1 *state,
    File file, enum PSI_file_operation op);
+
 /**
   Get a socket instrumentation locker.
   @param state data storage for the locker

=== modified file 'include/mysql/psi/psi_abi_v1.h.pp'
--- a/include/mysql/psi/psi_abi_v1.h.pp	2011-01-26 22:26:41 +0000
+++ b/include/mysql/psi/psi_abi_v1.h.pp	2011-02-03 05:40:19 +0000
@@ -75,10 +75,14 @@ enum PSI_socket_operation
   PSI_SOCKET_CLOSE= 3,
   PSI_SOCKET_SEND= 4,
   PSI_SOCKET_RECV= 5,
-  PSI_SOCKET_SEEK= 6,
-  PSI_SOCKET_OPT= 7,
-  PSI_SOCKET_STAT= 8,
-  PSI_SOCKET_SHUTDOWN= 9
+  PSI_SOCKET_SENDTO= 6,
+  PSI_SOCKET_RECVFROM= 7,
+  PSI_SOCKET_SENDMSG= 8,
+  PSI_SOCKET_RECVMSG= 9,
+  PSI_SOCKET_SEEK= 10,
+  PSI_SOCKET_OPT= 11,
+  PSI_SOCKET_STAT= 12,
+  PSI_SOCKET_SHUTDOWN= 13
 };
 typedef unsigned int PSI_mutex_key;
 typedef unsigned int PSI_rwlock_key;

=== modified file 'include/mysql/psi/psi_abi_v2.h.pp'
--- a/include/mysql/psi/psi_abi_v2.h.pp	2011-01-26 22:26:41 +0000
+++ b/include/mysql/psi/psi_abi_v2.h.pp	2011-02-03 05:40:19 +0000
@@ -75,10 +75,14 @@ enum PSI_socket_operation
   PSI_SOCKET_CLOSE= 3,
   PSI_SOCKET_SEND= 4,
   PSI_SOCKET_RECV= 5,
-  PSI_SOCKET_SEEK= 6,
-  PSI_SOCKET_OPT= 7,
-  PSI_SOCKET_STAT= 8,
-  PSI_SOCKET_SHUTDOWN= 9
+  PSI_SOCKET_SENDTO= 6,
+  PSI_SOCKET_RECVFROM= 7,
+  PSI_SOCKET_SENDMSG= 8,
+  PSI_SOCKET_RECVMSG= 9,
+  PSI_SOCKET_SEEK= 10,
+  PSI_SOCKET_OPT= 11,
+  PSI_SOCKET_STAT= 12,
+  PSI_SOCKET_SHUTDOWN= 13
 };
 typedef unsigned int PSI_mutex_key;
 typedef unsigned int PSI_rwlock_key;

=== modified file 'scripts/mysql_system_tables.sql' (properties changed: -x to +x)
--- a/scripts/mysql_system_tables.sql	2011-01-26 22:26:41 +0000
+++ b/scripts/mysql_system_tables.sql	2011-02-03 05:03:04 +0000
@@ -164,7 +164,7 @@ DROP PREPARE stmt;
 
 --
 -- From this point, only create the performance schema tables
--- if the server is build with performance schema
+-- if the server is built with performance schema
 --
 
 set @have_pfs= (select count(engine) from information_schema.engines where engine='PERFORMANCE_SCHEMA' and support != 'NO');
@@ -380,16 +380,14 @@ DROP PREPARE stmt;
 -- TABLE SOCKET_INSTANCES
 --
 
-SET @l1="CREATE TABLE performance_schema.socket_instances(";
-SET @l2="EVENT_NAME varchar(128) not null,";
-SET @l3="OBJECT_INSTANCE_BEGIN bigint(20) not null,";
-SET @l4="SOCKET_ID int(11) not null,";
-SET @l5="IP varchar(128) not null,";
-SET @l6="PORT int(11) not null,";
-SET @l7="BYTES_READ bigint(20) not null,";
-SET @l8="BYTES_WRITE bigint(20) not null";
-SET @l9=")ENGINE=PERFORMANCE_SCHEMA;";
-SET @cmd=concat(@l1,@l2,@l3,@l4,@l5,@l6,@l7,@l8,@l9);
+SET @cmd="CREATE TABLE performance_schema.socket_instances("
+  "EVENT_NAME VARCHAR(128) not null,"
+  "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null,"
+  "THREAD_ID INTEGER unsigned,"
+  "SOCKET_ID INTEGER unsigned,"
+  "IP VARCHAR(64),"
+  "PORT INTEGER unsigned"
+  ")ENGINE=PERFORMANCE_SCHEMA;";
 
 SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
 PREPARE stmt FROM @str;

=== modified file 'storage/perfschema/pfs.cc'
--- a/storage/perfschema/pfs.cc	2011-01-26 23:02:25 +0000
+++ b/storage/perfschema/pfs.cc	2011-02-03 05:40:19 +0000
@@ -998,6 +998,10 @@ static enum_operation_type socket_operat
   OPERATION_TYPE_SOCKETCLOSE,
   OPERATION_TYPE_SOCKETSEND,
   OPERATION_TYPE_SOCKETRECV,
+  OPERATION_TYPE_SOCKETSENDTO,
+  OPERATION_TYPE_SOCKETRECVFROM,
+  OPERATION_TYPE_SOCKETSENDMSG,
+  OPERATION_TYPE_SOCKETRECVMSG,
   OPERATION_TYPE_SOCKETSEEK,
   OPERATION_TYPE_SOCKETOPT,
   OPERATION_TYPE_SOCKETSTAT,
@@ -1297,21 +1301,7 @@ static void close_table_v1(PSI_table *ta
 static PSI_socket*
 init_socket_v1(PSI_socket_key key, const void *identity)
 {
-//  INIT_BODY_V1(socket, key, identity);
-  PFS_socket_class *klass;
-  PFS_socket *pfs;
-  PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
-  if (unlikely(pfs_thread == NULL))
-    return NULL;
-  if (!pfs_thread->m_enabled)
-    return NULL;
-  klass= find_socket_class(key);
-  if (unlikely(klass == NULL))
-    return NULL;
-  if (!klass->m_enabled)
-    return NULL;
-  pfs= create_socket(klass, identity);
-  return reinterpret_cast<PSI_socket *> (pfs);
+  INIT_BODY_V1(socket, key, identity);
 }
 
 static void destroy_socket_v1(PSI_socket* socket)
@@ -1817,10 +1807,13 @@ get_thread_rwlock_locker_v1(PSI_rwlock_l
   if (flag_thread_instrumentation)
   {
     PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
+
     if (unlikely(pfs_thread == NULL))
       return NULL;
+
     if (! pfs_thread->m_enabled)
       return NULL;
+
     state->m_thread= reinterpret_cast<PSI_thread *> (pfs_thread);
     flags= STATE_FLAG_THREAD;
 
@@ -2534,29 +2527,22 @@ static PSI_socket_locker*
 get_thread_socket_locker_v1(PSI_socket_locker_state *state,
                                PSI_socket *socket, PSI_socket_operation op)
 {
-  PFS_socket *pfs_socket= reinterpret_cast<PFS_socket*> (socket);
-
   DBUG_ASSERT(static_cast<int> (op) >= 0);
   DBUG_ASSERT(static_cast<uint> (op) < array_elements(socket_operation_map));
   DBUG_ASSERT(state != NULL);
+  PFS_socket *pfs_socket= reinterpret_cast<PFS_socket*> (socket);
   DBUG_ASSERT(pfs_socket != NULL);
   DBUG_ASSERT(pfs_socket->m_class != NULL);
 
   if (!flag_global_instrumentation)
     return NULL;
-  if (!pfs_socket->m_class->m_enabled)
-    return NULL;
+
   PFS_socket_class *klass= pfs_socket->m_class;
   if (!klass->m_enabled)
     return NULL;
 
   register uint flags;
 
-  if (klass->m_timed)
-    state->m_flags= STATE_FLAG_TIMED;
-  else
-    state->m_flags= 0;
-
   if (flag_thread_instrumentation)
   {
     PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
@@ -2592,8 +2578,8 @@ get_thread_socket_locker_v1(PSI_socket_l
       wait->m_timer_start= 0;
       wait->m_timer_end= 0;
       wait->m_object_instance_addr= pfs_socket;
-//    wait->m_object_name= pfs_socket->m_ip;
-//    wait->m_object_name_length= pfs_socket->m_ip_length;
+   // wait->m_object_name= pfs_socket->m_ip;   // TBD: Where is object_name defined?
+   // wait->m_object_name_length= pfs_socket->m_ip_length;
       wait->m_event_id= pfs_thread->m_event_id++;
       wait->m_operation= socket_operation_map[static_cast<int>(op)];
       wait->m_wait_class= WAIT_CLASS_SOCKET;
@@ -2604,13 +2590,16 @@ get_thread_socket_locker_v1(PSI_socket_l
   else
   {
     if (klass->m_timed)
+    {
       flags= STATE_FLAG_TIMED;
+      state->m_thread= NULL;
+    }
     else
     {
       /*
         Complete shortcut.
       */
-      PFS_socket *pfs_socket= reinterpret_cast<PFS_socket *> (socket);
+      PFS_socket *pfs_socket= reinterpret_cast<PFS_socket *>(socket);
       /* Aggregate to EVENTS_WAITS_SUMMARY_BY_INSTANCE (counted) */
       pfs_socket->m_wait_stat.aggregate_counted();
       return NULL;
@@ -3518,14 +3507,13 @@ static void end_socket_wait_v1(PSI_socke
 */
 static void start_socket_wait_v1(PSI_socket_locker *locker,
                                  size_t count,
-                                 const char *src_file,
-                                 uint src_line)
+                                 const char *src_file, uint src_line)
 {
-  ulonglong timer_start= 0;
   PSI_socket_locker_state *state= reinterpret_cast<PSI_socket_locker_state*> (locker);
   DBUG_ASSERT(state != NULL);
 
   register uint flags= state->m_flags;
+  ulonglong timer_start= 0;
 
   if (flags & STATE_FLAG_TIMED)
   {
@@ -3558,7 +3546,49 @@ static void end_socket_wait_v1(PSI_socke
 
   PFS_socket *socket= reinterpret_cast<PFS_socket *> (state->m_socket);
   DBUG_ASSERT(socket != NULL);
-  PFS_thread *thread= reinterpret_cast<PFS_thread *> (state->m_thread);
+//TBD  PFS_thread *thread= reinterpret_cast<PFS_thread *> (state->m_thread);
+
+  PFS_single_stat *stat;
+
+  switch (state->m_operation)
+  {
+  case PSI_SOCKET_CONNECT:
+    stat= &socket->m_socket_stat.m_io_stat.m_connect;
+    break;
+  case PSI_SOCKET_SEND:
+    stat= &socket->m_socket_stat.m_io_stat.m_send;
+    break;
+  case PSI_SOCKET_RECV:
+    stat= &socket->m_socket_stat.m_io_stat.m_recv;
+    break;
+  case PSI_SOCKET_SENDTO:
+    stat= &socket->m_socket_stat.m_io_stat.m_sendto;
+    break;
+  case PSI_SOCKET_RECVFROM:
+    stat= &socket->m_socket_stat.m_io_stat.m_recvfrom;
+    break;
+  case PSI_SOCKET_SENDMSG:
+    stat= &socket->m_socket_stat.m_io_stat.m_sendmsg;
+    break;
+  case PSI_SOCKET_RECVMSG:
+    stat= &socket->m_socket_stat.m_io_stat.m_recvmsg;
+    break;
+
+  /** These operations are grouped as 'miscellaneous' */
+  case PSI_SOCKET_CREATE:
+  case PSI_SOCKET_BIND:
+  case PSI_SOCKET_CLOSE:
+  case PSI_SOCKET_SEEK:
+  case PSI_SOCKET_OPT:
+  case PSI_SOCKET_STAT:
+  case PSI_SOCKET_SHUTDOWN:
+    stat= &socket->m_socket_stat.m_io_stat.m_misc;
+    break;
+  default:
+    DBUG_ASSERT(false);
+    stat= NULL;
+    break;
+  }
 
   register uint flags= state->m_flags;
 
@@ -3566,75 +3596,28 @@ static void end_socket_wait_v1(PSI_socke
   {
     timer_end= state->m_timer();
     wait_time= timer_end - state->m_timer_start;
-    /* Aggregate to EVENTS_WAITS_SUMMARY_BY_INSTANCE (timed) */
-    socket->m_wait_stat.aggregate_timed(wait_time);
+    stat->aggregate_timed(wait_time);
   }
   else
   {
-    /* Aggregate to EVENTS_WAITS_SUMMARY_BY_INSTANCE (counted) */
-    socket->m_wait_stat.aggregate_counted();
+    stat->aggregate_counted();
   }
 
-  if (flags & STATE_FLAG_THREAD)
+  if (flags & STATE_FLAG_WAIT)
   {
+    DBUG_ASSERT(flags & STATE_FLAG_THREAD);
+    PFS_thread *thread= reinterpret_cast<PFS_thread *> (state->m_thread);
     DBUG_ASSERT(thread != NULL);
 
-    PFS_single_stat *event_name_array;
-    event_name_array= thread->m_instr_class_wait_stats;
-    uint index= socket->m_class->m_event_name_index;
-
-    if (flags & STATE_FLAG_TIMED)
-    {
-      /* Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME (timed) */
-      event_name_array[index].aggregate_timed(wait_time);
-    }
-    else
-    {
-      /* Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME (counted) */
-      event_name_array[index].aggregate_counted();
-    }
-
-    if (state->m_flags & STATE_FLAG_WAIT)
-    {
-      PFS_events_waits *wait= reinterpret_cast<PFS_events_waits*> (state->m_wait);
-      DBUG_ASSERT(wait != NULL);
-
-      wait->m_timer_end= timer_end;
-      wait->m_number_of_bytes= count;
-      if (flag_events_waits_history)
-        insert_events_waits_history(thread, wait);
-      if (flag_events_waits_history_long)
-        insert_events_waits_history_long(wait);
-      thread->m_events_waits_count--;
-    }
-  }
+    PFS_events_waits *wait= reinterpret_cast<PFS_events_waits*> (state->m_wait);
+    DBUG_ASSERT(wait != NULL);
 
-  switch(state->m_operation)
-  {
-  case PSI_SOCKET_CREATE:
-//  socket->m_socket_stat.m_open_count++;
-//  klass->m_socket_stat.m_open_count++;
-    break;
-  case PSI_SOCKET_SEND:
-    socket->m_socket_stat.m_io_stat.aggregate_write(count);
-    break;
-  case PSI_SOCKET_RECV:
-    socket->m_socket_stat.m_io_stat.aggregate_read(count);
-    break;
-  case PSI_SOCKET_CLOSE:
-    /** close() frees the file descriptor, shutdown() does not */
-    release_socket(socket);
-    destroy_socket(socket);
-    break;
-  case PSI_SOCKET_CONNECT:
-  case PSI_SOCKET_BIND:
-  case PSI_SOCKET_STAT:
-  case PSI_SOCKET_OPT:
-  case PSI_SOCKET_SEEK:
-  case PSI_SOCKET_SHUTDOWN:
-    break;
-  default:
-    break;
+    wait->m_timer_end= timer_end;
+    if (flag_events_waits_history)
+      insert_events_waits_history(thread, wait);
+    if (flag_events_waits_history_long)
+      insert_events_waits_history_long(wait);
+    thread->m_events_waits_count--;
   }
 }
 
@@ -3646,6 +3629,11 @@ static void set_socket_descriptor_v1(PSI
 }
 
 #ifdef __WIN__
+
+/**
+  inet_ntop() and inet_pton() do not exist in Windows. They are defined here
+  for convenience.
+*/
 const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt)
 {
   if (af == AF_INET)

=== modified file 'storage/perfschema/pfs_column_types.h'
--- a/storage/perfschema/pfs_column_types.h	2011-01-26 23:02:25 +0000
+++ b/storage/perfschema/pfs_column_types.h	2011-02-03 05:03:04 +0000
@@ -144,11 +144,16 @@ enum enum_operation_type
   OPERATION_TYPE_SOCKETCLOSE = 44,
   OPERATION_TYPE_SOCKETSEND = 45,
   OPERATION_TYPE_SOCKETRECV = 46,
-  OPERATION_TYPE_SOCKETSEEK = 47,
-  OPERATION_TYPE_SOCKETOPT = 48,
-  OPERATION_TYPE_SOCKETSTAT = 49,
-  OPERATION_TYPE_SOCKETSHUTDOWN = 50
+  OPERATION_TYPE_SOCKETSENDTO = 47,
+  OPERATION_TYPE_SOCKETRECVFROM = 48,
+  OPERATION_TYPE_SOCKETSENDMSG = 49,
+  OPERATION_TYPE_SOCKETRECVMSG = 50,
+  OPERATION_TYPE_SOCKETSEEK = 51,
+  OPERATION_TYPE_SOCKETOPT = 52,
+  OPERATION_TYPE_SOCKETSTAT = 53,
+  OPERATION_TYPE_SOCKETSHUTDOWN = 54
 };
+
 #define FIRST_OPERATION_TYPE (static_cast<int> (OPERATION_TYPE_LOCK))
 #define LAST_OPERATION_TYPE (static_cast<int> (OPERATION_TYPE_SOCKETSHUTDOWN)
 #define COUNT_OPERATION_TYPE (LAST_OPERATION_TYPE - FIRST_OPERATION_TYPE + 1)

=== modified file 'storage/perfschema/pfs_instr.cc' (properties changed: -x to +x)
--- a/storage/perfschema/pfs_instr.cc	2011-01-26 22:26:41 +0000
+++ b/storage/perfschema/pfs_instr.cc	2011-02-03 05:03:04 +0000
@@ -762,6 +762,11 @@ PFS_file *sanitize_file(PFS_file *unsafe
   SANITIZE_ARRAY_BODY(PFS_file, file_array, file_max, unsafe);
 }
 
+PFS_socket *sanitize_socket(PFS_socket *unsafe)
+{
+  SANITIZE_ARRAY_BODY(PFS_socket, socket_array, socket_max, unsafe);
+}
+
 /**
   Destroy instrumentation for a thread instance.
   @param pfs                          the thread to destroy
@@ -1199,7 +1204,7 @@ PFS_socket* create_socket(PFS_socket_cla
           pfs->m_identity= identity;
           pfs->m_class= klass;
           pfs->m_wait_stat.reset();
-          // TBD socket_io_stat
+          pfs->m_socket_stat.reset();
           pfs->m_lock.dirty_to_allocated();
           return pfs;
         }
@@ -1218,7 +1223,7 @@ PFS_socket* create_socket(PFS_socket_cla
 void release_socket(PFS_socket *pfs)
 {
   DBUG_ASSERT(pfs != NULL);
-  //pfs->m_socket_stat.m_open_count--;
+  pfs->m_socket_stat.m_open_count--;
 }
 
 /**
@@ -1228,7 +1233,17 @@ void release_socket(PFS_socket *pfs)
 void destroy_socket(PFS_socket *pfs)
 {
   DBUG_ASSERT(pfs != NULL);
-  // TBD aggregate
+  PFS_socket_class *klass= pfs->m_class;
+
+  /* Aggregate to EVENTS_WAITS_SUMMARY_BY_EVENT_NAME */
+  uint index= klass->m_event_name_index;
+  global_instr_class_waits_array[index].aggregate(& pfs->m_wait_stat);
+  pfs->m_wait_stat.reset();
+
+  /* Aggregate to SOCKET_SUMMARY_BY_INSTANCE */
+  klass->m_socket_stat.m_io_stat.aggregate(&pfs->m_socket_stat.m_io_stat);
+  pfs->m_socket_stat.m_io_stat.reset();
+
   pfs->m_lock.allocated_to_free();
 }
 
@@ -1297,6 +1312,16 @@ void reset_file_instance_io(void)
     pfs->m_file_stat.m_io_stat.reset();
 }
 
+/** Reset the io statistics per socket instance. */
+void reset_socket_instance_io(void)
+{
+  PFS_socket *pfs= socket_array;
+  PFS_socket *pfs_last= socket_array + socket_max;
+
+  for ( ; pfs < pfs_last; pfs++)
+    pfs->m_socket_stat.m_io_stat.reset();
+}
+
 void reset_global_wait_stat()
 {
   PFS_single_stat *stat= global_instr_class_waits_array;

=== modified file 'storage/perfschema/pfs_instr.h' (properties changed: -x to +x)
--- a/storage/perfschema/pfs_instr.h	2011-01-26 22:26:41 +0000
+++ b/storage/perfschema/pfs_instr.h	2011-02-03 05:03:04 +0000
@@ -198,6 +198,8 @@ struct PFS_socket : public PFS_instr
 {
   /** Socket identity, typically int */
   const void *m_identity;
+  /** Thread identifier */
+  uint m_thread_id;
   /** Socket file descriptor */
   uint m_fd;
   /** Socket ip address, IPV4 or IPV6 */
@@ -350,6 +352,7 @@ PFS_cond *sanitize_cond(PFS_cond *unsafe
 PFS_thread *sanitize_thread(PFS_thread *unsafe);
 const char *sanitize_file_name(const char *unsafe);
 PFS_file *sanitize_file(PFS_file *unsafe);
+PFS_socket *sanitize_socket(PFS_socket *unsafe);
 
 int init_instruments(const PFS_global_param *param);
 void cleanup_instruments();
@@ -415,6 +418,7 @@ extern PFS_socket *socket_array;
 void reset_events_waits_by_instance();
 void reset_per_thread_wait_stat();
 void reset_file_instance_io();
+void reset_socket_instance_io();
 
 void reset_global_wait_stat(void);
 

=== modified file 'storage/perfschema/pfs_instr_class.cc'
--- a/storage/perfschema/pfs_instr_class.cc	2011-01-26 23:02:25 +0000
+++ b/storage/perfschema/pfs_instr_class.cc	2011-02-03 05:03:04 +0000
@@ -450,7 +450,8 @@ int init_socket_class(uint socket_class_
 
   if (socket_class_max > 0)
   {
-    socket_class_array= PFS_MALLOC_ARRAY(socket_class_max, PFS_socket_class, MYF(MY_ZEROFILL));
+    socket_class_array= PFS_MALLOC_ARRAY(socket_class_max, PFS_socket_class,
+                                         MYF(MY_ZEROFILL));
     if (unlikely(socket_class_array == NULL))
       return 1;
   }
@@ -821,18 +822,8 @@ PFS_socket_key register_socket_class(con
   uint32 index;
   PFS_socket_class *entry;
 
-// TBD  REGISTER_CLASS_BODY_PART(index, socket_class_array, socket_class_max, name, name_length)
-
-  for (index= 0; index < socket_class_max; index++)
-  {
-    entry= &socket_class_array[index];
-    if ((entry->m_name_length == name_length) &&
-        (strncmp(entry->m_name, name, name_length) == 0))
-    {
-      DBUG_ASSERT(entry->m_flags == flags);
-      return (index + 1);
-    }
-  }
+  REGISTER_CLASS_BODY_PART(index, socket_class_array, socket_class_max,
+                           name, name_length)
 
   index= PFS_atomic::add_u32(&socket_class_dirty_count, 1);
 
@@ -842,7 +833,6 @@ PFS_socket_key register_socket_class(con
     init_instr_class(entry, name, name_length, flags);
     entry->m_index= index;
     entry->m_event_name_index= file_class_start + index;
-    entry->m_singleton= NULL;
     PFS_atomic::add_u32(&socket_class_allocated_count, 1);
     return (index + 1);
   }
@@ -858,10 +848,7 @@ PFS_socket_key register_socket_class(con
 */
 PFS_socket_class *find_socket_class(PFS_socket_key key)
 {
-//  FIND_CLASS_BODY(key, socket_class_allocated_count, socket_class_array);
-  if ((key == 0) || (key > socket_class_allocated_count))
-    return NULL;
-  return &socket_class_array[key - 1];
+  FIND_CLASS_BODY(key, socket_class_allocated_count, socket_class_array);
 }
 
 PFS_socket_class *sanitize_socket_class(PFS_socket_class *unsafe)

=== modified file 'storage/perfschema/pfs_instr_class.h' (properties changed: -x to +x)
--- a/storage/perfschema/pfs_instr_class.h	2011-01-26 22:26:41 +0000
+++ b/storage/perfschema/pfs_instr_class.h	2011-02-03 05:03:04 +0000
@@ -291,8 +291,6 @@ struct PFS_socket_class : public PFS_ins
   PFS_socket_stat m_socket_stat;
   /** Self index in @c socket_class_array. */
   uint m_index;
-  /** Singleton instance. */
-  PFS_file *m_singleton;
 };
 
 void init_event_name_sizing(const PFS_global_param *param);

=== modified file 'storage/perfschema/pfs_stat.h' (properties changed: -x to +x)
--- a/storage/perfschema/pfs_stat.h	2011-01-26 22:26:41 +0000
+++ b/storage/perfschema/pfs_stat.h	2011-02-03 05:03:04 +0000
@@ -309,42 +309,64 @@ struct PFS_table_stat
 /** Statistics for SOCKET IO usage. */
 struct PFS_socket_io_stat
 {
-  /** Count of READ operations. */
-  ulonglong m_count_read;
-  /** Count of WRITE operations. */
-  ulonglong m_count_write;
-  /** Number of bytes read. */
-  ulonglong m_read_bytes;
-  /** Number of bytes written. */
-  ulonglong m_write_bytes;
+  /** READ statistics */
+  PFS_single_stat m_read;
+  /** WRITE statistics */
+  PFS_single_stat m_write;
+  /** RECV statistics */
+  PFS_single_stat m_recv;
+  /** SEND statistics */
+  PFS_single_stat m_send;
+  /** RECVFROM statistics */
+  PFS_single_stat m_recvfrom;
+  /** SENDTO statistics */
+  PFS_single_stat m_sendto;
+  /** RECVMSG statistics */
+  PFS_single_stat m_recvmsg;
+  /** SENDMSG statistics */
+  PFS_single_stat m_sendmsg;
+  /** CONNECT statistics */
+  PFS_single_stat m_connect;
+  /** Miscelleanous statistics */
+  PFS_single_stat m_misc;
 
-  /** Reset socket statistics. */
   inline void reset(void)
   {
-    m_count_read= 0;
-    m_count_write= 0;
-    m_read_bytes= 0;
-    m_write_bytes= 0;
+    m_read.reset();
+    m_write.reset();
+    m_recv.reset();
+    m_send.reset();
+    m_recvfrom.reset();
+    m_sendto.reset();
+    m_recvmsg.reset();
+    m_sendmsg.reset();
+    m_connect.reset();
+    m_misc.reset();
   }
 
   inline void aggregate(const PFS_socket_io_stat *stat)
   {
-    m_count_read+= stat->m_count_read;
-    m_count_write+= stat->m_count_write;
-    m_read_bytes+= stat->m_read_bytes;
-    m_write_bytes+= stat->m_write_bytes;
+    m_recv.aggregate(&stat->m_recv);
+    m_send.aggregate(&stat->m_send);
+    m_recvfrom.aggregate(&stat->m_recvfrom);
+    m_sendto.aggregate(&stat->m_sendto);
+    m_recvmsg.aggregate(&stat->m_recvmsg);
+    m_sendmsg.aggregate(&stat->m_sendmsg);
+    m_connect.aggregate(&stat->m_connect);
+    m_misc.aggregate(&stat->m_misc);
+    // TBD: read+write
   }
 
-  inline void aggregate_read(ulonglong bytes)
+  inline void sum(PFS_single_stat *result)
   {
-    m_count_read++;
-    m_read_bytes+= bytes;
-  }
-
-  inline void aggregate_write(ulonglong bytes)
-  {
-    m_count_write++;
-    m_write_bytes+= bytes;
+    result->aggregate(&m_recv);
+    result->aggregate(&m_send);
+    result->aggregate(&m_recvfrom);
+    result->aggregate(&m_sendto);
+    result->aggregate(&m_recvmsg);
+    result->aggregate(&m_sendmsg);
+    result->aggregate(&m_connect);
+    result->aggregate(&m_misc);
   }
 };
 
@@ -355,8 +377,13 @@ struct PFS_socket_stat
   ulong m_open_count;
   /** Socket IO statistics. */
   PFS_socket_io_stat m_io_stat;
-};
 
+  /** Reset socket statistics. */
+  inline void reset(void)
+  {
+    m_io_stat.reset();
+  }
+};
 
 /** @} */
 #endif

=== modified file 'storage/perfschema/table_events_waits.cc'
--- a/storage/perfschema/table_events_waits.cc	2011-01-26 23:02:25 +0000
+++ b/storage/perfschema/table_events_waits.cc	2011-02-03 05:03:04 +0000
@@ -478,7 +478,11 @@ static const LEX_STRING operation_names_
   { C_STRING_WITH_LEN("bind") },
   { C_STRING_WITH_LEN("close") },
   { C_STRING_WITH_LEN("send") },
-  { C_STRING_WITH_LEN("receive") },
+  { C_STRING_WITH_LEN("recv") },
+  { C_STRING_WITH_LEN("sendto") },
+  { C_STRING_WITH_LEN("recvfrom") },
+  { C_STRING_WITH_LEN("sendmsg") },
+  { C_STRING_WITH_LEN("recvmsg") },
   { C_STRING_WITH_LEN("seek") },
   { C_STRING_WITH_LEN("opt") },
   { C_STRING_WITH_LEN("stat") },

=== modified file 'storage/perfschema/table_events_waits_summary.cc' (properties changed: -x to +x)
--- a/storage/perfschema/table_events_waits_summary.cc	2010-12-07 18:55:54 +0000
+++ b/storage/perfschema/table_events_waits_summary.cc	2011-02-03 05:03:04 +0000
@@ -200,10 +200,10 @@ void table_events_waits_summary_by_insta
     return;
 
   /*
-    Files don't have a in memory structure associated to it,
+    Sockets don't have a in memory structure associated to it,
     so we use the address of the PFS_socket buffer as object_instance_begin
   */
-  make_instr_row(pfs, safe_class, pfs);
+  make_instr_row(pfs, safe_class, pfs); // TBD: check this
 }
 
 int table_events_waits_summary_by_instance

=== modified file 'storage/perfschema/table_socket_instances.cc' (properties changed: -x to +x)
--- a/storage/perfschema/table_socket_instances.cc	2010-12-08 03:24:30 +0000
+++ b/storage/perfschema/table_socket_instances.cc	2011-02-03 05:40:19 +0000
@@ -41,28 +41,23 @@ static const TABLE_FIELD_TYPE field_type
     { NULL, 0}
   },
   {
-    { C_STRING_WITH_LEN("SOCKET_ID") },
-    { C_STRING_WITH_LEN("int(11)") },
-    { NULL, 0}
-  },
-  {
-    { C_STRING_WITH_LEN("IP") },
-    { C_STRING_WITH_LEN("varchar(128)") },
+    { C_STRING_WITH_LEN("THREAD_ID") },
+    { C_STRING_WITH_LEN("int(10)") },
     { NULL, 0}
   },
   {
-    { C_STRING_WITH_LEN("PORT") },
-    { C_STRING_WITH_LEN("int(11)") },
+    { C_STRING_WITH_LEN("SOCKET_ID") },
+    { C_STRING_WITH_LEN("int(10)") },
     { NULL, 0}
   },
   {
-    { C_STRING_WITH_LEN("BYTES_READ") },
-    { C_STRING_WITH_LEN("bigint(20)") },
+    { C_STRING_WITH_LEN("IP") },
+    { C_STRING_WITH_LEN("varchar(64)") },
     { NULL, 0}
   },
   {
-    { C_STRING_WITH_LEN("BYTES_WRITE") },
-    { C_STRING_WITH_LEN("bigint(20)") },
+    { C_STRING_WITH_LEN("PORT") },
+    { C_STRING_WITH_LEN("int(10)") },
     { NULL, 0}
   }
 };
@@ -70,7 +65,7 @@ static const TABLE_FIELD_TYPE field_type
 
 TABLE_FIELD_DEF
 table_socket_instances::m_field_def=
-{ 7, field_types };
+{ 6, field_types };
 
 PFS_engine_table_share
 table_socket_instances::m_share=
@@ -156,12 +151,11 @@ void table_socket_instances::make_row(PF
   m_row.m_event_name=         safe_class->m_name;
   m_row.m_event_name_length=  safe_class->m_name_length;
   m_row.m_identity=           pfs->m_identity;
+  m_row.m_thread_id=          pfs->m_thread_id;
   m_row.m_fd=                 pfs->m_fd;
   m_row.m_ip=                 pfs->m_ip;
   m_row.m_ip_length=          pfs->m_ip_length;
   m_row.m_port=               pfs->m_port;
-  m_row.m_bytes_read=         pfs->m_socket_stat.m_io_stat.m_read_bytes; //TBD
-  m_row.m_bytes_write=        pfs->m_socket_stat.m_io_stat.m_write_bytes;
 
   if (pfs->m_lock.end_optimistic_lock(&lock))
     m_row_exists= true;
@@ -192,21 +186,18 @@ int table_socket_instances::read_row_val
       case 1: /* OBJECT_INSTANCE_BEGIN */
         set_field_ulonglong(f, (intptr)m_row.m_identity);
         break;
-      case 2: /* SOCKET_ID */
+      case 2: /* THREAD_ID */
+        set_field_ulong(f, m_row.m_thread_id);
+        break;
+      case 3: /* SOCKET_ID */
         set_field_ulong(f, m_row.m_fd);
         break;
-      case 3: /* IP */
+      case 4: /* IP */
         set_field_varchar_utf8(f, m_row.m_ip, m_row.m_ip_length);
         break;
-      case 4: /* PORT */
+      case 5: /* PORT */
         set_field_ulong(f, m_row.m_port);
         break;
-      case 5: /* BYTES_READ */
-        set_field_ulonglong(f, m_row.m_bytes_read);
-        break;
-      case 6: /* BYTES_WRITE */
-        set_field_ulonglong(f, m_row.m_bytes_write);
-        break;
       default:
         DBUG_ASSERT(false);
       }

=== modified file 'storage/perfschema/table_socket_instances.h' (properties changed: -x to +x)
--- a/storage/perfschema/table_socket_instances.h	2010-12-07 19:50:08 +0000
+++ b/storage/perfschema/table_socket_instances.h	2011-02-03 05:40:19 +0000
@@ -38,6 +38,8 @@ struct row_socket_instances
   uint m_event_name_length;
   /** Column OBJECT_INSTANCE_BEGIN */
   const void *m_identity;
+  /** Column THREAD_ID */
+  uint m_thread_id;
   /** Column SOCKET_ID */
   uint m_fd;
   /** Column IP. */
@@ -46,10 +48,6 @@ struct row_socket_instances
   uint m_ip_length;
   /** Column PORT */
   uint m_port;
-  /** Column BYTES_READ */
-  ulonglong m_bytes_read;           // TBD
-  /** Column BYTES_WRITE */
-  ulonglong m_bytes_write;
 };
 
 /** Table PERFORMANCE_SCHEMA.SOCKET_INSTANCES. */


Attachment: [text/bzr-bundle] bzr/chris.powers@oracle.com-20110203054019-pw8ylc67ke9la3sg.bundle
Thread
bzr push into mysql-trunk-wl5379 branch (chris.powers:3220 to 3222) WL#4896Christopher Powers3 Feb