3259 Marc Alff 2011-03-16
WL#4896 PERFORMANCE SCHEMA NET IO
Added instrumentation for IDLE events.
added:
include/mysql/psi/mysql_idle.h
modified:
include/mysql/psi/mysql_socket.h
include/mysql/psi/psi.h
include/mysql/psi/psi_abi_v1.h.pp
include/mysql/psi/psi_abi_v2.h.pp
mysql-test/suite/perfschema/include/start_server_common.inc
mysql-test/suite/perfschema/r/dml_setup_timers.result
mysql-test/suite/perfschema/r/information_schema.result
mysql-test/suite/perfschema/r/ortho_iter.result
mysql-test/suite/perfschema/r/query_cache.result
mysql-test/suite/perfschema/r/start_server_no_cond_class.result
mysql-test/suite/perfschema/r/start_server_no_cond_inst.result
mysql-test/suite/perfschema/r/start_server_no_file_class.result
mysql-test/suite/perfschema/r/start_server_no_file_inst.result
mysql-test/suite/perfschema/r/start_server_no_mutex_class.result
mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result
mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result
mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result
mysql-test/suite/perfschema/r/start_server_no_setup_actors.result
mysql-test/suite/perfschema/r/start_server_no_setup_objects.result
mysql-test/suite/perfschema/r/start_server_no_socket_class.result
mysql-test/suite/perfschema/r/start_server_no_socket_inst.result
mysql-test/suite/perfschema/r/start_server_no_table_hdl.result
mysql-test/suite/perfschema/r/start_server_no_table_inst.result
mysql-test/suite/perfschema/r/start_server_no_thread_class.result
mysql-test/suite/perfschema/r/start_server_no_thread_inst.result
mysql-test/suite/perfschema/r/start_server_nothing.result
mysql-test/suite/perfschema/r/start_server_off.result
mysql-test/suite/perfschema/r/start_server_on.result
mysql-test/suite/perfschema/t/dml_setup_timers.test
mysql-test/suite/perfschema/t/ortho_iter.test
sql/sql_parse.cc
storage/perfschema/pfs.cc
storage/perfschema/pfs_column_types.h
storage/perfschema/pfs_events_waits.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_timer.cc
storage/perfschema/pfs_timer.h
storage/perfschema/pfs_visitor.cc
storage/perfschema/table_events_waits.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_helper.h
storage/perfschema/table_setup_instruments.cc
storage/perfschema/table_setup_instruments.h
storage/perfschema/table_setup_timers.cc
3258 Marc Alff 2011-03-16
Build cleanup
modified:
include/mysql/psi/mysql_socket.h
mysql-test/suite/perfschema/r/pfs_upgrade_lc2.result
mysql-test/suite/perfschema/r/schema_lc2.result
=== added file 'include/mysql/psi/mysql_idle.h'
--- a/include/mysql/psi/mysql_idle.h 1970-01-01 00:00:00 +0000
+++ b/include/mysql/psi/mysql_idle.h 2011-03-16 15:36:35 +0000
@@ -0,0 +1,113 @@
+/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#ifndef MYSQL_IDLE_H
+#define MYSQL_IDLE_H
+
+/**
+ @file mysql/psi/mysql_idle.h
+ Instrumentation helpers for idle waits.
+*/
+
+#include "mysql/psi/psi.h"
+
+/**
+ @defgroup Idle_instrumentation Idle Instrumentation
+ @ingroup Instrumentation_interface
+ @{
+*/
+
+/**
+ @def MYSQL_IDLE_WAIT_VARIABLES
+ Instrumentation helper for idle waits.
+ This instrumentation declares local variables.
+ Do not use a ';' after this macro
+ @param LOCKER the locker
+ @param STATE the locker state
+ @sa MYSQL_START_IDLE_WAIT
+ @sa MYSQL_END_IDLE_WAIT
+*/
+#ifdef HAVE_PSI_INTERFACE
+ #define MYSQL_IDLE_WAIT_VARIABLES(LOCKER, STATE) \
+ struct PSI_idle_locker* LOCKER; \
+ PSI_idle_locker_state STATE;
+#else
+ #define MYSQL_IDLE_WAIT_VARIABLES(LOCKER, STATE)
+#endif
+
+/**
+ @def MYSQL_START_IDLE_WAIT
+ Instrumentation helper for table io_waits.
+ This instrumentation marks the start of a wait event.
+ @param LOCKER the locker
+ @param STATE the locker state
+ @sa MYSQL_END_IDLE_WAIT.
+*/
+#ifdef HAVE_PSI_INTERFACE
+ #define MYSQL_START_IDLE_WAIT(LOCKER, STATE) \
+ LOCKER= inline_mysql_start_idle_wait(STATE, __FILE__, __LINE__)
+#else
+ #define MYSQL_START_IDLE_WAIT(LOCKER, STATE) \
+ do {} while (0)
+#endif
+
+/**
+ @def MYSQL_END_IDLE_WAIT
+ Instrumentation helper for idle waits.
+ This instrumentation marks the end of a wait event.
+ @param LOCKER the locker
+ @sa MYSQL_START_IDLE_WAIT.
+*/
+#ifdef HAVE_PSI_INTERFACE
+ #define MYSQL_END_IDLE_WAIT(LOCKER) \
+ inline_mysql_end_idle_wait(LOCKER)
+#else
+ #define MYSQL_END_IDLE_WAIT(LOCKER) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_INTERFACE
+/**
+ Instrumentation calls for MYSQL_START_IDLE_WAIT.
+ @sa MYSQL_END_IDLE_WAIT.
+*/
+static inline struct PSI_idle_locker *
+inline_mysql_start_idle_wait(PSI_idle_locker_state *state,
+ const char *src_file, int src_line)
+{
+ struct PSI_idle_locker *locker= NULL;
+ if (likely(PSI_server != NULL))
+ {
+ locker= PSI_server->start_idle_wait(state, src_file, src_line);
+ }
+ return locker;
+}
+
+/**
+ Instrumentation calls for MYSQL_END_IDLE_WAIT.
+ @sa MYSQL_START_IDLE_WAIT.
+*/
+static inline void
+inline_mysql_end_idle_wait(struct PSI_idle_locker *locker)
+{
+ if (likely(locker != NULL))
+ PSI_server->end_idle_wait(locker);
+}
+#endif
+
+/** @} (end of group Idle_instrumentation) */
+
+#endif
+
=== modified file 'include/mysql/psi/mysql_socket.h'
--- a/include/mysql/psi/mysql_socket.h 2011-03-16 09:32:27 +0000
+++ b/include/mysql/psi/mysql_socket.h 2011-03-16 15:36:35 +0000
@@ -86,6 +86,22 @@ mysql_socket_invalid()
MYSQL_SOCKET mysql_socket= {INVALID_SOCKET, NULL};
return mysql_socket;
}
+
+/**
+ Set the state (IDLE, ACTIVE) of an instrumented socket.
+ @param socket the instrumented socket
+ @param state the new state
+ @sa PSI_socket_state
+*/
+static inline void
+mysql_socket_set_state(MYSQL_SOCKET socket, enum PSI_socket_state state)
+{
+#ifdef HAVE_PSI_INTERFACE
+ if ((PSI_server != NULL) && (socket.m_psi != NULL))
+ PSI_server->set_socket_state(socket.m_psi, state);
+#endif
+}
+
/**
@def mysql_socket_getfd
MYSQL_SOCKET helper. Get socket descriptor.
=== modified file 'include/mysql/psi/psi.h'
--- a/include/mysql/psi/psi.h 2011-03-14 16:11:25 +0000
+++ b/include/mysql/psi/psi.h 2011-03-16 15:36:35 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -143,6 +143,12 @@ struct PSI_bootstrap
#endif
/**
+ Interface for an instrumented idle operation.
+ This is an opaque structure.
+*/
+struct PSI_idle_locker;
+
+/**
Interface for an instrumented mutex operation.
This is an opaque structure.
*/
@@ -265,6 +271,15 @@ enum PSI_table_lock_operation
PSI_TABLE_EXTERNAL_LOCK= 1
};
+/** State of an instrumented socket. */
+enum PSI_socket_state
+{
+ /** Idle, waiting for the next command. */
+ PSI_SOCKET_STATE_IDLE= 0,
+ /** Active, executing a command. */
+ PSI_SOCKET_STATE_ACTIVE= 1
+};
+
/** Operation performed on an instrumented socket. */
enum PSI_socket_operation
{
@@ -515,6 +530,29 @@ struct PSI_socket_info_v1
};
/**
+ State data storage for @c start_idle_wait_v1_t.
+ This structure provide temporary storage to an idle locker.
+ The content of this structure is considered opaque,
+ the fields are only hints of what an implementation
+ of the psi interface can use.
+ This memory is provided by the instrumented code for performance reasons.
+ @sa start_idle_wait_v1_t.
+*/
+struct PSI_idle_locker_state_v1
+{
+ /** Internal state. */
+ uint m_flags;
+ /** Current thread. */
+ struct PSI_thread *m_thread;
+ /** Timer start. */
+ ulonglong m_timer_start;
+ /** Timer function. */
+ ulonglong (*m_timer)(void);
+ /** Internal data. */
+ void *m_wait;
+};
+
+/**
State data storage for @c get_thread_mutex_locker_v1_t.
This structure provide temporary storage to a mutex locker.
The content of this structure is considered opaque,
@@ -1126,6 +1164,12 @@ typedef void (*signal_cond_v1_t)
typedef void (*broadcast_cond_v1_t)
(struct PSI_cond *cond);
+typedef struct PSI_idle_locker* (*start_idle_wait_v1_t)
+ (struct PSI_idle_locker_state_v1 *state, const char *src_file, uint src_line);
+
+typedef void (*end_idle_wait_v1_t)
+ (struct PSI_idle_locker *locker);
+
/**
Record a mutex instrumentation wait start event.
@param locker a thread locker for the running thread
@@ -1297,6 +1341,14 @@ typedef void (*end_socket_wait_v1_t)
(struct PSI_socket_locker *locker, size_t count);
/**
+ Set the socket state for an instrumented socket.
+ @param socket the instrumented socket
+ @param state socket state
+ */
+typedef void (*set_socket_state_v1_t)(struct PSI_socket *socket,
+ enum PSI_socket_state state);
+
+/**
Set the socket descriptor for an instrumented socket.
@param socket the instrumented socket
@param fd socket descriptor
@@ -1434,6 +1486,10 @@ struct PSI_v1
signal_cond_v1_t signal_cond;
/** @sa broadcast_cond_v1_t. */
broadcast_cond_v1_t broadcast_cond;
+ /** @sa start_idle_wait_v1_t. */
+ start_idle_wait_v1_t start_idle_wait;
+ /** @sa end_idle_wait_v1_t. */
+ end_idle_wait_v1_t end_idle_wait;
/** @sa start_mutex_wait_v1_t. */
start_mutex_wait_v1_t start_mutex_wait;
/** @sa end_mutex_wait_v1_t. */
@@ -1473,6 +1529,8 @@ struct PSI_v1
start_socket_wait_v1_t start_socket_wait;
/** @sa end_socket_wait_v1_t. */
end_socket_wait_v1_t end_socket_wait;
+ /** @sa set_socket_state_v1_t. */
+ set_socket_state_v1_t set_socket_state;
/** @sa set_socket_descriptor_v1_t. */
set_socket_descriptor_v1_t set_socket_descriptor;
/** @sa set_socket_address_v1_t. */
@@ -1546,6 +1604,12 @@ struct PSI_file_info_v2
int placeholder;
};
+struct PSI_idle_locker_state_v2
+{
+ /** Placeholder */
+ int placeholder;
+};
+
struct PSI_mutex_locker_state_v2
{
/** Placeholder */
@@ -1626,6 +1690,7 @@ typedef struct PSI_cond_info_v1 PSI_cond
typedef struct PSI_thread_info_v1 PSI_thread_info;
typedef struct PSI_file_info_v1 PSI_file_info;
typedef struct PSI_socket_info_v1 PSI_socket_info;
+typedef struct PSI_idle_locker_state_v1 PSI_idle_locker_state;
typedef struct PSI_mutex_locker_state_v1 PSI_mutex_locker_state;
typedef struct PSI_rwlock_locker_state_v1 PSI_rwlock_locker_state;
typedef struct PSI_cond_locker_state_v1 PSI_cond_locker_state;
@@ -1642,6 +1707,7 @@ typedef struct PSI_cond_info_v2 PSI_cond
typedef struct PSI_thread_info_v2 PSI_thread_info;
typedef struct PSI_file_info_v2 PSI_file_info;
typedef struct PSI_socket_info_v2 PSI_socket_info;
+typedef struct PSI_idle_locker_state_v2 PSI_idle_locker_state;
typedef struct PSI_mutex_locker_state_v2 PSI_mutex_locker_state;
typedef struct PSI_rwlock_locker_state_v2 PSI_rwlock_locker_state;
typedef struct PSI_cond_locker_state_v2 PSI_cond_locker_state;
=== modified file 'include/mysql/psi/psi_abi_v1.h.pp'
--- a/include/mysql/psi/psi_abi_v1.h.pp 2011-03-14 16:29:27 +0000
+++ b/include/mysql/psi/psi_abi_v1.h.pp 2011-03-16 15:36:35 +0000
@@ -14,6 +14,7 @@ struct PSI_bootstrap
{
void* (*get_interface)(int version);
};
+struct PSI_idle_locker;
struct PSI_mutex_locker;
struct PSI_rwlock_locker;
struct PSI_cond_locker;
@@ -67,6 +68,11 @@ enum PSI_table_lock_operation
PSI_TABLE_LOCK= 0,
PSI_TABLE_EXTERNAL_LOCK= 1
};
+enum PSI_socket_state
+{
+ PSI_SOCKET_STATE_IDLE= 0,
+ PSI_SOCKET_STATE_ACTIVE= 1
+};
enum PSI_socket_operation
{
PSI_SOCKET_CREATE= 0,
@@ -126,6 +132,14 @@ struct PSI_socket_info_v1
const char *m_name;
int m_flags;
};
+struct PSI_idle_locker_state_v1
+{
+ uint m_flags;
+ struct PSI_thread *m_thread;
+ ulonglong m_timer_start;
+ ulonglong (*m_timer)(void);
+ void *m_wait;
+};
struct PSI_mutex_locker_state_v1
{
uint m_flags;
@@ -297,6 +311,10 @@ typedef void (*signal_cond_v1_t)
(struct PSI_cond *cond);
typedef void (*broadcast_cond_v1_t)
(struct PSI_cond *cond);
+typedef struct PSI_idle_locker* (*start_idle_wait_v1_t)
+ (struct PSI_idle_locker_state_v1 *state, const char *src_file, uint src_line);
+typedef void (*end_idle_wait_v1_t)
+ (struct PSI_idle_locker *locker);
typedef void (*start_mutex_wait_v1_t)
(struct PSI_mutex_locker *locker, const char *src_file, uint src_line);
typedef void (*end_mutex_wait_v1_t)
@@ -334,6 +352,8 @@ typedef void (*start_socket_wait_v1_t)
const char *src_file, uint src_line);
typedef void (*end_socket_wait_v1_t)
(struct PSI_socket_locker *locker, size_t count);
+typedef void (*set_socket_state_v1_t)(struct PSI_socket *socket,
+ enum PSI_socket_state state);
typedef void (*set_socket_descriptor_v1_t)(struct PSI_socket *socket,
uint fd);
typedef void (*set_socket_address_v1_t)(struct PSI_socket *socket,
@@ -394,6 +414,8 @@ struct PSI_v1
unlock_rwlock_v1_t unlock_rwlock;
signal_cond_v1_t signal_cond;
broadcast_cond_v1_t broadcast_cond;
+ start_idle_wait_v1_t start_idle_wait;
+ end_idle_wait_v1_t end_idle_wait;
start_mutex_wait_v1_t start_mutex_wait;
end_mutex_wait_v1_t end_mutex_wait;
start_rwlock_rdwait_v1_t start_rwlock_rdwait;
@@ -414,6 +436,7 @@ struct PSI_v1
end_file_wait_v1_t end_file_wait;
start_socket_wait_v1_t start_socket_wait;
end_socket_wait_v1_t end_socket_wait;
+ set_socket_state_v1_t set_socket_state;
set_socket_descriptor_v1_t set_socket_descriptor;
set_socket_address_v1_t set_socket_address;
set_socket_info_v1_t set_socket_info;
@@ -426,6 +449,7 @@ typedef struct PSI_cond_info_v1 PSI_cond
typedef struct PSI_thread_info_v1 PSI_thread_info;
typedef struct PSI_file_info_v1 PSI_file_info;
typedef struct PSI_socket_info_v1 PSI_socket_info;
+typedef struct PSI_idle_locker_state_v1 PSI_idle_locker_state;
typedef struct PSI_mutex_locker_state_v1 PSI_mutex_locker_state;
typedef struct PSI_rwlock_locker_state_v1 PSI_rwlock_locker_state;
typedef struct PSI_cond_locker_state_v1 PSI_cond_locker_state;
=== modified file 'include/mysql/psi/psi_abi_v2.h.pp'
--- a/include/mysql/psi/psi_abi_v2.h.pp 2011-02-23 21:13:48 +0000
+++ b/include/mysql/psi/psi_abi_v2.h.pp 2011-03-16 15:36:35 +0000
@@ -14,6 +14,7 @@ struct PSI_bootstrap
{
void* (*get_interface)(int version);
};
+struct PSI_idle_locker;
struct PSI_mutex_locker;
struct PSI_rwlock_locker;
struct PSI_cond_locker;
@@ -67,6 +68,11 @@ enum PSI_table_lock_operation
PSI_TABLE_LOCK= 0,
PSI_TABLE_EXTERNAL_LOCK= 1
};
+enum PSI_socket_state
+{
+ PSI_SOCKET_STATE_IDLE= 0,
+ PSI_SOCKET_STATE_ACTIVE= 1
+};
enum PSI_socket_operation
{
PSI_SOCKET_CREATE= 0,
@@ -114,6 +120,10 @@ struct PSI_file_info_v2
{
int placeholder;
};
+struct PSI_idle_locker_state_v2
+{
+ int placeholder;
+};
struct PSI_mutex_locker_state_v2
{
int placeholder;
@@ -145,6 +155,7 @@ typedef struct PSI_cond_info_v2 PSI_cond
typedef struct PSI_thread_info_v2 PSI_thread_info;
typedef struct PSI_file_info_v2 PSI_file_info;
typedef struct PSI_socket_info_v2 PSI_socket_info;
+typedef struct PSI_idle_locker_state_v2 PSI_idle_locker_state;
typedef struct PSI_mutex_locker_state_v2 PSI_mutex_locker_state;
typedef struct PSI_rwlock_locker_state_v2 PSI_rwlock_locker_state;
typedef struct PSI_cond_locker_state_v2 PSI_cond_locker_state;
=== modified file 'mysql-test/suite/perfschema/include/start_server_common.inc'
--- a/mysql-test/suite/perfschema/include/start_server_common.inc 2011-02-27 01:14:36 +0000
+++ b/mysql-test/suite/perfschema/include/start_server_common.inc 2011-03-16 15:36:35 +0000
@@ -21,7 +21,8 @@ select count(*) from performance_schema.
select count(*) from performance_schema.setup_consumers;
# wait/io/table/sql/handler is a native instrument
# wait/lock/table/sql/handler is a native instrument
-select count(*) > 2 from performance_schema.setup_instruments;
+# idle/io/socket is a native instrument
+select count(*) > 3 from performance_schema.setup_instruments;
select count(*) from performance_schema.setup_timers;
# Make sure we don't crash, no matter what the starting parameters are
=== modified file 'mysql-test/suite/perfschema/r/dml_setup_timers.result'
--- a/mysql-test/suite/perfschema/r/dml_setup_timers.result 2010-11-03 15:42:33 +0000
+++ b/mysql-test/suite/perfschema/r/dml_setup_timers.result 2011-03-16 15:36:35 +0000
@@ -1,5 +1,12 @@
+update performance_schema.setup_timers
+set timer_name='CYCLE';
+update performance_schema.setup_timers
+set timer_name='NANOSECOND' where name="statement";
+update performance_schema.setup_timers
+set timer_name='MICROSECOND' where name="idle";
select * from performance_schema.setup_timers;
NAME TIMER_NAME
+idle MICROSECOND
wait CYCLE
select * from performance_schema.setup_timers
where name='Wait';
@@ -19,6 +26,7 @@ update performance_schema.setup_timers
set timer_name='MILLISECOND';
select * from performance_schema.setup_timers;
NAME TIMER_NAME
+idle MILLISECOND
wait MILLISECOND
update performance_schema.setup_timers
set timer_name='CYCLE';
@@ -31,3 +39,9 @@ LOCK TABLES performance_schema.setup_tim
UNLOCK TABLES;
LOCK TABLES performance_schema.setup_timers WRITE;
UNLOCK TABLES;
+update performance_schema.setup_timers
+set timer_name='CYCLE';
+update performance_schema.setup_timers
+set timer_name='NANOSECOND' where name="statement";
+update performance_schema.setup_timers
+set timer_name='MICROSECOND' where name="idle";
=== modified file 'mysql-test/suite/perfschema/r/information_schema.result'
--- a/mysql-test/suite/perfschema/r/information_schema.result 2011-02-25 23:53:35 +0000
+++ b/mysql-test/suite/perfschema/r/information_schema.result 2011-03-16 15:36:35 +0000
@@ -110,7 +110,7 @@ setup_actors 1 0
setup_consumers 5 0
setup_instruments 1000 0
setup_objects 3 0
-setup_timers 1 0
+setup_timers 2 0
socket_instances 1000 0
socket_summary_by_event_name 1000 0
socket_summary_by_instance 1000 0
=== modified file 'mysql-test/suite/perfschema/r/ortho_iter.result'
--- a/mysql-test/suite/perfschema/r/ortho_iter.result 2011-02-25 23:53:35 +0000
+++ b/mysql-test/suite/perfschema/r/ortho_iter.result 2011-03-16 15:36:35 +0000
@@ -22,7 +22,7 @@ where table_schema= 'performance_schema'
and table_name like "events_%_by_event_name%";
declare continue handler for sqlstate '02000'
set done = 1;
-select (instr_name like "wait/%") into is_wait;
+select (instr_name like "wait/%") or (instr_name like "idle/%") into is_wait;
select (instr_name like "stage/%") into is_stage;
select (instr_name like "statement/%") into is_statement;
select instr_name, is_wait, is_stage, is_statement;
@@ -266,4 +266,22 @@ status
Checking table events_waits_summary_global_by_event_name ...
Warnings:
Warning 12000 Done
+call check_instrument("idle/io/socket");
+instr_name is_wait is_stage is_statement
+idle/io/socket 1 0 0
+status
+Checking table events_waits_summary_by_thread_by_event_name ...
+status
+Checking table events_waits_summary_global_by_event_name ...
+Warnings:
+Warning 12000 Done
+call check_instrument("idle/");
+instr_name is_wait is_stage is_statement
+idle/ 1 0 0
+status
+Checking table events_waits_summary_by_thread_by_event_name ...
+status
+Checking table events_waits_summary_global_by_event_name ...
+Warnings:
+Warning 12000 Done
drop procedure check_instrument;
=== modified file 'mysql-test/suite/perfschema/r/query_cache.result'
--- a/mysql-test/suite/perfschema/r/query_cache.result 2010-11-08 19:35:17 +0000
+++ b/mysql-test/suite/perfschema/r/query_cache.result 2011-03-16 15:36:35 +0000
@@ -38,7 +38,7 @@ spins
NULL
select name from performance_schema.setup_instruments order by name limit 1;
name
-wait/io/file/csv/data
+idle
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
@@ -53,7 +53,7 @@ spins
NULL
select name from performance_schema.setup_instruments order by name limit 1;
name
-wait/io/file/csv/data
+idle
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_cond_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_cond_class.result 2011-02-27 02:46:11 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_cond_class.result 2011-03-16 15:36:35 +0000
@@ -11,12 +11,12 @@ count(*)
select count(*) from performance_schema.setup_consumers;
count(*)
5
-select count(*) > 2 from performance_schema.setup_instruments;
-count(*) > 2
+select count(*) > 3 from performance_schema.setup_instruments;
+count(*) > 3
1
select count(*) from performance_schema.setup_timers;
count(*)
-1
+2
select * from performance_schema.cond_instances;
select * from performance_schema.events_waits_current;
select * from performance_schema.events_waits_history;
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_cond_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_cond_inst.result 2011-02-27 02:46:11 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_cond_inst.result 2011-03-16 15:36:35 +0000
@@ -11,12 +11,12 @@ count(*)
select count(*) from performance_schema.setup_consumers;
count(*)
5
-select count(*) > 2 from performance_schema.setup_instruments;
-count(*) > 2
+select count(*) > 3 from performance_schema.setup_instruments;
+count(*) > 3
1
select count(*) from performance_schema.setup_timers;
count(*)
-1
+2
select * from performance_schema.cond_instances;
select * from performance_schema.events_waits_current;
select * from performance_schema.events_waits_history;
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_file_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_file_class.result 2011-02-27 02:46:11 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_file_class.result 2011-03-16 15:36:35 +0000
@@ -11,12 +11,12 @@ count(*)
select count(*) from performance_schema.setup_consumers;
count(*)
5
-select count(*) > 2 from performance_schema.setup_instruments;
-count(*) > 2
+select count(*) > 3 from performance_schema.setup_instruments;
+count(*) > 3
1
select count(*) from performance_schema.setup_timers;
count(*)
-1
+2
select * from performance_schema.cond_instances;
select * from performance_schema.events_waits_current;
select * from performance_schema.events_waits_history;
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_file_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_file_inst.result 2011-02-27 02:46:11 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_file_inst.result 2011-03-16 15:36:35 +0000
@@ -11,12 +11,12 @@ count(*)
select count(*) from performance_schema.setup_consumers;
count(*)
5
-select count(*) > 2 from performance_schema.setup_instruments;
-count(*) > 2
+select count(*) > 3 from performance_schema.setup_instruments;
+count(*) > 3
1
select count(*) from performance_schema.setup_timers;
count(*)
-1
+2
select * from performance_schema.cond_instances;
select * from performance_schema.events_waits_current;
select * from performance_schema.events_waits_history;
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_mutex_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_mutex_class.result 2011-02-27 02:46:11 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_mutex_class.result 2011-03-16 15:36:35 +0000
@@ -11,12 +11,12 @@ count(*)
select count(*) from performance_schema.setup_consumers;
count(*)
5
-select count(*) > 2 from performance_schema.setup_instruments;
-count(*) > 2
+select count(*) > 3 from performance_schema.setup_instruments;
+count(*) > 3
1
select count(*) from performance_schema.setup_timers;
count(*)
-1
+2
select * from performance_schema.cond_instances;
select * from performance_schema.events_waits_current;
select * from performance_schema.events_waits_history;
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result 2011-02-27 02:46:11 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result 2011-03-16 15:36:35 +0000
@@ -11,12 +11,12 @@ count(*)
select count(*) from performance_schema.setup_consumers;
count(*)
5
-select count(*) > 2 from performance_schema.setup_instruments;
-count(*) > 2
+select count(*) > 3 from performance_schema.setup_instruments;
+count(*) > 3
1
select count(*) from performance_schema.setup_timers;
count(*)
-1
+2
select * from performance_schema.cond_instances;
select * from performance_schema.events_waits_current;
select * from performance_schema.events_waits_history;
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result 2011-02-27 02:46:11 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result 2011-03-16 15:36:35 +0000
@@ -11,12 +11,12 @@ count(*)
select count(*) from performance_schema.setup_consumers;
count(*)
5
-select count(*) > 2 from performance_schema.setup_instruments;
-count(*) > 2
+select count(*) > 3 from performance_schema.setup_instruments;
+count(*) > 3
1
select count(*) from performance_schema.setup_timers;
count(*)
-1
+2
select * from performance_schema.cond_instances;
select * from performance_schema.events_waits_current;
select * from performance_schema.events_waits_history;
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result 2011-02-27 02:46:11 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result 2011-03-16 15:36:35 +0000
@@ -11,12 +11,12 @@ count(*)
select count(*) from performance_schema.setup_consumers;
count(*)
5
-select count(*) > 2 from performance_schema.setup_instruments;
-count(*) > 2
+select count(*) > 3 from performance_schema.setup_instruments;
+count(*) > 3
1
select count(*) from performance_schema.setup_timers;
count(*)
-1
+2
select * from performance_schema.cond_instances;
select * from performance_schema.events_waits_current;
select * from performance_schema.events_waits_history;
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_setup_actors.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_setup_actors.result 2011-02-27 02:46:11 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_setup_actors.result 2011-03-16 15:36:35 +0000
@@ -11,12 +11,12 @@ count(*)
select count(*) from performance_schema.setup_consumers;
count(*)
5
-select count(*) > 2 from performance_schema.setup_instruments;
-count(*) > 2
+select count(*) > 3 from performance_schema.setup_instruments;
+count(*) > 3
1
select count(*) from performance_schema.setup_timers;
count(*)
-1
+2
select * from performance_schema.cond_instances;
select * from performance_schema.events_waits_current;
select * from performance_schema.events_waits_history;
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_setup_objects.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_setup_objects.result 2011-02-27 02:46:11 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_setup_objects.result 2011-03-16 15:36:35 +0000
@@ -11,12 +11,12 @@ count(*)
select count(*) from performance_schema.setup_consumers;
count(*)
5
-select count(*) > 2 from performance_schema.setup_instruments;
-count(*) > 2
+select count(*) > 3 from performance_schema.setup_instruments;
+count(*) > 3
1
select count(*) from performance_schema.setup_timers;
count(*)
-1
+2
select * from performance_schema.cond_instances;
select * from performance_schema.events_waits_current;
select * from performance_schema.events_waits_history;
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_socket_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_socket_class.result 2011-02-27 02:07:57 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_socket_class.result 2011-03-16 15:36:35 +0000
@@ -11,12 +11,12 @@ count(*)
select count(*) from performance_schema.setup_consumers;
count(*)
5
-select count(*) > 2 from performance_schema.setup_instruments;
-count(*) > 2
+select count(*) > 3 from performance_schema.setup_instruments;
+count(*) > 3
1
select count(*) from performance_schema.setup_timers;
count(*)
-1
+2
select * from performance_schema.cond_instances;
select * from performance_schema.events_waits_current;
select * from performance_schema.events_waits_history;
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_socket_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_socket_inst.result 2011-02-27 02:07:57 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_socket_inst.result 2011-03-16 15:36:35 +0000
@@ -11,12 +11,12 @@ count(*)
select count(*) from performance_schema.setup_consumers;
count(*)
5
-select count(*) > 2 from performance_schema.setup_instruments;
-count(*) > 2
+select count(*) > 3 from performance_schema.setup_instruments;
+count(*) > 3
1
select count(*) from performance_schema.setup_timers;
count(*)
-1
+2
select * from performance_schema.cond_instances;
select * from performance_schema.events_waits_current;
select * from performance_schema.events_waits_history;
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_table_hdl.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_table_hdl.result 2011-02-27 02:46:11 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_table_hdl.result 2011-03-16 15:36:35 +0000
@@ -11,12 +11,12 @@ count(*)
select count(*) from performance_schema.setup_consumers;
count(*)
5
-select count(*) > 2 from performance_schema.setup_instruments;
-count(*) > 2
+select count(*) > 3 from performance_schema.setup_instruments;
+count(*) > 3
1
select count(*) from performance_schema.setup_timers;
count(*)
-1
+2
select * from performance_schema.cond_instances;
select * from performance_schema.events_waits_current;
select * from performance_schema.events_waits_history;
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_table_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_table_inst.result 2011-02-27 02:46:11 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_table_inst.result 2011-03-16 15:36:35 +0000
@@ -11,12 +11,12 @@ count(*)
select count(*) from performance_schema.setup_consumers;
count(*)
5
-select count(*) > 2 from performance_schema.setup_instruments;
-count(*) > 2
+select count(*) > 3 from performance_schema.setup_instruments;
+count(*) > 3
1
select count(*) from performance_schema.setup_timers;
count(*)
-1
+2
select * from performance_schema.cond_instances;
select * from performance_schema.events_waits_current;
select * from performance_schema.events_waits_history;
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_thread_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_thread_class.result 2011-02-27 02:46:11 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_thread_class.result 2011-03-16 15:36:35 +0000
@@ -11,12 +11,12 @@ count(*)
select count(*) from performance_schema.setup_consumers;
count(*)
5
-select count(*) > 2 from performance_schema.setup_instruments;
-count(*) > 2
+select count(*) > 3 from performance_schema.setup_instruments;
+count(*) > 3
1
select count(*) from performance_schema.setup_timers;
count(*)
-1
+2
select * from performance_schema.cond_instances;
select * from performance_schema.events_waits_current;
select * from performance_schema.events_waits_history;
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_thread_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_thread_inst.result 2011-02-27 02:46:11 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_thread_inst.result 2011-03-16 15:36:35 +0000
@@ -11,12 +11,12 @@ count(*)
select count(*) from performance_schema.setup_consumers;
count(*)
5
-select count(*) > 2 from performance_schema.setup_instruments;
-count(*) > 2
+select count(*) > 3 from performance_schema.setup_instruments;
+count(*) > 3
1
select count(*) from performance_schema.setup_timers;
count(*)
-1
+2
select * from performance_schema.cond_instances;
select * from performance_schema.events_waits_current;
select * from performance_schema.events_waits_history;
=== modified file 'mysql-test/suite/perfschema/r/start_server_nothing.result'
--- a/mysql-test/suite/perfschema/r/start_server_nothing.result 2011-03-09 23:28:32 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_nothing.result 2011-03-16 15:36:35 +0000
@@ -11,12 +11,12 @@ count(*)
select count(*) from performance_schema.setup_consumers;
count(*)
5
-select count(*) > 2 from performance_schema.setup_instruments;
-count(*) > 2
+select count(*) > 3 from performance_schema.setup_instruments;
+count(*) > 3
0
select count(*) from performance_schema.setup_timers;
count(*)
-1
+2
select * from performance_schema.cond_instances;
select * from performance_schema.events_waits_current;
select * from performance_schema.events_waits_history;
@@ -93,6 +93,7 @@ select * from performance_schema.setup_i
NAME ENABLED TIMED
wait/io/table/sql/handler YES YES
wait/lock/table/sql/handler YES YES
+idle YES YES
select TIMER_NAME from performance_schema.performance_timers;
TIMER_NAME
CYCLE
@@ -109,6 +110,7 @@ global_instrumentation YES
thread_instrumentation YES
select * from performance_schema.setup_timers;
NAME TIMER_NAME
+idle MICROSECOND
wait CYCLE
select * from performance_schema.cond_instances;
NAME OBJECT_INSTANCE_BEGIN
@@ -126,6 +128,7 @@ select * from performance_schema.events_
EVENT_NAME COUNT_STAR SUM_TIMER_WAIT MIN_TIMER_WAIT AVG_TIMER_WAIT MAX_TIMER_WAIT
wait/io/table/sql/handler 0 0 0 0 0
wait/lock/table/sql/handler 0 0 0 0 0
+idle 0 0 0 0 0
select * from performance_schema.file_instances;
FILE_NAME EVENT_NAME OPEN_COUNT
select * from performance_schema.file_summary_by_event_name;
=== modified file 'mysql-test/suite/perfschema/r/start_server_off.result'
--- a/mysql-test/suite/perfschema/r/start_server_off.result 2011-02-27 02:46:11 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_off.result 2011-03-16 15:36:35 +0000
@@ -11,12 +11,12 @@ count(*)
select count(*) from performance_schema.setup_consumers;
count(*)
5
-select count(*) > 2 from performance_schema.setup_instruments;
-count(*) > 2
+select count(*) > 3 from performance_schema.setup_instruments;
+count(*) > 3
0
select count(*) from performance_schema.setup_timers;
count(*)
-1
+2
select * from performance_schema.cond_instances;
select * from performance_schema.events_waits_current;
select * from performance_schema.events_waits_history;
=== modified file 'mysql-test/suite/perfschema/r/start_server_on.result'
--- a/mysql-test/suite/perfschema/r/start_server_on.result 2011-02-27 02:46:11 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_on.result 2011-03-16 15:36:35 +0000
@@ -11,12 +11,12 @@ count(*)
select count(*) from performance_schema.setup_consumers;
count(*)
5
-select count(*) > 2 from performance_schema.setup_instruments;
-count(*) > 2
+select count(*) > 3 from performance_schema.setup_instruments;
+count(*) > 3
1
select count(*) from performance_schema.setup_timers;
count(*)
-1
+2
select * from performance_schema.cond_instances;
select * from performance_schema.events_waits_current;
select * from performance_schema.events_waits_history;
=== modified file 'mysql-test/suite/perfschema/t/dml_setup_timers.test'
--- a/mysql-test/suite/perfschema/t/dml_setup_timers.test 2010-11-08 19:35:17 +0000
+++ b/mysql-test/suite/perfschema/t/dml_setup_timers.test 2011-03-16 15:36:35 +0000
@@ -18,6 +18,14 @@
--source include/not_embedded.inc
--source include/have_perfschema.inc
+# Set to a known state
+update performance_schema.setup_timers
+ set timer_name='CYCLE';
+update performance_schema.setup_timers
+ set timer_name='NANOSECOND' where name="statement";
+update performance_schema.setup_timers
+ set timer_name='MICROSECOND' where name="idle";
+
select * from performance_schema.setup_timers;
select * from performance_schema.setup_timers
@@ -55,3 +63,11 @@ UNLOCK TABLES;
LOCK TABLES performance_schema.setup_timers WRITE;
UNLOCK TABLES;
+# Cleanup
+update performance_schema.setup_timers
+ set timer_name='CYCLE';
+update performance_schema.setup_timers
+ set timer_name='NANOSECOND' where name="statement";
+update performance_schema.setup_timers
+ set timer_name='MICROSECOND' where name="idle";
+
=== modified file 'mysql-test/suite/perfschema/t/ortho_iter.test'
--- a/mysql-test/suite/perfschema/t/ortho_iter.test 2011-01-28 13:40:57 +0000
+++ b/mysql-test/suite/perfschema/t/ortho_iter.test 2011-03-16 15:36:35 +0000
@@ -51,7 +51,7 @@ begin
declare continue handler for sqlstate '02000'
set done = 1;
- select (instr_name like "wait/%") into is_wait;
+ select (instr_name like "wait/%") or (instr_name like "idle/%") into is_wait;
select (instr_name like "stage/%") into is_stage;
select (instr_name like "statement/%") into is_statement;
@@ -154,6 +154,8 @@ call check_instrument("stage/");
call check_instrument("statement/com/");
call check_instrument("statement/sql/");
call check_instrument("statement/");
+call check_instrument("idle/io/socket");
+call check_instrument("idle/");
drop procedure check_instrument;
=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc 2011-03-11 09:35:38 +0000
+++ b/sql/sql_parse.cc 2011-03-16 15:36:35 +0000
@@ -95,6 +95,7 @@
#include "probes_mysql.h"
#include "set_var.h"
#include "sql_bootstrap.h"
+#include "mysql/psi/mysql_idle.h"
#define FLAGSTR(V,F) ((V)&(F)?#F" ":"")
@@ -716,6 +717,8 @@ 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");
/*
@@ -757,7 +760,20 @@ bool do_command(THD *thd)
*/
DEBUG_SYNC(thd, "before_do_command_net_read");
- if ((packet_length= my_net_read(net)) == packet_error)
+ /*
+ 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);
+
+ packet_length= my_net_read(net);
+
+ MYSQL_END_IDLE_WAIT(idle_locker);
+ mysql_socket_set_state(net->vio->mysql_socket, PSI_SOCKET_STATE_ACTIVE);
+
+ if (packet_length == packet_error)
{
DBUG_PRINT("info",("Got error %d reading command from socket %s",
net->error,
=== modified file 'storage/perfschema/pfs.cc'
--- a/storage/perfschema/pfs.cc 2011-03-14 16:11:25 +0000
+++ b/storage/perfschema/pfs.cc 2011-03-16 15:36:35 +0000
@@ -2625,6 +2625,9 @@ get_thread_socket_locker_v1(PSI_socket_l
if (!flag_global_instrumentation)
return NULL;
+ if (pfs_socket->m_idle)
+ return NULL;
+
PFS_socket_class *klass= pfs_socket->m_class;
if (!klass->m_enabled)
return NULL;
@@ -2847,6 +2850,135 @@ static void broadcast_cond_v1(PSI_cond*
}
/**
+ Implementation of the idle instrumentation interface.
+ @sa PSI_v1::start_idle_wait.
+*/
+static PSI_idle_locker*
+start_idle_wait_v1(PSI_idle_locker_state* state, const char *src_file, uint src_line)
+{
+ DBUG_ASSERT(state != NULL);
+
+ if (! flag_global_instrumentation)
+ return NULL;
+
+ if (! global_idle_class.m_enabled)
+ return NULL;
+
+ register uint flags= 0;
+ ulonglong timer_start= 0;
+
+ 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;
+
+ if (global_idle_class.m_timed)
+ {
+ timer_start= get_timer_raw_value_and_function(idle_timer, & state->m_timer);
+ state->m_timer_start= timer_start;
+ flags|= STATE_FLAG_TIMED;
+ }
+
+ if (flag_events_waits_current)
+ {
+ if (unlikely(pfs_thread->m_events_waits_count >= WAIT_STACK_SIZE))
+ {
+ locker_lost++;
+ return NULL;
+ }
+ PFS_events_waits *wait= &pfs_thread->m_events_waits_stack[pfs_thread->m_events_waits_count];
+ state->m_wait= wait;
+ flags|= STATE_FLAG_WAIT;
+
+#ifdef HAVE_NESTED_EVENTS
+ wait->m_nesting_event_id= (wait - 1)->m_event_id;
+#endif
+
+ wait->m_thread= pfs_thread;
+ wait->m_class= & global_idle_class;
+ wait->m_timer_start= timer_start;
+ wait->m_timer_end= 0;
+ wait->m_event_id= pfs_thread->m_event_id++;
+ wait->m_operation= OPERATION_TYPE_IDLE;
+ wait->m_source_file= src_file;
+ wait->m_source_line= src_line;
+ wait->m_wait_class= WAIT_CLASS_IDLE;
+
+ pfs_thread->m_events_waits_count++;
+ }
+ }
+ else
+ {
+ if (global_idle_class.m_timed)
+ {
+ timer_start= get_timer_raw_value_and_function(idle_timer, & state->m_timer);
+ state->m_timer_start= timer_start;
+ flags= STATE_FLAG_TIMED;
+ }
+ }
+
+ state->m_flags= flags;
+ return reinterpret_cast<PSI_idle_locker*> (state);
+}
+
+/**
+ Implementation of the mutex instrumentation interface.
+ @sa PSI_v1::end_mutex_wait.
+*/
+static void end_idle_wait_v1(PSI_idle_locker* locker)
+{
+ PSI_idle_locker_state *state= reinterpret_cast<PSI_idle_locker_state*> (locker);
+ DBUG_ASSERT(state != NULL);
+ ulonglong timer_end= 0;
+ ulonglong wait_time= 0;
+
+ register uint flags= state->m_flags;
+
+ if (flags & STATE_FLAG_TIMED)
+ {
+ timer_end= state->m_timer();
+ wait_time= timer_end - state->m_timer_start;
+ }
+
+ if (flags & STATE_FLAG_THREAD)
+ {
+ PFS_thread *thread= reinterpret_cast<PFS_thread *> (state->m_thread);
+ PFS_single_stat *event_name_array;
+ event_name_array= thread->m_instr_class_wait_stats;
+ uint index= global_idle_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_value(wait_time);
+ }
+ else
+ {
+ /* Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME (counted) */
+ event_name_array[index].aggregate_counted();
+ }
+
+ if (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;
+ 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--;
+ }
+ }
+}
+
+/**
Implementation of the mutex instrumentation interface.
@sa PSI_v1::start_mutex_wait.
*/
@@ -3755,6 +3887,14 @@ static void end_socket_wait_v1(PSI_socke
byte_stat->m_bytes+= byte_count;
}
+static void set_socket_state_v1(PSI_socket *socket, PSI_socket_state state)
+{
+ DBUG_ASSERT(socket);
+ DBUG_ASSERT((state == PSI_SOCKET_STATE_IDLE) || (state == PSI_SOCKET_STATE_ACTIVE));
+ PFS_socket *pfs= reinterpret_cast<PFS_socket*>(socket);
+ pfs->m_idle= (state == PSI_SOCKET_STATE_IDLE);
+}
+
static void set_socket_descriptor_v1(PSI_socket *socket, uint fd)
{
DBUG_ASSERT(socket);
@@ -3894,6 +4034,8 @@ PSI_v1 PFS_v1=
unlock_rwlock_v1,
signal_cond_v1,
broadcast_cond_v1,
+ start_idle_wait_v1,
+ end_idle_wait_v1,
start_mutex_wait_v1,
end_mutex_wait_v1,
start_rwlock_rdwait_v1,
@@ -3913,6 +4055,7 @@ PSI_v1 PFS_v1=
end_file_wait_v1,
start_socket_wait_v1,
end_socket_wait_v1,
+ set_socket_state_v1,
set_socket_descriptor_v1,
set_socket_address_v1,
set_socket_info_v1,
=== modified file 'storage/perfschema/pfs_column_types.h'
--- a/storage/perfschema/pfs_column_types.h 2011-02-23 21:13:48 +0000
+++ b/storage/perfschema/pfs_column_types.h 2011-03-16 15:36:35 +0000
@@ -151,11 +151,14 @@ enum enum_operation_type
OPERATION_TYPE_SOCKETSEEK = 51,
OPERATION_TYPE_SOCKETOPT = 52,
OPERATION_TYPE_SOCKETSTAT = 53,
- OPERATION_TYPE_SOCKETSHUTDOWN = 54
+ OPERATION_TYPE_SOCKETSHUTDOWN = 54,
+
+ /* Idle operation */
+ OPERATION_TYPE_IDLE= 55
};
#define FIRST_OPERATION_TYPE (static_cast<int> (OPERATION_TYPE_LOCK))
-#define LAST_OPERATION_TYPE (static_cast<int> (OPERATION_TYPE_SOCKETSHUTDOWN)
+#define LAST_OPERATION_TYPE (static_cast<int> (OPERATION_TYPE_IDLE))
#define COUNT_OPERATION_TYPE (LAST_OPERATION_TYPE - FIRST_OPERATION_TYPE + 1)
enum enum_object_type
=== modified file 'storage/perfschema/pfs_events_waits.h'
--- a/storage/perfschema/pfs_events_waits.h 2011-02-14 23:26:08 +0000
+++ b/storage/perfschema/pfs_events_waits.h 2011-03-16 15:36:35 +0000
@@ -43,7 +43,8 @@ enum events_waits_class
WAIT_CLASS_COND,
WAIT_CLASS_TABLE,
WAIT_CLASS_FILE,
- WAIT_CLASS_SOCKET
+ WAIT_CLASS_SOCKET,
+ WAIT_CLASS_IDLE
};
/** A wait event record. */
=== modified file 'storage/perfschema/pfs_instr.cc'
--- a/storage/perfschema/pfs_instr.cc 2011-03-09 21:28:05 +0000
+++ b/storage/perfschema/pfs_instr.cc 2011-03-16 15:36:35 +0000
@@ -1213,6 +1213,7 @@ PFS_socket* create_socket(PFS_socket_cla
pfs->m_fd= fd;
pfs->m_identity= pfs;
pfs->m_class= klass;
+ pfs->m_idle= false;
pfs->m_wait_stat.reset();
pfs->m_socket_stat.reset();
pfs->m_lock.dirty_to_allocated();
=== modified file 'storage/perfschema/pfs_instr.h'
--- a/storage/perfschema/pfs_instr.h 2011-03-14 16:11:25 +0000
+++ b/storage/perfschema/pfs_instr.h 2011-03-16 15:36:35 +0000
@@ -216,6 +216,8 @@ struct PFS_socket : public PFS_instr
uint m_ip_length;
/** Socket ip port */
uint m_port;
+ /** Idle flag. */
+ bool m_idle;
/** Socket class. */
PFS_socket_class *m_class;
/** Socket usage statistics. */
=== modified file 'storage/perfschema/pfs_instr_class.cc'
--- a/storage/perfschema/pfs_instr_class.cc 2011-03-11 19:52:13 +0000
+++ b/storage/perfschema/pfs_instr_class.cc 2011-03-16 15:36:35 +0000
@@ -113,6 +113,7 @@ PFS_table_share *table_share_array= NULL
PFS_instr_class global_table_io_class;
PFS_instr_class global_table_lock_class;
+PFS_instr_class global_idle_class;
/**
Hash index for instrumented table shares.
@@ -158,7 +159,7 @@ void init_event_name_sizing(const PFS_gl
file_class_start= cond_class_start + param->m_cond_class_sizing;
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 + 2; /* global table io, lock */
+ max_instrument_class= table_class_start + 3; /* 3 global classes */
memcpy(global_table_io_class.m_name, "wait/io/table/sql/handler", 25);
global_table_io_class.m_name_length= 25;
@@ -173,6 +174,13 @@ void init_event_name_sizing(const PFS_gl
global_table_lock_class.m_enabled= true;
global_table_lock_class.m_timed= true;
global_table_lock_class.m_event_name_index= table_class_start + 1;
+
+ memcpy(global_idle_class.m_name, "idle", 4);
+ global_idle_class.m_name_length= 4;
+ global_idle_class.m_flags= 0;
+ global_idle_class.m_enabled= true;
+ global_idle_class.m_timed= true;
+ global_idle_class.m_event_name_index= table_class_start + 2;
}
/**
@@ -874,6 +882,20 @@ PFS_instr_class *sanitize_table_class(PF
return NULL;
}
+PFS_instr_class *find_idle_class(uint index)
+{
+ if (index == 1)
+ return & global_idle_class;
+ return NULL;
+}
+
+PFS_instr_class *sanitize_idle_class(PFS_instr_class *unsafe)
+{
+ if (likely(& global_idle_class == unsafe))
+ return unsafe;
+ return NULL;
+}
+
static void set_keys(PFS_table_share *pfs, const TABLE_SHARE *share)
{
int len;
=== modified file 'storage/perfschema/pfs_instr_class.h'
--- a/storage/perfschema/pfs_instr_class.h 2011-02-25 21:12:43 +0000
+++ b/storage/perfschema/pfs_instr_class.h 2011-03-16 15:36:35 +0000
@@ -271,6 +271,11 @@ extern PFS_instr_class global_table_io_c
*/
extern PFS_instr_class global_table_lock_class;
+/**
+ Instrument controlling all idle waits.
+*/
+extern PFS_instr_class global_idle_class;
+
struct PFS_file;
/** Instrumentation metadata for a file. */
@@ -349,6 +354,8 @@ PFS_instr_class *find_table_class(uint i
PFS_instr_class *sanitize_table_class(PFS_instr_class *unsafe);
PFS_socket_class *find_socket_class(PSI_socket_key key);
PFS_socket_class *sanitize_socket_class(PFS_socket_class *unsafe);
+PFS_instr_class *find_idle_class(uint index);
+PFS_instr_class *sanitize_idle_class(PFS_instr_class *unsafe);
PFS_table_share *find_or_create_table_share(PFS_thread *thread,
bool temporary,
=== modified file 'storage/perfschema/pfs_timer.cc'
--- a/storage/perfschema/pfs_timer.cc 2010-09-23 16:08:54 +0000
+++ b/storage/perfschema/pfs_timer.cc 2011-03-16 15:36:35 +0000
@@ -22,6 +22,7 @@
#include "pfs_timer.h"
#include "my_rdtsc.h"
+enum_timer_name idle_timer= TIMER_NAME_MICROSEC;
enum_timer_name wait_timer= TIMER_NAME_CYCLE;
MY_TIMER_INFO pfs_timer_info;
=== modified file 'storage/perfschema/pfs_timer.h'
--- a/storage/perfschema/pfs_timer.h 2011-02-04 11:55:17 +0000
+++ b/storage/perfschema/pfs_timer.h 2011-03-16 15:36:35 +0000
@@ -50,6 +50,7 @@ struct time_normalizer
ulonglong *pico_start, ulonglong *pico_end, ulonglong *pico_wait);
};
+extern enum_timer_name idle_timer;
extern enum_timer_name wait_timer;
extern MY_TIMER_INFO pfs_timer_info;
=== modified file 'storage/perfschema/pfs_visitor.cc'
--- a/storage/perfschema/pfs_visitor.cc 2011-03-10 17:34:04 +0000
+++ b/storage/perfschema/pfs_visitor.cc 2011-03-16 15:36:35 +0000
@@ -294,8 +294,13 @@ PFS_connection_wait_visitor::~PFS_connec
void PFS_connection_wait_visitor::visit_global()
{
- /* Sum by instances, not by connection */
- DBUG_ASSERT(false);
+ /*
+ This visitor is used only for idle instruments.
+ For waits, do not sum by connection but by instances,
+ it is more efficient.
+ */
+ DBUG_ASSERT(m_index == global_idle_class.m_event_name_index);
+ m_stat.aggregate(& global_instr_class_waits_array[m_index]);
}
void PFS_connection_wait_visitor::visit_thread(PFS_thread *pfs)
=== modified file 'storage/perfschema/table_events_waits.cc'
--- a/storage/perfschema/table_events_waits.cc 2011-02-14 23:26:08 +0000
+++ b/storage/perfschema/table_events_waits.cc 2011-03-16 15:36:35 +0000
@@ -187,6 +187,7 @@ void table_events_waits_common::clear_ob
m_row.m_object_schema_length= 0;
m_row.m_object_name_length= 0;
m_row.m_index_name_length= 0;
+ m_row.m_object_instance_addr= 0;
}
int table_events_waits_common::make_table_object_columns(volatile PFS_events_waits *wait)
@@ -246,6 +247,7 @@ int table_events_waits_common::make_tabl
m_row.m_index_name_length= 0;
}
+ m_row.m_object_instance_addr= (intptr) wait->m_object_instance_addr;
return 0;
}
@@ -260,6 +262,7 @@ int table_events_waits_common::make_file
m_row.m_object_type= "FILE";
m_row.m_object_type_length= 4;
m_row.m_object_schema_length= 0;
+ m_row.m_object_instance_addr= (intptr) wait->m_object_instance_addr;
if (safe_file->get_version() == wait->m_weak_version)
{
@@ -291,6 +294,7 @@ int table_events_waits_common::make_sock
m_row.m_object_type= "SOCKET";
m_row.m_object_type_length= 6;
m_row.m_object_schema_length= 0;
+ m_row.m_object_instance_addr= (intptr) wait->m_object_instance_addr;
if (safe_socket->get_version() == wait->m_weak_version)
{
@@ -371,6 +375,10 @@ void table_events_waits_common::make_row
*/
switch (wait->m_wait_class)
{
+ case WAIT_CLASS_IDLE:
+ clear_object_columns();
+ safe_class= sanitize_idle_class(wait->m_class);
+ break;
case WAIT_CLASS_MUTEX:
clear_object_columns();
safe_class= sanitize_mutex_class((PFS_mutex_class*) wait->m_class);
@@ -416,8 +424,6 @@ void table_events_waits_common::make_row
normalizer->to_pico(wait->m_timer_start, wait->m_timer_end,
& m_row.m_timer_start, & m_row.m_timer_end, & m_row.m_timer_wait);
- m_row.m_object_instance_addr= (intptr) wait->m_object_instance_addr;
-
m_row.m_name= safe_class->m_name;
m_row.m_name_length= safe_class->m_name_length;
@@ -532,7 +538,10 @@ static const LEX_STRING operation_names_
{ C_STRING_WITH_LEN("seek") },
{ C_STRING_WITH_LEN("opt") },
{ C_STRING_WITH_LEN("stat") },
- { C_STRING_WITH_LEN("shutdown") }
+ { C_STRING_WITH_LEN("shutdown") },
+
+ /* Idle operations */
+ { C_STRING_WITH_LEN("idle") }
};
@@ -544,7 +553,8 @@ int table_events_waits_common::read_row_
Field *f;
const LEX_STRING *operation;
-//TBD 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_ews_by_thread_by_event_name.cc'
--- a/storage/perfschema/table_ews_by_thread_by_event_name.cc 2011-02-23 21:13:48 +0000
+++ b/storage/perfschema/table_ews_by_thread_by_event_name.cc 2011-03-16 15:36:35 +0000
@@ -153,6 +153,9 @@ int table_ews_by_thread_by_event_name::r
case pos_ews_by_thread_by_event_name::VIEW_SOCKET:
instr_class= find_socket_class(m_pos.m_index_3);
break;
+ case pos_ews_by_thread_by_event_name::VIEW_IDLE:
+ instr_class= find_idle_class(m_pos.m_index_3);
+ break;
default:
DBUG_ASSERT(false);
instr_class= NULL;
=== modified file 'storage/perfschema/table_ews_global_by_event_name.cc'
--- a/storage/perfschema/table_ews_global_by_event_name.cc 2011-02-12 00:22:15 +0000
+++ b/storage/perfschema/table_ews_global_by_event_name.cc 2011-03-16 15:36:35 +0000
@@ -119,6 +119,7 @@ int table_ews_global_by_event_name::rnd_
PFS_cond_class *cond_class;
PFS_file_class *file_class;
PFS_socket_class *socket_class;
+ PFS_instr_class *instr_class;
if (global_instr_class_waits_array == NULL)
return HA_ERR_END_OF_FILE;
@@ -188,6 +189,15 @@ int table_ews_global_by_event_name::rnd_
return 0;
}
break;
+ case pos_ews_global_by_event_name::VIEW_IDLE:
+ instr_class= find_idle_class(m_pos.m_index_2);
+ if (instr_class)
+ {
+ make_idle_row(instr_class);
+ m_next_pos.set_after(&m_pos);
+ return 0;
+ }
+ break;
default:
break;
}
@@ -204,6 +214,7 @@ table_ews_global_by_event_name::rnd_pos(
PFS_cond_class *cond_class;
PFS_file_class *file_class;
PFS_socket_class *socket_class;
+ PFS_instr_class *instr_class;
set_position(pos);
@@ -260,6 +271,14 @@ table_ews_global_by_event_name::rnd_pos(
return 0;
}
break;
+ case pos_ews_global_by_event_name::VIEW_IDLE:
+ instr_class= find_idle_class(m_pos.m_index_2);
+ if (instr_class)
+ {
+ make_idle_row(instr_class);
+ return 0;
+ }
+ break;
}
return HA_ERR_RECORD_DELETED;
@@ -356,6 +375,19 @@ void table_ews_global_by_event_name
m_row_exists= true;
}
+void table_ews_global_by_event_name
+::make_idle_row(PFS_instr_class *klass)
+{
+ m_row.m_event_name.make_row(klass);
+
+ PFS_connection_wait_visitor visitor(klass);
+ PFS_connection_iterator::visit_global(true, &visitor);
+
+ time_normalizer *normalizer= time_normalizer::get(idle_timer);
+ m_row.m_stat.set(normalizer, &visitor.m_stat);
+ m_row_exists= true;
+}
+
int table_ews_global_by_event_name
::read_row_values(TABLE *table, unsigned char *, Field **fields,
bool read_all)
=== modified file 'storage/perfschema/table_ews_global_by_event_name.h'
--- a/storage/perfschema/table_ews_global_by_event_name.h 2011-02-23 21:13:48 +0000
+++ b/storage/perfschema/table_ews_global_by_event_name.h 2011-03-16 15:36:35 +0000
@@ -106,6 +106,7 @@ protected:
void make_table_io_row(PFS_instr_class *klass);
void make_table_lock_row(PFS_instr_class *klass);
void make_socket_row(PFS_socket_class *klass);
+ void make_idle_row(PFS_instr_class *klass);
private:
/** Table share lock. */
=== modified file 'storage/perfschema/table_helper.h'
--- a/storage/perfschema/table_helper.h 2011-03-09 21:28:05 +0000
+++ b/storage/perfschema/table_helper.h 2011-03-16 15:36:35 +0000
@@ -42,7 +42,8 @@ struct PFS_instrument_view_constants
static const uint VIEW_FILE= 4;
static const uint VIEW_TABLE= 5;
static const uint VIEW_SOCKET= 6;
- static const uint LAST_VIEW= 6;
+ static const uint VIEW_IDLE= 7;
+ static const uint LAST_VIEW= 7;
};
/** Namespace, internal views used within object summaries. */
=== modified file 'storage/perfschema/table_setup_instruments.cc'
--- a/storage/perfschema/table_setup_instruments.cc 2011-02-23 21:13:48 +0000
+++ b/storage/perfschema/table_setup_instruments.cc 2011-03-16 15:36:35 +0000
@@ -102,9 +102,6 @@ int table_setup_instruments::rnd_next(vo
case pos_setup_instruments::VIEW_COND:
instr_class= find_cond_class(m_pos.m_index_2);
break;
- case pos_setup_instruments::VIEW_THREAD:
- /* Not used yet */
- break;
case pos_setup_instruments::VIEW_FILE:
instr_class= find_file_class(m_pos.m_index_2);
break;
@@ -114,6 +111,9 @@ int table_setup_instruments::rnd_next(vo
case pos_setup_instruments::VIEW_SOCKET:
instr_class= find_socket_class(m_pos.m_index_2);
break;
+ case pos_setup_instruments::VIEW_IDLE:
+ instr_class= find_idle_class(m_pos.m_index_2);
+ break;
}
if (instr_class)
{
@@ -143,9 +143,6 @@ int table_setup_instruments::rnd_pos(con
case pos_setup_instruments::VIEW_COND:
instr_class= find_cond_class(m_pos.m_index_2);
break;
- case pos_setup_instruments::VIEW_THREAD:
- /* Not used yet */
- break;
case pos_setup_instruments::VIEW_FILE:
instr_class= find_file_class(m_pos.m_index_2);
break;
@@ -155,6 +152,9 @@ int table_setup_instruments::rnd_pos(con
case pos_setup_instruments::VIEW_SOCKET:
instr_class= find_table_class(m_pos.m_index_2);
break;
+ case pos_setup_instruments::VIEW_IDLE:
+ instr_class= find_idle_class(m_pos.m_index_2);
+ break;
}
if (instr_class)
{
=== modified file 'storage/perfschema/table_setup_instruments.h'
--- a/storage/perfschema/table_setup_instruments.h 2010-12-08 03:24:30 +0000
+++ b/storage/perfschema/table_setup_instruments.h 2011-03-16 15:36:35 +0000
@@ -23,6 +23,7 @@
#include "pfs_instr_class.h"
#include "pfs_engine_table.h"
+#include "table_helper.h"
/**
@addtogroup Performance_schema_tables
@@ -43,19 +44,8 @@ struct row_setup_instruments
};
/** Position of a cursor on PERFORMANCE_SCHEMA.SETUP_INSTRUMENTS. */
-struct pos_setup_instruments : public PFS_double_index
+struct pos_setup_instruments : public PFS_double_index, PFS_instrument_view_constants
{
- static const uint FIRST_VIEW= 1;
- static const uint VIEW_MUTEX= 1;
- static const uint VIEW_RWLOCK= 2;
- static const uint VIEW_COND= 3;
- /** Reverved for WL#4674, PERFORMANCE_SCHEMA Setup For Actors. */
- static const uint VIEW_THREAD= 4;
- static const uint VIEW_FILE= 5;
- static const uint VIEW_TABLE= 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_setup_timers.cc'
--- a/storage/perfschema/table_setup_timers.cc 2010-12-01 18:46:51 +0000
+++ b/storage/perfschema/table_setup_timers.cc 2011-03-16 15:36:35 +0000
@@ -24,10 +24,14 @@
#include "pfs_column_values.h"
#include "pfs_timer.h"
-#define COUNT_SETUP_TIMERS 1
+#define COUNT_SETUP_TIMERS 2
static row_setup_timers all_setup_timers_data[COUNT_SETUP_TIMERS]=
{
{
+ { C_STRING_WITH_LEN("idle") },
+ &idle_timer
+ },
+ {
{ C_STRING_WITH_LEN("wait") },
&wait_timer
}
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-trunk branch (marc.alff:3258 to 3259) WL#4896 | Marc Alff | 16 Mar |