From: Christopher Powers Date: August 9 2011 7:27pm Subject: bzr push into mysql-trunk branch (chris.powers:3351 to 3353) WL#4896 List-Archive: http://lists.mysql.com/commits/140556 Message-Id: <201108091927.p79JRRWW007947@acsmt358.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3353 Christopher Powers 2011-08-09 WL#4896 "Performance Schema Net IO" Include number of bytes for socket operations in EVENTS_WAITS_HISTORY tables. modified: storage/perfschema/table_events_waits.cc 3352 Christopher Powers 2011-08-09 WL#4896 "Performance Schema Net IO" Refined IDLE wait times by pushing timing of IDLE events further down into the packet processing layer. modified: include/mysql/psi/psi.h include/mysql_com.h sql/net_serv.cc sql/sql_parse.cc storage/perfschema/pfs.cc storage/perfschema/pfs_instr.cc 3351 Christopher Powers 2011-08-05 WL#4896 "Performance Schema Net IO" Disable instrumenting IDLE wait times for testing. modified: mysql-test/suite/perfschema/include/socket_summary_check.inc sql/sql_parse.cc === modified file 'include/mysql/psi/psi.h' --- a/include/mysql/psi/psi.h 2011-08-05 00:20:04 +0000 +++ b/include/mysql/psi/psi.h 2011-08-09 19:09:51 +0000 @@ -953,9 +953,6 @@ struct PSI_socket_locker_state_v1 int m_src_line; /** Internal data. */ void *m_wait; - /** True if socket state is IDLE. */ - my_bool m_idle; - }; /* Using typedef to make reuse between PSI_v1 and PSI_v2 easier later. */ === modified file 'include/mysql_com.h' --- a/include/mysql_com.h 2011-06-30 15:50:45 +0000 +++ b/include/mysql_com.h 2011-08-09 19:09:51 +0000 @@ -302,7 +302,7 @@ typedef struct st_net { unsigned int *return_status; unsigned char reading_or_writing; char save_char; - my_bool unused1; /* Please remove with the next incompatible ABI change. */ + my_bool mysql_socket_idle; /* Perfschema: True when socket state is IDLE */ my_bool unused2; /* Please remove with the next incompatible ABI change */ my_bool compress; my_bool unused3; /* Please remove with the next incompatible ABI change. */ === modified file 'sql/net_serv.cc' --- a/sql/net_serv.cc 2011-08-05 00:20:04 +0000 +++ b/sql/net_serv.cc 2011-08-09 19:09:51 +0000 @@ -44,6 +44,7 @@ #include #include #include "probes_mysql.h" +#include "mysql/psi/mysql_idle.h" #ifdef EMBEDDED_LIBRARY #undef MYSQL_SERVER @@ -103,6 +104,7 @@ my_bool my_net_init(NET *net, Vio* vio) net->where_b = net->remain_in_buf=0; net->last_errno=0; net->unused= 0; + net->mysql_socket_idle= FALSE; if (vio) { @@ -711,12 +713,36 @@ static my_bool net_read_packet_header(NE { uchar pkt_nr; size_t count= NET_HEADER_SIZE; + MYSQL_IDLE_WAIT_VARIABLES(idle_locker, idle_state) /* no ; */ if (net->compress) count+= COMP_HEADER_SIZE; - if (net_read_raw_loop(net, count)) - return TRUE; + /* + If the server is IDLE, waiting for the next command: + - do not time the wait on the socket + - time the wait as IDLE server time instead. + */ + #ifdef HAVE_PSI_INTERFACE + if (net->mysql_socket_idle) + { + mysql_socket_set_state(net->vio->mysql_socket, PSI_SOCKET_STATE_IDLE); + MYSQL_START_IDLE_WAIT(idle_locker, &idle_state); + + my_bool rc= net_read_raw_loop(net, count); + + MYSQL_END_IDLE_WAIT(idle_locker); + mysql_socket_set_state(net->vio->mysql_socket, PSI_SOCKET_STATE_ACTIVE); + + if (rc) + return TRUE; + } + else + #endif + { + if (net_read_raw_loop(net, count)) + return TRUE; + } DBUG_DUMP("packet_header", net->buff + net->where_b, NET_HEADER_SIZE); === modified file 'sql/sql_parse.cc' --- a/sql/sql_parse.cc 2011-08-05 23:59:49 +0000 +++ b/sql/sql_parse.cc 2011-08-09 19:09:51 +0000 @@ -96,7 +96,6 @@ #include "mysql/psi/mysql_statement.h" #include "sql_bootstrap.h" #include "opt_explain.h" -#include "mysql/psi/mysql_idle.h" #define FLAGSTR(V,F) ((V)&(F)?#F" ":"") @@ -805,7 +804,6 @@ bool do_command(THD *thd) ulong packet_length; NET *net= &thd->net; enum enum_server_command command; - //MYSQL_IDLE_WAIT_VARIABLES(idle_locker, idle_state) /* no ; */ DBUG_ENTER("do_command"); @@ -848,18 +846,15 @@ bool do_command(THD *thd) */ DEBUG_SYNC(thd, "before_do_command_net_read"); - /* - The server is now IDLE, waiting for the next command: - - do not time the wait on the socket - - time the wait as IDLE server time instead. - */ - //mysql_socket_set_state(net->vio->mysql_socket, PSI_SOCKET_STATE_IDLE); - //MYSQL_START_IDLE_WAIT(idle_locker, &idle_state); + #ifdef HAVE_PSI_INTERFACE + net->mysql_socket_idle= TRUE; + #endif packet_length= my_net_read(net); - //MYSQL_END_IDLE_WAIT(idle_locker); - //mysql_socket_set_state(net->vio->mysql_socket, PSI_SOCKET_STATE_ACTIVE); + #ifdef HAVE_PSI_INTERFACE + net->mysql_socket_idle= FALSE; + #endif if (packet_length == packet_error) { === modified file 'storage/perfschema/pfs.cc' --- a/storage/perfschema/pfs.cc 2011-08-05 20:16:40 +0000 +++ b/storage/perfschema/pfs.cc 2011-08-09 19:09:51 +0000 @@ -2894,7 +2894,6 @@ get_thread_socket_locker_v1(PSI_socket_l state->m_flags= flags; state->m_socket= socket; state->m_operation= op; - state->m_idle= pfs_socket->m_idle; return reinterpret_cast (state); } @@ -4581,11 +4580,13 @@ static void start_socket_wait_v1(PSI_soc { PSI_socket_locker_state *state= reinterpret_cast (locker); DBUG_ASSERT(state != NULL); + PFS_socket *socket= reinterpret_cast(state->m_socket); + DBUG_ASSERT(socket != NULL); register uint flags= state->m_flags; ulonglong timer_start= 0; - if (flags & STATE_FLAG_TIMED && !state->m_idle) + if (flags & STATE_FLAG_TIMED && !socket->m_idle) { timer_start= get_timer_raw_value_and_function(wait_timer, &state->m_timer); state->m_timer_start= timer_start; @@ -4617,7 +4618,6 @@ static void end_socket_wait_v1(PSI_socke ulonglong timer_end= 0; ulonglong wait_time= 0; bool socket_closed= false; - bool socket_idle= state->m_idle; PFS_byte_stat *byte_stat; register uint flags= state->m_flags; size_t bytes= ((int)byte_count > -1 ? byte_count : 0); @@ -4662,7 +4662,7 @@ static void end_socket_wait_v1(PSI_socke /** Aggregation for EVENTS_WAITS_SUMMARY_BY_INSTANCE */ if (flags & STATE_FLAG_TIMED) { - if (!socket_idle) + if (!socket->m_idle) { timer_end= state->m_timer(); wait_time= timer_end - state->m_timer_start; @@ -4670,13 +4670,12 @@ static void end_socket_wait_v1(PSI_socke else { /* - A state of IDLE means that this is a RECV operation following a (possibly - very long) idle period. The split between the idle time and the RECV is - unknown, so the entire wait time will be later assigned to the global - IDLE class. Incrementing the RECV count with a zero wait time will throw - off the stats, so assign the current min wait as a best guess. + If idle, then this was a RECV operation that blocked on the socket for an + indeterminate time waiting for data, so the wait time will later be + recorded as an IDLE event. The duration of the actual RECV is unknown and + is therefore set to zero. */ - wait_time= byte_stat->m_min; + wait_time= 0; } /* Aggregate to the socket instrument for now (timed) */ @@ -4734,10 +4733,6 @@ static void end_socket_wait_v1(PSI_socke } } - /* Clear IDLE state */ - if (socket_idle) - socket->m_idle= false; - /* This socket will no longer be used */ if (socket_closed) destroy_socket(socket); === modified file 'storage/perfschema/pfs_instr.cc' --- a/storage/perfschema/pfs_instr.cc 2011-08-05 00:20:04 +0000 +++ b/storage/perfschema/pfs_instr.cc 2011-08-09 19:09:51 +0000 @@ -1414,8 +1414,8 @@ PFS_socket* create_socket(PFS_socket_cla pfs->m_fd= fd; pfs->m_identity= pfs; pfs->m_class= klass; - pfs->m_enabled= klass->m_enabled && flag_global_instrumentation; - pfs->m_timed= klass->m_timed; + pfs->m_enabled= klass->m_enabled && flag_global_instrumentation; + pfs->m_timed= klass->m_timed; pfs->m_idle= false; pfs->m_socket_stat.reset(); pfs->m_lock.dirty_to_allocated(); === modified file 'storage/perfschema/table_events_waits.cc' --- a/storage/perfschema/table_events_waits.cc 2011-07-25 03:34:01 +0000 +++ b/storage/perfschema/table_events_waits.cc 2011-08-09 19:26:45 +0000 @@ -686,7 +686,11 @@ int table_events_waits_common::read_row_ case 16: /* NUMBER_OF_BYTES */ if ((m_row.m_operation == OPERATION_TYPE_FILEREAD) || (m_row.m_operation == OPERATION_TYPE_FILEWRITE) || - (m_row.m_operation == OPERATION_TYPE_FILECHSIZE)) + (m_row.m_operation == OPERATION_TYPE_FILECHSIZE) || + (m_row.m_operation == OPERATION_TYPE_SOCKETSEND) || + (m_row.m_operation == OPERATION_TYPE_SOCKETRECV) || + (m_row.m_operation == OPERATION_TYPE_SOCKETSENDTO) || + (m_row.m_operation == OPERATION_TYPE_SOCKETRECVFROM)) set_field_ulonglong(f, m_row.m_number_of_bytes); else f->set_null(); No bundle (reason: useless for push emails).