List:Commits« Previous MessageNext Message »
From:Christopher Powers Date:December 8 2010 3:24am
Subject:bzr push into mysql-trunk-wl4896 branch (chris.powers:3211 to 3212) WL#4896
View as plain text  
 3212 Christopher Powers	2010-12-07
      WL#4896 Peformance schema Net IO
      
      Merge w/ mysql-trunk - build fixes

    modified:
      include/mysql/psi/psi.h
      include/violite.h
      sql/mysqld.cc
      storage/perfschema/ha_perfschema.cc
      storage/perfschema/pfs.cc
      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_all_instr.cc
      storage/perfschema/table_events_waits.cc
      storage/perfschema/table_setup_instruments.cc
      storage/perfschema/table_setup_instruments.h
      storage/perfschema/table_socket_instances.cc
 3211 Christopher Powers	2010-12-07
      WL#4896 Performance schema Net IO
      
      Merge with mysql-trunk: Forgot to 'bzr add' two files

    added:
      storage/perfschema/table_socket_instances.cc
      storage/perfschema/table_socket_instances.h
=== modified file 'include/mysql/psi/psi.h'
--- a/include/mysql/psi/psi.h	2010-12-07 18:55:54 +0000
+++ b/include/mysql/psi/psi.h	2010-12-08 03:24:30 +0000
@@ -265,31 +265,22 @@ enum PSI_socket_operation
 {
   /** Socket creation, as in @c socket() or @c socketpair(). */
   PSI_SOCKET_CREATE= 0,
-
   /** Socket connection, as in @c connect(), @c listen() and @c accept(). */
   PSI_SOCKET_CONNECT= 1,
-
   /** Socket bind, as in @c bind(), @c getsockname() and @c getpeername(). */
   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(). */
+  /** Generic socket send, such as @c send(), @c sendto(), @c sendmsg(). */
   PSI_SOCKET_SEND= 4,
-  /**
-    Generic socket receive, such as @c recv(), @c recvfrom), @c recvmsg(). */
+  /** Generic socket receive, such as @c recv(), @c recvfrom), @c recvmsg(). */
   PSI_SOCKET_RECV= 5,
-
   /** Generic socket seek, such as @c fseek() or @c seek(). */
   PSI_SOCKET_SEEK= 6,
-
   /** Socket options, as in @c getsockopt() and @c setsockopt(). */
   PSI_SOCKET_OPT= 7,
-
   /** Socket status, as in @c sockatmark() and @c isfdtype(). */
   PSI_SOCKET_STAT= 8,
-
   /** Socket shutdown, as in @c shutdown(). */
   PSI_SOCKET_SHUTDOWN= 9
 };

=== modified file 'include/violite.h'
--- a/include/violite.h	2010-06-07 14:01:39 +0000
+++ b/include/violite.h	2010-12-08 03:24:30 +0000
@@ -22,6 +22,7 @@
 #define	vio_violite_h_
 
 #include "my_net.h"			/* needed because of struct in_addr */
+#include <mysql/psi/mysql_socket.h>
 
 
 /* Simple vio interface in C;  The functions are implemented in violite.c */
@@ -46,6 +47,7 @@ enum enum_vio_type
 #define VIO_READ_BUFFER_SIZE 16384              /* size of read buffer */
 
 Vio*	vio_new(my_socket sd, enum enum_vio_type type, uint flags);
+Vio*  mysql_socket_vio_new(MYSQL_SOCKET mysql_socket, enum enum_vio_type type, uint flags);
 #ifdef __WIN__
 Vio* vio_new_win32pipe(HANDLE hPipe);
 Vio* vio_new_win32shared_memory(HANDLE handle_file_map,
@@ -188,6 +190,7 @@ enum SSL_type
 struct st_vio
 {
   my_socket		sd;		/* my_socket - real or imaginary */
+  MYSQL_SOCKET  mysql_socket;       /* socket handle for performance schema */
   HANDLE hPipe;
   my_bool		localhost;	/* Are we from localhost? */
   int			fcntl_mode;	/* Buffered fcntl(sd,F_GETFL) */
@@ -197,10 +200,9 @@ struct st_vio
   enum enum_vio_type	type;		/* Type of connection */
   char			desc[30];	/* String description */
   char                  *read_buffer;   /* buffer for vio_read_buff */
-  char                  *read_pos;      /* start of unfetched data in the
-                                           read buffer */
+  char   *read_pos;      /* start of unfetched data in the read buffer */
   char                  *read_end;      /* end of unfetched data */
-  /* function pointers. They are similar for socket/SSL/whatever */
+  /* Function pointers. They are similar for socket/SSL/whatever. */
   void    (*viodelete)(Vio*);
   int     (*vioerrno)(Vio*);
   size_t  (*read)(Vio*, uchar *, size_t);

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2010-12-07 18:55:54 +0000
+++ b/sql/mysqld.cc	2010-12-08 03:24:30 +0000
@@ -142,7 +142,7 @@ extern "C" {					// Because of SCO 3.2V4
 #include <sys/mman.h>
 #endif
 
-#ifdef __WIN__ 
+#ifdef __WIN__
 #include <crtdbg.h>
 #define SIGNAL_FMT "exception 0x%x"
 #else
@@ -383,7 +383,7 @@ bool in_bootstrap= FALSE;
    @brief 'grant_option' is used to indicate if privileges needs
    to be checked, in which case the lock, LOCK_grant, is used
    to protect access to the grant table.
-   @note This flag is dropped in 5.1 
+   @note This flag is dropped in 5.1
    @see grant_init()
  */
 bool volatile grant_option;
@@ -1270,18 +1270,18 @@ static void __cdecl kill_server(int sig_
   else
     sql_print_error(ER_DEFAULT(ER_GOT_SIGNAL),my_progname,sig); /* purecov: inspected */
 
-#if defined(HAVE_SMEM) && defined(__WIN__)    
-  /*    
-   Send event to smem_event_connect_request for aborting    
-   */    
-  if (!SetEvent(smem_event_connect_request))    
-  {      
+#if defined(HAVE_SMEM) && defined(__WIN__)
+  /*
+   Send event to smem_event_connect_request for aborting
+   */
+  if (!SetEvent(smem_event_connect_request))
+  {
 	  DBUG_PRINT("error",
 		("Got error: %ld from SetEvent of smem_event_connect_request",
-		 GetLastError()));    
+		 GetLastError()));
   }
-#endif  
-  
+#endif
+
   close_connections();
   if (sig != MYSQL_KILL_SIGNAL &&
       sig != 0)
@@ -2205,7 +2205,7 @@ extern "C" sig_handler abort_thread(int
   callstack.
 */
 
-static BOOL WINAPI console_event_handler( DWORD type ) 
+static BOOL WINAPI console_event_handler( DWORD type )
 {
   DBUG_ENTER("console_event_handler");
 #ifndef EMBEDDED_LIBRARY
@@ -2213,7 +2213,7 @@ static BOOL WINAPI console_event_handler
   {
      /*
        Do not shutdown before startup is finished and shutdown
-       thread is initialized. Otherwise there is a race condition 
+       thread is initialized. Otherwise there is a race condition
        between main thread doing initialization and CTRL-C thread doing
        cleanup, which can result into crash.
      */
@@ -2278,9 +2278,9 @@ LONG WINAPI my_unhandler_exception_filte
 #ifdef DEBUG_UNHANDLED_EXCEPTION_FILTER
    /*
     Unfortunately there is no clean way to debug unhandled exception filters,
-    as debugger does not stop there(also documented in MSDN) 
+    as debugger does not stop there(also documented in MSDN)
     To overcome, one could put a MessageBox, but this will not work in service.
-    Better solution is to print error message and sleep some minutes 
+    Better solution is to print error message and sleep some minutes
     until debugger is attached
   */
   wait_for_debugger(DEBUGGER_ATTACH_TIMEOUT);
@@ -2294,7 +2294,7 @@ LONG WINAPI my_unhandler_exception_filte
   {
     DWORD written;
     const char msg[] = "Got exception in exception handler!\n";
-    WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),msg, sizeof(msg)-1, 
+    WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),msg, sizeof(msg)-1,
       &written,NULL);
   }
   /*
@@ -2491,7 +2491,7 @@ You should either build a dynamically-li
 to be used with the LD_ASSUME_KERNEL environment variable. Please consult\n\
 the documentation for your distribution on how to do that.\n");
 #endif
-  
+
   if (locked_in_memory)
   {
     fprintf(stderr, "\n\
@@ -3068,7 +3068,7 @@ SHOW_VAR com_status_vars[]= {
 
 /**
   Create the name of the default general log file
-  
+
   @param[IN] buff    Location for building new string.
   @param[IN] log_ext The extension for the file (e.g .log)
   @returns Pointer to a new string containing the name
@@ -3167,13 +3167,13 @@ static int init_common_variables()
     strmake(default_logfile_name, STRING_WITH_LEN("mysql"));
   }
   else
-    strmake(default_logfile_name, glob_hostname, 
+    strmake(default_logfile_name, glob_hostname,
 	    sizeof(default_logfile_name)-5);
 
   strmake(pidfile_name, default_logfile_name, sizeof(pidfile_name)-5);
   strmov(fn_ext(pidfile_name),".pid");		// Add proper extension
 
-  
+
   /*
     The default-storage-engine entry in my_long_options should have a
     non-null default value. It was earlier intialized as
@@ -3251,7 +3251,7 @@ static int init_common_variables()
   else
   {
     opt_large_pages= 0;
-    /* 
+    /*
        Either not configured to use large pages or Linux haven't
        been compiled with large page support
     */
@@ -3427,7 +3427,7 @@ static int init_common_variables()
   global_system_variables.collation_connection=  default_charset_info;
   global_system_variables.character_set_results= default_charset_info;
   global_system_variables.character_set_client=  default_charset_info;
-  if (!(character_set_filesystem= 
+  if (!(character_set_filesystem=
         get_charset_by_csname(character_set_filesystem_name,
                               MY_CS_PRIMARY, MYF(MY_WME))))
     return 1;
@@ -3620,20 +3620,20 @@ static int init_thread_environment()
 
 #if defined(HAVE_OPENSSL) && !defined(HAVE_YASSL)
 static unsigned long openssl_id_function()
-{ 
+{
   return (unsigned long) pthread_self();
-} 
+}
 
 
 static openssl_lock_t *openssl_dynlock_create(const char *file, int line)
-{ 
+{
   openssl_lock_t *lock= new openssl_lock_t;
   mysql_rwlock_init(key_rwlock_openssl, &lock->lock);
   return lock;
 }
 
 
-static void openssl_dynlock_destroy(openssl_lock_t *lock, const char *file, 
+static void openssl_dynlock_destroy(openssl_lock_t *lock, const char *file,
 				    int line)
 {
   mysql_rwlock_destroy(&lock->lock);
@@ -3653,7 +3653,7 @@ static void openssl_lock_function(int mo
 }
 
 
-static void openssl_lock(int mode, openssl_lock_t *lock, const char *file, 
+static void openssl_lock(int mode, openssl_lock_t *lock, const char *file,
 			 int line)
 {
   int err;
@@ -3678,7 +3678,7 @@ static void openssl_lock(int mode, opens
     sql_print_error("Fatal: OpenSSL interface problem (mode=0x%x)", mode);
     abort();
   }
-  if (err) 
+  if (err)
   {
     sql_print_error("Fatal: can't %s OpenSSL lock", what);
     abort();
@@ -4008,9 +4008,9 @@ will be ignored as the --log-bin option
 
   if (opt_bin_log)
   {
-    /* Reports an error and aborts, if the --log-bin's path 
+    /* Reports an error and aborts, if the --log-bin's path
        is a directory.*/
-    if (opt_bin_logname && 
+    if (opt_bin_logname &&
         opt_bin_logname[strlen(opt_bin_logname) - 1] == FN_LIBCHAR)
     {
       sql_print_error("Path '%s' is a directory name, please specify \
@@ -4018,10 +4018,10 @@ a file name for --log-bin option", opt_b
       unireg_abort(1);
     }
 
-    /* Reports an error and aborts, if the --log-bin-index's path 
+    /* Reports an error and aborts, if the --log-bin-index's path
        is a directory.*/
-    if (opt_binlog_index_name && 
-        opt_binlog_index_name[strlen(opt_binlog_index_name) - 1] 
+    if (opt_binlog_index_name &&
+        opt_binlog_index_name[strlen(opt_binlog_index_name) - 1]
         == FN_LIBCHAR)
     {
       sql_print_error("Path '%s' is a directory name, please specify \
@@ -4149,7 +4149,7 @@ a file name for --log-bin-index option",
 
   /* if the errmsg.sys is not loaded, terminate to maintain behaviour */
   if (!DEFAULT_ERRMSGS[0][0])
-    unireg_abort(1);  
+    unireg_abort(1);
 
   /* We have to initialize the storage engines before CSV logging */
   if (ha_init())
@@ -4361,7 +4361,7 @@ static void handle_connections_methods()
       handler_count--;
     }
   }
-#endif 
+#endif
 
   while (handler_count > 0)
     mysql_cond_wait(&COND_handler_count, &LOCK_thread_count);
@@ -4633,7 +4633,7 @@ int mysqld_main(int argc, char **argv)
 
 #ifndef DBUG_OFF
   test_lc_time_sz();
-  srand(time(NULL)); 
+  srand(time(NULL));
 #endif
 
   /*
@@ -4811,7 +4811,7 @@ int mysqld_main(int argc, char **argv)
 #endif /* _WIN32 || HAVE_SMEM */
 
   /* (void) pthread_attr_destroy(&connection_attrib); */
-  
+
   DBUG_PRINT("quit",("Exiting main thread"));
 
 #ifndef __WIN__
@@ -4919,10 +4919,10 @@ default_service_handling(char **argv,
   pos= add_quoted_string(path_and_service, file_path, end);
   if (*extra_opt)
   {
-    /* 
-     Add option after file_path. There will be zero or one extra option.  It's 
+    /*
+     Add option after file_path. There will be zero or one extra option.  It's
      assumed to be --defaults-file=file but isn't checked.  The variable (not
-     the option name) should be quoted if it contains a string.  
+     the option name) should be quoted if it contains a string.
     */
     *pos++= ' ';
     if (opt_delim= strchr(extra_opt, '='))
@@ -4932,7 +4932,7 @@ default_service_handling(char **argv,
     }
     else
       opt_delim= extra_opt;
-    
+
     pos= add_quoted_string(pos, opt_delim, end);
   }
   /* We must have servicename last */
@@ -5921,8 +5921,8 @@ struct my_option my_long_options[]=
    "The value has to be a multiple of 256.",
    &opt_binlog_rows_event_max_size, &opt_binlog_rows_event_max_size,
    0, GET_ULONG, REQUIRED_ARG,
-   /* def_value */ 1024, /* min_value */  256, /* max_value */ ULONG_MAX, 
-   /* sub_size */     0, /* block_size */ 256, 
+   /* def_value */ 1024, /* min_value */  256, /* max_value */ ULONG_MAX,
+   /* sub_size */     0, /* block_size */ 256,
    /* app_type */ 0
   },
 #ifndef DISABLE_GRANT_OPTIONS
@@ -6053,7 +6053,7 @@ struct my_option my_long_options[]=
    REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"master-retry-count", OPT_MASTER_RETRY_COUNT,
    "The number of tries the slave will make to connect to the master before giving up. "
-   "Deprecated option, use 'CHANGE MASTER TO master_retry_count = <num>' instead.", 
+   "Deprecated option, use 'CHANGE MASTER TO master_retry_count = <num>' instead.",
    &master_retry_count, &master_retry_count, 0, GET_ULONG,
    REQUIRED_ARG, 3600*24, 0, 0, 0, 0, 0},
 #ifdef HAVE_REPLICATION
@@ -6269,7 +6269,7 @@ static int show_slave_running(THD *thd,
   var->type= SHOW_MY_BOOL;
   mysql_mutex_lock(&LOCK_active_mi);
   var->value= buff;
-  *((my_bool *)buff)= (my_bool) (active_mi && 
+  *((my_bool *)buff)= (my_bool) (active_mi &&
                                  active_mi->slave_running == MYSQL_SLAVE_RUN_CONNECT &&
                                  active_mi->rli->slave_running);
   mysql_mutex_unlock(&LOCK_active_mi);
@@ -6322,7 +6322,7 @@ static int show_slave_last_heartbeat(THD
   {
     var->type= SHOW_CHAR;
     var->value= buff;
-    thd->variables.time_zone->gmt_sec_to_TIME(&received_heartbeat_time, 
+    thd->variables.time_zone->gmt_sec_to_TIME(&received_heartbeat_time,
       active_mi->last_heartbeat);
     my_datetime_to_str(&received_heartbeat_time, buff);
   }
@@ -6540,7 +6540,7 @@ static int show_ssl_ctx_get_session_cach
 }
 
 /*
-   Functions relying on SSL 
+   Functions relying on SSL
    Note: In the show_ssl_* functions, we need to check if we have a
          valid vio-object since this isn't always true, specifically
          when session_status or global_status is requested from
@@ -6986,7 +6986,7 @@ static int mysql_init_variables(void)
   character_set_filesystem_name= (char*) "binary";
   lc_messages= (char*) "en_US";
   lc_time_names_name= (char*) "en_US";
-  
+
   /* Variables that depends on compile options */
 #ifndef DBUG_OFF
   default_dbug_option=IF_WIN("d:t:i:O,\\mysqld.trace",
@@ -7272,13 +7272,13 @@ mysqld_get_one_option(int optid,
     break;
   case (int) OPT_BIND_ADDRESS:
     {
-      struct addrinfo *res_lst, hints;    
+      struct addrinfo *res_lst, hints;
 
       bzero(&hints, sizeof(struct addrinfo));
       hints.ai_socktype= SOCK_STREAM;
       hints.ai_protocol= IPPROTO_TCP;
 
-      if (getaddrinfo(argument, NULL, &hints, &res_lst) != 0) 
+      if (getaddrinfo(argument, NULL, &hints, &res_lst) != 0)
       {
         sql_print_error("Can't start server: cannot resolve hostname!");
         return 1;
@@ -7637,7 +7637,7 @@ fn_format_relative_to_data_home(char * t
 /**
   Test a file path to determine if the path is compatible with the secure file
   path restriction.
- 
+
   @param path null terminated character string
 
   @return
@@ -7699,7 +7699,7 @@ static int fix_paths(void)
   opt_plugin_dir_ptr= opt_plugin_dir;
 
   my_realpath(mysql_unpacked_real_data_home, mysql_real_data_home, MYF(0));
-  mysql_unpacked_real_data_home_len= 
+  mysql_unpacked_real_data_home_len=
     (int) strlen(mysql_unpacked_real_data_home);
   if (mysql_unpacked_real_data_home[mysql_unpacked_real_data_home_len-1] == FN_LIBCHAR)
     --mysql_unpacked_real_data_home_len;
@@ -7755,7 +7755,7 @@ static int fix_paths(void)
       opt_secure_file_priv= secure_file_real_path;
     }
   }
-  
+
   return 0;
 }
 
@@ -8127,6 +8127,9 @@ void init_server_psi_keys(void)
 
   count= array_elements(all_server_files);
   PSI_server->register_file(category, all_server_files, count);
+
+  count= array_elements(all_server_sockets);
+  PSI_server->register_socket(category, all_server_sockets, count);
 }
 
 #endif /* HAVE_PSI_INTERFACE */

=== modified file 'storage/perfschema/ha_perfschema.cc'
--- a/storage/perfschema/ha_perfschema.cc	2010-12-07 18:55:54 +0000
+++ b/storage/perfschema/ha_perfschema.cc	2010-12-08 03:24:30 +0000
@@ -139,7 +139,7 @@ static struct st_mysql_show_var pfs_stat
   {"Performance_schema_file_handles_lost",
     (char*) &file_handle_lost, SHOW_LONG},
   {"Performance_schema_socket_instances_lost",
-    (char*) &socket_instances_lost, SHOW_LONG},
+    (char*) &socket_lost, SHOW_LONG},
   {"Performance_schema_locker_lost",
     (char*) &locker_lost, SHOW_LONG},
   /* table shares, can be flushed */

=== modified file 'storage/perfschema/pfs.cc'
--- a/storage/perfschema/pfs.cc	2010-12-07 18:55:54 +0000
+++ b/storage/perfschema/pfs.cc	2010-12-08 03:24:30 +0000
@@ -2422,7 +2422,7 @@ get_thread_socket_locker_v1(PSI_socket_l
 
     if (flag_events_waits_current)
     {
-      if (unlikely(pfs_thread->m_wait_waits_count >= WAIT_STACK_SIZE))
+      if (unlikely(pfs_thread->m_events_waits_count >= WAIT_STACK_SIZE))
       {
         locker_lost++;
         return NULL;
@@ -2466,7 +2466,6 @@ get_thread_socket_locker_v1(PSI_socket_l
 
   state->m_flags= flags;
   state->m_socket= socket;
-  state->m_class= klass;
   state->m_operation= op;
   return reinterpret_cast<PSI_socket_locker*> (state);
 }
@@ -3311,86 +3310,130 @@ static void start_socket_wait_v1(PSI_soc
 
 static void end_socket_wait_v1(PSI_socket_locker *locker, size_t count);
 
+/**
+  Implementation of the socket instrumentation interface.
+  @sa PSI_v1::start_socket_wait.
+*/
 static void start_socket_wait_v1(PSI_socket_locker *locker,
-                                     size_t count,
-                                     const char *src_file,
-                                     uint src_line)
+                                 size_t count,
+                                 const char *src_file,
+                                 uint src_line)
 {
-  PFS_wait_locker *pfs_locker= reinterpret_cast<PFS_wait_locker*> (locker);
-  DBUG_ASSERT(pfs_locker != NULL);
+  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;
+
+  if (flags & STATE_FLAG_TIMED)
+  {
+    timer_start= get_timer_raw_value_and_function(wait_timer, & state->m_timer);
+    state->m_timer_start= timer_start;
+  }
 
-  PFS_events_waits *wait=&pfs_locker->m_waits_current;
-  if (wait->m_timer_state == TIMER_STATE_STARTING)
+  if (flags & STATE_FLAG_WAIT)
   {
-    wait->m_timer_start= get_timer_value(pfs_locker->m_timer_name);
-    wait->m_timer_state= TIMER_STATE_STARTED;
+    PFS_events_waits *wait= reinterpret_cast<PFS_events_waits*> (state->m_wait);
+    DBUG_ASSERT(wait != NULL);
+
+    wait->m_timer_start= timer_start;
+    wait->m_source_file= src_file;
+    wait->m_source_line= src_line;
+    wait->m_number_of_bytes= count;
   }
-  wait->m_source_file= src_file;
-  wait->m_source_line= src_line;
-  wait->m_number_of_bytes= count;
 }
 
+/**
+  Implementation of the socket instrumentation interface.
+  @sa PSI_v1::end_socket_wait.
+*/
 static void end_socket_wait_v1(PSI_socket_locker *locker, size_t count)
 {
-  PFS_wait_locker *pfs_locker= reinterpret_cast<PFS_wait_locker*> (locker);
-  DBUG_ASSERT(pfs_locker != NULL);
-  PFS_events_waits *wait= &pfs_locker->m_waits_current;
+  PSI_socket_locker_state *state= reinterpret_cast<PSI_socket_locker_state*> (locker);
+  DBUG_ASSERT(state != NULL);
+  ulonglong timer_end= 0;
+  ulonglong wait_time= 0;
 
-  wait->m_number_of_bytes= count;
-  if (wait->m_timer_state == TIMER_STATE_STARTED)
+  PFS_socket *socket= reinterpret_cast<PFS_socket *> (state->m_socket);
+  DBUG_ASSERT(socket != NULL);
+  PFS_thread *thread= reinterpret_cast<PFS_thread *> (state->m_thread);
+
+  register uint flags= state->m_flags;
+
+  if (flags & STATE_FLAG_TIMED)
   {
-    wait->m_timer_end= get_timer_value(pfs_locker->m_timer_name);
-    wait->m_timer_state= TIMER_STATE_TIMED;
+    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);
+  }
+  else
+  {
+    /* Aggregate to EVENTS_WAITS_SUMMARY_BY_INSTANCE (counted) */
+    socket->m_wait_stat.aggregate_counted();
   }
-  if (flag_events_waits_history)
-    insert_events_waits_history(wait->m_thread, wait);
-  if (flag_events_waits_history_long)
-    insert_events_waits_history_long(wait);
 
-  PFS_single_stat_chain *stat;
-  PFS_socket *socket= pfs_locker->m_target.m_socket;
+  if (flags & STATE_FLAG_THREAD)
+  {
+    DBUG_ASSERT(thread != NULL);
 
-  ulonglong wait_time= wait->m_timer_end - wait->m_timer_start;
-  aggregate_single_stat_chain(&socket->m_wait_stat, wait_time);
-  stat= find_per_thread_socket_class_wait_stat(wait->m_thread,
-                                               socket->m_class);
-  aggregate_single_stat_chain(stat, wait_time);
+    PFS_single_stat *event_name_array;
+    event_name_array= thread->m_instr_class_wait_stats;
+    uint index= socket->m_class->m_event_name_index;
 
-  PFS_socket_class *klass= socket->m_class;
+    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();
+    }
 
-  switch(wait->m_operation)
+    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--;
+    }
+  }
+
+  switch(state->m_operation)
   {
-  case OPERATION_TYPE_SOCKETCREATE:
-    socket->m_socket_stat.m_open_count++;
-    klass->m_socket_stat.m_open_count++;
+  case PSI_SOCKET_CREATE:
+//  socket->m_socket_stat.m_open_count++;
+//  klass->m_socket_stat.m_open_count++;
     break;
-  case OPERATION_TYPE_SOCKETSEND:
-    socket->m_socket_stat.m_count_send++;
-    socket->m_socket_stat.m_send_bytes+= count;
-    klass->m_socket_stat.m_send_bytes+= count;
+  case PSI_SOCKET_SEND:
+    socket->m_socket_stat.m_io_stat.aggregate_write(count);
     break;
-  case OPERATION_TYPE_SOCKETRECV:
-    socket->m_socket_stat.m_count_recv++;
-    socket->m_socket_stat.m_recv_bytes+= count;
-    klass->m_socket_stat.m_recv_bytes+= count;
+  case PSI_SOCKET_RECV:
+    socket->m_socket_stat.m_io_stat.aggregate_read(count);
     break;
-  case OPERATION_TYPE_SOCKETCLOSE:
+  case PSI_SOCKET_CLOSE:
     /** close() frees the file descriptor, shutdown() does not */
-    release_socket(pfs_locker->m_target.m_socket);
-    destroy_socket(pfs_locker->m_target.m_socket);
+    release_socket(socket);
+    destroy_socket(socket);
     break;
-  case OPERATION_TYPE_SOCKETCONNECT:
-  case OPERATION_TYPE_SOCKETBIND:
-  case OPERATION_TYPE_SOCKETSTAT:
-  case OPERATION_TYPE_SOCKETOPT:
-  case OPERATION_TYPE_SOCKETSEEK:
-  case OPERATION_TYPE_SOCKETSHUTDOWN:
+  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_thread->m_wait_locker_count--;
 }
 
 static void set_socket_descriptor_v1(PSI_socket *socket, uint fd)
@@ -3401,7 +3444,7 @@ static void set_socket_descriptor_v1(PSI
 }
 
 static void set_socket_address_v1(PSI_socket *socket,
-                                      const struct sockaddr * socket_addr)
+                                  const struct sockaddr * socket_addr)
 {
   DBUG_ASSERT(socket);
   PFS_socket *pfs= reinterpret_cast<PFS_socket*>(socket);
@@ -3432,8 +3475,8 @@ static void set_socket_address_v1(PSI_so
 }
 
 static void set_socket_info_v1(PSI_socket *socket,
-                                  uint fd,
-                                  const struct sockaddr * addr)
+                               uint fd,
+                               const struct sockaddr * addr)
 {
   DBUG_ASSERT(socket);
   PFS_socket *pfs= reinterpret_cast<PFS_socket*>(socket);

=== modified file 'storage/perfschema/pfs_instr.cc'
--- a/storage/perfschema/pfs_instr.cc	2010-12-07 18:55:54 +0000
+++ b/storage/perfschema/pfs_instr.cc	2010-12-08 03:24:30 +0000
@@ -65,9 +65,9 @@ ulong table_max;
 /** Number of table instances lost. @sa table_array */
 ulong table_lost;
 /** Size of the socket instances array. @sa socket_array */
-ulong socket_instances_max;
+ulong socket_max;
 /** Number of socket instances lost. @sa socket_array */
-ulong socket_instances_lost;
+ulong socket_lost;
 /** Number of EVENTS_WAITS_HISTORY records per thread. */
 ulong events_waits_history_per_thread;
 /** Number of locker lost. @sa LOCKER_STACK_SIZE. */
@@ -125,8 +125,8 @@ PFS_table *table_array= NULL;
 
 /**
   Socket instrumentation instances array.
-  @sa socket_instances_max
-  @sa socket_instances_lost
+  @sa socket_max
+  @sa socket_lost
 */
 PFS_socket *socket_array= NULL;
 
@@ -175,8 +175,8 @@ int init_instruments(const PFS_global_pa
   table_lost= 0;
   thread_max= param->m_thread_sizing;
   thread_lost= 0;
-  socket_instances_max= param->m_socket_sizing;
-  socket_instances_lost= 0;
+  socket_max= param->m_socket_sizing;
+  socket_lost= 0;
 
   events_waits_history_per_thread= param->m_events_waits_history_sizing;
   thread_history_sizing= param->m_thread_sizing
@@ -239,9 +239,9 @@ int init_instruments(const PFS_global_pa
       return 1;
   }
 
-  if (socket_instances_max > 0)
+  if (socket_max > 0)
   {
-    socket_array= PFS_MALLOC_ARRAY(socket_instances_max, PFS_socket, MYF(MY_ZEROFILL));
+    socket_array= PFS_MALLOC_ARRAY(socket_max, PFS_socket, MYF(MY_ZEROFILL));
     if (unlikely(socket_array == NULL))
       return 1;
   }
@@ -333,7 +333,7 @@ void cleanup_instruments(void)
   table_max= 0;
   pfs_free(socket_array);
   socket_array= NULL;
-  socket_instances_max= 0;
+  socket_max= 0;
   pfs_free(thread_array);
   thread_array= NULL;
   thread_max= 0;
@@ -750,9 +750,9 @@ const char *sanitize_file_name(const cha
     intptr offset= (ptr - first) % sizeof(PFS_file);
     intptr valid_offset= my_offsetof(PFS_file, m_filename[0]);
     if (likely(offset == valid_offset))
-    {   
+    {
       return unsafe;
-    }   
+    }
   }
   return NULL;
 }
@@ -1078,9 +1078,9 @@ void destroy_table(PFS_table *pfs)
 PFS_socket* create_socket(PFS_socket_class *klass, const void *identity)
 {
   PFS_scan scan;
-  uint random= randomized_index(identity, socket_instances_max);
+  uint random= randomized_index(identity, socket_max);
 
-  for (scan.init(random, socket_instances_max);
+  for (scan.init(random, socket_max);
        scan.has_pass();
        scan.next_pass())
   {
@@ -1103,7 +1103,7 @@ PFS_socket* create_socket(PFS_socket_cla
     }
   }
 
-  socket_instances_lost++;
+  socket_lost++;
   return NULL;
 }
 
@@ -1114,7 +1114,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--;
 }
 
 /**
@@ -1167,7 +1167,7 @@ static void reset_file_waits_by_instance
 static void reset_socket_waits_by_instance(void)
 {
   PFS_socket *pfs= socket_array;
-  PFS_socket *pfs_last= socket_array + sockets_max;
+  PFS_socket *pfs_last= socket_array + socket_max;
 
   for ( ; pfs < pfs_last; pfs++)
     pfs->m_wait_stat.reset();

=== modified file 'storage/perfschema/pfs_instr.h'
--- a/storage/perfschema/pfs_instr.h	2010-12-07 18:55:54 +0000
+++ b/storage/perfschema/pfs_instr.h	2010-12-08 03:24:30 +0000
@@ -348,8 +348,8 @@ extern long file_handle_max;
 extern ulong file_handle_lost;
 extern ulong table_max;
 extern ulong table_lost;
-extern ulong socket_instances_max;
-extern ulong socket_instances_lost;
+extern ulong socket_max;
+extern ulong socket_lost;
 extern ulong events_waits_history_per_thread;
 extern ulong locker_lost;
 

=== modified file 'storage/perfschema/pfs_instr_class.cc'
--- a/storage/perfschema/pfs_instr_class.cc	2010-12-07 18:55:54 +0000
+++ b/storage/perfschema/pfs_instr_class.cc	2010-12-08 03:24:30 +0000
@@ -155,9 +155,9 @@ void init_event_name_sizing(const PFS_gl
   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;
-  table_class_start= file_class_start + param->m_file_class_sizing;
-  socket_class_start= table_class_start + param->m_table_class_sizing;
-  max_instrument_class= socket_class_start + 1; /* global table io */
+  socket_class_start= file_class_start + param->m_file_class_sizing;
+  table_class_start= socket_class_start + param->m_socket_class_sizing;
+  max_instrument_class= table_class_start + 1; /* global table io */
 
   memcpy(global_table_io_class.m_name, "wait/io/table/sql/handler", 25);
   global_table_io_class.m_name_length= 25;
@@ -796,6 +796,7 @@ PFS_file_class *find_file_class(PFS_file
 PFS_file_class *sanitize_file_class(PFS_file_class *unsafe)
 {
   SANITIZE_ARRAY_BODY(PFS_file_class, file_class_array, file_class_max, unsafe);
+}
 
 /**
   Register a socket instrumentation metadata.
@@ -832,7 +833,7 @@ 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;
+    entry->m_singleton= NULL;
     PFS_atomic::add_u32(&socket_class_allocated_count, 1);
     return (index + 1);
   }
@@ -856,7 +857,7 @@ PFS_socket_class *find_socket_class(PFS_
 
 PFS_socket_class *sanitize_socket_class(PFS_socket_class *unsafe)
 {
-  SANITIZE_ARRAY_BODY(socket_class_array, socket_class_max, unsafe);
+  SANITIZE_ARRAY_BODY(PFS_socket_class, socket_class_array, socket_class_max, unsafe);
 }
 
 PFS_instr_class *find_table_class(uint index)

=== modified file 'storage/perfschema/pfs_instr_class.h'
--- a/storage/perfschema/pfs_instr_class.h	2010-12-07 18:55:54 +0000
+++ b/storage/perfschema/pfs_instr_class.h	2010-12-08 03:24:30 +0000
@@ -266,6 +266,17 @@ struct PFS_file_class : public PFS_instr
   PFS_file *m_singleton;
 };
 
+/** Instrumentation metadata for a socket. */
+struct PFS_socket_class : public PFS_instr_class
+{
+  /** Socket usage statistics. */
+  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);
 
 int init_sync_class(uint mutex_class_sizing,

=== modified file 'storage/perfschema/pfs_stat.h'
--- a/storage/perfschema/pfs_stat.h	2010-12-07 18:55:54 +0000
+++ b/storage/perfschema/pfs_stat.h	2010-12-08 03:24:30 +0000
@@ -222,31 +222,28 @@ struct PFS_table_stat
   }
 };
 
-/** Statistics for SOCKET usage. */
-struct PFS_socket_stat
+/** Statistics for SOCKET IO usage. */
+struct PFS_socket_io_stat
 {
-  /** Number of current open sockets. */
-  ulong m_open_count;
-  /** Count of RECV operations. */
-  ulonglong m_count_recv;
-  /** Count of SEND operations. */
-  ulonglong m_count_send;
-  /** Number of bytes received. */
-  ulonglong m_recv_bytes;
-  /** Number of bytes sent. */
-  ulonglong m_send_bytes;
+  /** 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;
 
   /** Reset socket statistics. */
   inline void reset(void)
   {
-    m_open_count= 0;
-    m_count_recv= 0;
-    m_count_send= 0;
-    m_count_recv_bytes= 0;
-    m_count_send_bytes= 0;
+    m_count_read= 0;
+    m_count_write= 0;
+    m_read_bytes= 0;
+    m_write_bytes= 0;
   }
 
-  inline void aggregate(const PFS_file_io_stat *stat)
+  inline void aggregate(const PFS_socket_io_stat *stat)
   {
     m_count_read+= stat->m_count_read;
     m_count_write+= stat->m_count_write;
@@ -254,32 +251,27 @@ struct PFS_socket_stat
     m_write_bytes+= stat->m_write_bytes;
   }
 
-  inline void aggregate_recv(ulonglong bytes)
+  inline void aggregate_read(ulonglong bytes)
   {
-    m_count_recv++;
-    m_recv_bytes+= bytes;
+    m_count_read++;
+    m_read_bytes+= bytes;
   }
 
-  inline void aggregate_send(ulonglong bytes)
+  inline void aggregate_write(ulonglong bytes)
   {
-    m_count_send++;
-    m_send_bytes+= bytes;
+    m_count_write++;
+    m_write_bytes+= bytes;
   }
-
 };
 
-/**
-  Reset socket statistic.
-  @param stat                         the statistics to reset
-*/
-inline void reset_socket_stat(PFS_socket_stat *stat)
+/** Statistics for SOCKET usage. */
+struct PFS_socket_stat
 {
-  stat->m_open_count= 0;
-  stat->m_count_recv= 0;
-  stat->m_count_send= 0;
-  stat->m_recv_bytes= 0;
-  stat->m_send_bytes= 0;
-}
+  /** Number of current open sockets. //TBD Not relevant */
+  ulong m_open_count;
+  /** Socket IO statistics. */
+  PFS_socket_io_stat m_io_stat;
+};
 
 
 /** @} */

=== modified file 'storage/perfschema/table_all_instr.cc'
--- a/storage/perfschema/table_all_instr.cc	2010-12-07 18:55:54 +0000
+++ b/storage/perfschema/table_all_instr.cc	2010-12-08 03:24:30 +0000
@@ -96,7 +96,7 @@ int table_all_instr::rnd_next(void)
       }
       break;
     case pos_all_instr::VIEW_SOCKET:
-      for ( ; m_pos.m_index_2 < socket_instances_max; m_pos.m_index_2++)
+      for ( ; m_pos.m_index_2 < socket_max; m_pos.m_index_2++)
       {
         socket= &socket_array[m_pos.m_index_2];
         if (socket->m_lock.is_populated())
@@ -161,7 +161,7 @@ int table_all_instr::rnd_pos(const void
     }
     break;
   case pos_all_instr::VIEW_SOCKET:
-    DBUG_ASSERT(m_pos.m_index_2 < socket_instances_max);
+    DBUG_ASSERT(m_pos.m_index_2 < socket_max);
     socket= &socket_array[m_pos.m_index_2];
     if (socket->m_lock.is_populated())
     {

=== modified file 'storage/perfschema/table_events_waits.cc'
--- a/storage/perfschema/table_events_waits.cc	2010-12-07 18:55:54 +0000
+++ b/storage/perfschema/table_events_waits.cc	2010-12-08 03:24:30 +0000
@@ -395,7 +395,7 @@ static const LEX_STRING operation_names_
   { C_STRING_WITH_LEN("fetch") },
   { C_STRING_WITH_LEN("insert") }, /* write row */
   { C_STRING_WITH_LEN("update") }, /* update row */
-  { C_STRING_WITH_LEN("delete") },  /* delete row */
+  { C_STRING_WITH_LEN("delete") }, /* delete row */
 
   /* Socket operations */
   { C_STRING_WITH_LEN("create") },
@@ -410,7 +410,6 @@ static const LEX_STRING operation_names_
   { C_STRING_WITH_LEN("shutdown") }
 };
 
-
 int table_events_waits_common::read_row_values(TABLE *table,
                                                unsigned char *buf,
                                                Field **fields,
@@ -419,8 +418,8 @@ int table_events_waits_common::read_row_
   Field *f;
   const LEX_STRING *operation;
 
-  compile_time_assert(COUNT_OPERATION_TYPE ==
-                      array_elements(operation_names_map));
+//  compile_time_assert(COUNT_OPERATION_TYPE ==
+//                      array_elements(operation_names_map));
 
   if (unlikely(! m_row_exists))
     return HA_ERR_RECORD_DELETED;

=== modified file 'storage/perfschema/table_setup_instruments.cc'
--- a/storage/perfschema/table_setup_instruments.cc	2010-12-07 18:55:54 +0000
+++ b/storage/perfschema/table_setup_instruments.cc	2010-12-08 03:24:30 +0000
@@ -89,6 +89,7 @@ int table_setup_instruments::rnd_next(vo
   PFS_rwlock_class *rwlock_class;
   PFS_cond_class *cond_class;
   PFS_file_class *file_class;
+  PFS_instr_class *table_class;
   PFS_socket_class *socket_class;
 
   for (m_pos.set_at(&m_next_pos);

=== modified file 'storage/perfschema/table_setup_instruments.h'
--- a/storage/perfschema/table_setup_instruments.h	2010-07-23 17:08:41 +0000
+++ b/storage/perfschema/table_setup_instruments.h	2010-12-08 03:24:30 +0000
@@ -53,7 +53,8 @@ struct pos_setup_instruments : public PF
   static const uint VIEW_THREAD= 4;
   static const uint VIEW_FILE= 5;
   static const uint VIEW_TABLE= 6;
-  static const uint LAST_VIEW= 6;
+  static const uint VIEW_SOCKET= 7;
+  static const uint LAST_VIEW= 7;
 
   pos_setup_instruments()
     : PFS_double_index(FIRST_VIEW, 1)

=== modified file 'storage/perfschema/table_socket_instances.cc'
--- a/storage/perfschema/table_socket_instances.cc	2010-12-07 19:50:08 +0000
+++ b/storage/perfschema/table_socket_instances.cc	2010-12-08 03:24:30 +0000
@@ -80,6 +80,7 @@ table_socket_instances::m_share=
   &table_socket_instances::create,
   NULL, /* write_row */
   NULL, /* delete_all_rows */
+  NULL, /* get_row_count */
   1000, /* records */
   sizeof(PFS_simple_index),
   &m_table_lock,
@@ -108,7 +109,7 @@ int table_socket_instances::rnd_next(voi
   PFS_socket *pfs;
 
   for (m_pos.set_at(&m_next_pos);
-       m_pos.m_index < socket_instances_max;
+       m_pos.m_index < socket_max;
        m_pos.next())
   {
     pfs= &socket_array[m_pos.m_index];
@@ -128,7 +129,7 @@ int table_socket_instances::rnd_pos(cons
   PFS_socket *pfs;
 
   set_position(pos);
-  DBUG_ASSERT(m_pos.m_index < socket_instances_max);
+  DBUG_ASSERT(m_pos.m_index < socket_max);
   pfs= &socket_array[m_pos.m_index];
 
   if (! pfs->m_lock.is_populated())
@@ -159,8 +160,8 @@ void table_socket_instances::make_row(PF
   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_recv_bytes;
-  m_row.m_bytes_write=        pfs->m_socket_stat.m_send_bytes;
+  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;


Attachment: [text/bzr-bundle] bzr/chris.powers@oracle.com-20101208032430-1igi3mu7hk25gymb.bundle
Thread
bzr push into mysql-trunk-wl4896 branch (chris.powers:3211 to 3212) WL#4896Christopher Powers8 Dec