From: Christopher Powers Date: July 20 2011 11:12pm Subject: bzr push into mysql-trunk branch (chris.powers:3324 to 3325) WL#4896 List-Archive: http://lists.mysql.com/commits/140396 Message-Id: <201107202312.p6KNCRlQ005087@acsmt356.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3325 Christopher Powers 2011-07-20 WL#4896 "Performance Schema Net IO" Capture number of bytes read from socket recv() for sockets in IDLE state. modified: sql/sql_parse.cc storage/perfschema/pfs.cc 3324 Christopher Powers 2011-07-20 WL#4896 "Performance Schema Net IO" - Handle socket accept() more effectively for listener sockets modified: sql/mysqld.cc storage/perfschema/pfs.cc === modified file 'sql/sql_parse.cc' --- a/sql/sql_parse.cc 2011-07-17 03:30:21 +0000 +++ b/sql/sql_parse.cc 2011-07-20 23:11:24 +0000 @@ -790,7 +790,7 @@ bool do_command(THD *thd) ulong packet_length; NET *net= &thd->net; enum enum_server_command command; - // CWP: MYSQL_IDLE_WAIT_VARIABLES(idle_locker, idle_state) /* no ; */ + MYSQL_IDLE_WAIT_VARIABLES(idle_locker, idle_state) /* no ; */ DBUG_ENTER("do_command"); @@ -838,13 +838,13 @@ bool do_command(THD *thd) - do not time the wait on the socket - time the wait as IDLE server time instead. */ - // CWP: disabled mysql_socket_set_state(net->vio->mysql_socket, PSI_SOCKET_STATE_IDLE); - // CWP: MYSQL_START_IDLE_WAIT(idle_locker, &idle_state); + mysql_socket_set_state(net->vio->mysql_socket, PSI_SOCKET_STATE_IDLE); + MYSQL_START_IDLE_WAIT(idle_locker, &idle_state); packet_length= my_net_read(net); - // CWP: MYSQL_END_IDLE_WAIT(idle_locker); - // CWP: mysql_socket_set_state(net->vio->mysql_socket, PSI_SOCKET_STATE_ACTIVE); + MYSQL_END_IDLE_WAIT(idle_locker); + mysql_socket_set_state(net->vio->mysql_socket, PSI_SOCKET_STATE_ACTIVE); if (packet_length == packet_error) { === modified file 'storage/perfschema/pfs.cc' --- a/storage/perfschema/pfs.cc 2011-07-20 18:44:46 +0000 +++ b/storage/perfschema/pfs.cc 2011-07-20 23:11:24 +0000 @@ -2767,7 +2767,7 @@ get_thread_socket_locker_v1(PSI_socket_l DBUG_ASSERT(pfs_socket->m_class != NULL); - if (pfs_socket->m_idle || !pfs_socket->m_enabled) + if (!pfs_socket->m_enabled) return NULL; register uint flags; @@ -2785,7 +2785,8 @@ get_thread_socket_locker_v1(PSI_socket_l state->m_thread= reinterpret_cast (pfs_thread); flags= STATE_FLAG_THREAD; - if (pfs_socket->m_timed) + /* Sockets in IDLE state are timed separately */ + if (pfs_socket->m_timed && !pfs_socket->m_idle) flags|= STATE_FLAG_TIMED; if (flag_events_waits_current) @@ -2819,7 +2820,8 @@ get_thread_socket_locker_v1(PSI_socket_l } else { - if (pfs_socket->m_timed) + /* Sockets in IDLE state are counted but not timed */ + if (pfs_socket->m_timed && !pfs_socket->m_idle) { flags= STATE_FLAG_TIMED; } @@ -2828,10 +2830,10 @@ get_thread_socket_locker_v1(PSI_socket_l flags= 0; /* - get_thread_socket_locker() does not track the byte count associated - with socket operations because the requested and actual byte counts - may differ. This shortcut is therefore only valid for 'miscellaneous' - operations that do not have a byte count. + Even if timing is disabled, end_socket_wait() still needs a locker to + capture the number of bytes sent or received by the socket operation. + However, for operations that do not have a byte count, then just + increment the event counter and return a NULL locker. */ switch (op) { @@ -4574,14 +4576,15 @@ static void end_socket_wait_v1(PSI_socke { PSI_socket_locker_state *state= reinterpret_cast (locker); DBUG_ASSERT(state != NULL); - ulonglong timer_end= 0; - ulonglong wait_time= 0; - bool socket_closed= false; - PFS_socket *socket= reinterpret_cast(state->m_socket); DBUG_ASSERT(socket != NULL); PFS_thread *thread= reinterpret_cast(state->m_thread); + DBUG_ASSERT(thread != NULL); + ulonglong timer_end= 0; + ulonglong wait_time= 0; + bool socket_closed= false; + bool socket_idle= socket->m_idle; PFS_byte_stat *byte_stat; register uint flags= state->m_flags; size_t bytes= ((int)byte_count > -1 ? byte_count : 0); @@ -4686,6 +4689,10 @@ 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); No bundle (reason: useless for push emails).