List:Commits« Previous MessageNext Message »
From:Christopher Powers Date:February 14 2011 11:28pm
Subject:bzr push into mysql-trunk-wl5379 branch (chris.powers:3229 to 3230) WL#4896
View as plain text  
 3230 cpowers	2011-02-14
      WL#4896 "Performance Schema Net IO"
      
      - Added events_waits hooks
      - Added object_name info as ip:port

    modified:
      storage/perfschema/pfs.cc
      storage/perfschema/pfs_events_waits.h
      storage/perfschema/pfs_instr.h
      storage/perfschema/table_events_waits.cc
      storage/perfschema/table_events_waits.h
 3229 cpowers	2011-02-11
      WL#4896 "Performance Schema Net IO"
      
      - Corrected assignment of object_instance_begin field
      - Added VIEW_SOCKET to events_waits_summary_by_thread_by_event_name
      - Added VIEW_SOCKET to events_waits_summary_global_by_event_name
      - Fixed conditions to invoke set_socket_info() in mysql_socket.h

    modified:
      include/mysql/psi/mysql_socket.h
      storage/perfschema/pfs.cc
      storage/perfschema/pfs_instr.cc
      storage/perfschema/table_ews_by_thread_by_event_name.cc
      storage/perfschema/table_ews_global_by_event_name.cc
      storage/perfschema/table_ews_global_by_event_name.h
      storage/perfschema/table_socket_instances.cc
=== modified file 'storage/perfschema/pfs.cc'
--- a/storage/perfschema/pfs.cc	2011-02-12 00:22:15 +0000
+++ b/storage/perfschema/pfs.cc	2011-02-14 23:26:08 +0000
@@ -2573,16 +2573,15 @@ get_thread_socket_locker_v1(PSI_socket_l
 #ifdef HAVE_NESTED_EVENTS
       wait->m_nesting_event_id= (wait - 1)->m_event_id;
 #endif
-      wait->m_thread= pfs_thread;
-      wait->m_class= klass;
+      wait->m_thread=      pfs_thread;
+      wait->m_class=       klass;
       wait->m_timer_start= 0;
-      wait->m_timer_end= 0;
+      wait->m_timer_end=   0;
       wait->m_object_instance_addr= pfs_socket->m_identity;
-   // 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;
+      wait->m_weak_socket= pfs_socket;
+      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;
 
       pfs_thread->m_events_waits_count++;
     }
@@ -3701,6 +3700,8 @@ static void set_socket_address_v1(PSI_so
   DBUG_ASSERT(socket);
   PFS_socket *pfs= reinterpret_cast<PFS_socket*>(socket);
 
+  memset(pfs->m_ip, 0, pfs->m_ip_length);
+
   switch (socket_addr->sa_family)
   {
     case AF_INET:
@@ -3724,6 +3725,9 @@ static void set_socket_address_v1(PSI_so
     default:
       break;
   }
+
+  /* Adjust IP address string length */
+  pfs->m_ip_length= strlen((const char*)pfs->m_ip);
 }
 
 static void set_socket_info_v1(PSI_socket *socket,

=== modified file 'storage/perfschema/pfs_events_waits.h'
--- a/storage/perfschema/pfs_events_waits.h	2011-02-04 22:00:44 +0000
+++ b/storage/perfschema/pfs_events_waits.h	2011-02-14 23:26:08 +0000
@@ -85,6 +85,8 @@ struct PFS_events_waits
   PFS_table_share *m_weak_table_share;
   /** File, for file operations only. */
   PFS_file *m_weak_file;
+  /** Socket, for socket operations only. */
+  PFS_socket *m_weak_socket;
   /** For weak pointers, target object version. */
   uint32 m_weak_version;
   /** Address in memory of the object instance waited on. */

=== modified file 'storage/perfschema/pfs_instr.h'
--- a/storage/perfschema/pfs_instr.h	2011-02-07 19:17:08 +0000
+++ b/storage/perfschema/pfs_instr.h	2011-02-14 23:26:08 +0000
@@ -196,6 +196,9 @@ private:
 /** Instrumented socket implementation. @see PSI_socket. */
 struct PFS_socket : public PFS_instr
 {
+  uint32 get_version()
+  { return m_lock.get_version(); }
+
   /** Socket identity, typically int */
   const void *m_identity;
   /** Thread identifier */

=== modified file 'storage/perfschema/table_events_waits.cc'
--- a/storage/perfschema/table_events_waits.cc	2011-02-07 19:17:08 +0000
+++ b/storage/perfschema/table_events_waits.cc	2011-02-14 23:26:08 +0000
@@ -25,6 +25,7 @@
 #include "pfs_instr.h"
 #include "pfs_events_waits.h"
 #include "pfs_timer.h"
+#include "m_string.h"
 
 THR_LOCK table_events_waits_current::m_table_lock;
 
@@ -279,6 +280,46 @@ int table_events_waits_common::make_file
   return 0;
 }
 
+int table_events_waits_common::make_socket_object_columns(volatile PFS_events_waits *wait)
+{
+  PFS_socket *safe_socket;
+
+  safe_socket= sanitize_socket(wait->m_weak_socket);
+  if (unlikely(safe_socket == NULL))
+    return 1;
+
+  m_row.m_object_type= "SOCKET";
+  m_row.m_object_type_length= 6;
+  m_row.m_object_schema_length= 0;
+
+  if (safe_socket->get_version() == wait->m_weak_version)
+  {
+    /* Convert port number to string, include delimiter in port name length */
+    char port[128];
+    port[0] = ':';
+    int port_len= int10_to_str(safe_socket->m_port, (port+1), 10) - port + 1;
+
+    /* OBJECT NAME */
+    m_row.m_object_name_length= safe_socket->m_ip_length + port_len;
+
+    if (unlikely((m_row.m_object_name_length == 0) ||
+                 (m_row.m_object_name_length > sizeof(m_row.m_object_name))))
+      return 1;
+
+    char *name= m_row.m_object_name;
+    memcpy(name, safe_socket->m_ip, safe_socket->m_ip_length);
+    memcpy(name + safe_socket->m_ip_length, port, port_len);
+  }
+  else
+  {
+    m_row.m_object_name_length= 0;
+  }
+
+  m_row.m_index_name_length= 0;
+
+  return 0;
+}
+
 /**
   Build a row.
   @param thread_own_wait            True if the memory for the wait
@@ -352,6 +393,11 @@ void table_events_waits_common::make_row
       return;
     safe_class= sanitize_file_class((PFS_file_class*) wait->m_class);
     break;
+  case WAIT_CLASS_SOCKET:
+    if (make_socket_object_columns(wait))
+      return;
+    safe_class= sanitize_socket_class((PFS_socket_class*) wait->m_class);
+    break;
   case NO_WAIT_CLASS:
   default:
     return;

=== modified file 'storage/perfschema/table_events_waits.h'
--- a/storage/perfschema/table_events_waits.h	2010-12-09 16:17:13 +0000
+++ b/storage/perfschema/table_events_waits.h	2011-02-14 23:26:08 +0000
@@ -141,6 +141,7 @@ protected:
   void clear_object_columns();
   int make_table_object_columns(volatile PFS_events_waits *wait);
   int make_file_object_columns(volatile PFS_events_waits *wait);
+  int make_socket_object_columns(volatile PFS_events_waits *wait);
 
   void make_row(bool thread_own_wait, PFS_thread *pfs_thread,
                 volatile PFS_events_waits *wait);


Attachment: [text/bzr-bundle] bzr/cpowers@tma-1-20110214232608-xpt1ohgp4aa8trhw.bundle
Thread
bzr push into mysql-trunk-wl5379 branch (chris.powers:3229 to 3230) WL#4896Christopher Powers15 Feb