#At file:///home/malff/BZR-TREE/mysql-6.0-perf/
2740 Marc Alff 2008-11-20
Implemented ACTS_WAITS_HISTORY, ACTS_WAITS_HISTORY_LONG, rwlock instrumentation, cond instrumentation
removed:
storage/perfschema/table_acts_waits_current.cc
storage/perfschema/table_acts_waits_current.h
added:
mysql-test/suite/perfschema/r/dml_acts_waits_history.result
mysql-test/suite/perfschema/r/dml_acts_waits_history_long.result
mysql-test/suite/perfschema/t/dml_acts_waits_history.test
mysql-test/suite/perfschema/t/dml_acts_waits_history_long.test
storage/perfschema/table_acts_waits.cc
storage/perfschema/table_acts_waits.h
modified:
include/mysql/psi.h
mysql-test/suite/perfschema/r/dml_acts_waits_current.result
mysql-test/suite/perfschema/r/dml_setup_consumers.result
mysql-test/suite/perfschema/r/information_schema.result
mysql-test/suite/perfschema/r/schema.result
mysql-test/suite/perfschema/t/dml_acts_waits_current.test
mysql-test/suite/perfschema/t/schema.test
storage/perfschema/Makefile.am
storage/perfschema/pse.cc
storage/perfschema/pse_acts_waits.cc
storage/perfschema/pse_acts_waits.h
storage/perfschema/pse_bootstrap.cc
storage/perfschema/pse_sync.cc
storage/perfschema/pse_sync.h
storage/perfschema/pse_table.cc
=== modified file 'include/mysql/psi.h'
--- a/include/mysql/psi.h 2008-11-11 17:09:18 +0000
+++ b/include/mysql/psi.h 2008-11-20 16:31:49 +0000
@@ -358,7 +358,7 @@ struct PSI_v1
Get the instrumentation for the running thread.
For this function to return a result,
the thread instrumentation must have been attached to the
- running thread using @c get_thread()
+ running thread using @c set_thread()
@return the instrumentation for the running thread
*/
struct PSI_thread* (*get_thread)();
@@ -411,12 +411,6 @@ struct PSI_v1
struct PSI_locker* (*get_thread_cond_locker)(struct PSI_cond *cond,
struct PSI_mutex *mutex);
-
-
-
-
-
-
/**
Get a mutex locker.
@param thread the instrumentation for the current thread
=== modified file 'mysql-test/suite/perfschema/r/dml_acts_waits_current.result'
--- a/mysql-test/suite/perfschema/r/dml_acts_waits_current.result 2008-11-18 00:20:30 +0000
+++ b/mysql-test/suite/perfschema/r/dml_acts_waits_current.result 2008-11-20 16:31:49 +0000
@@ -1,6 +1,7 @@
-select * from performance_schema.acts_waits_current limit 1;
+select * from performance_schema.acts_waits_current
+where act_name='Wait/Synch/Mutex/Sql/LOCK_thread_count' limit 1;
THREAD_ID ACT_ID ACT_NAME TIMER_START TIMER_END TIMER_WAIT SPINS OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME OBJECT_INSTANCE_BEGIN
-1 # Wait/Synch/Mutex/mysys/THR_LOCK_malloc # # # NULL NULL NULL NULL #
+# # Wait/Synch/Mutex/Sql/LOCK_thread_count # # # NULL NULL NULL NULL #
select * from performance_schema.acts_waits_current
where act_name='FOO';
THREAD_ID ACT_ID ACT_NAME TIMER_START TIMER_END TIMER_WAIT SPINS OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME OBJECT_INSTANCE_BEGIN
=== added file 'mysql-test/suite/perfschema/r/dml_acts_waits_history.result'
--- a/mysql-test/suite/perfschema/r/dml_acts_waits_history.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/dml_acts_waits_history.result 2008-11-20 16:31:49 +0000
@@ -0,0 +1,22 @@
+select * from performance_schema.acts_waits_history
+where act_name='Wait/Synch/Mutex/Sql/LOCK_thread_count' limit 1;
+THREAD_ID ACT_ID ACT_NAME TIMER_START TIMER_END TIMER_WAIT SPINS OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME OBJECT_INSTANCE_BEGIN
+# # Wait/Synch/Mutex/Sql/LOCK_thread_count # # # NULL NULL NULL NULL #
+select * from performance_schema.acts_waits_history
+where act_name='FOO';
+THREAD_ID ACT_ID ACT_NAME TIMER_START TIMER_END TIMER_WAIT SPINS OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME OBJECT_INSTANCE_BEGIN
+insert into performance_schema.acts_waits_history
+set thread_id='1', act_id=1,
+act_name='FOO', timer_start=1, timer_end=2, timer_wait=3;
+ERROR HY000: Table storage engine for 'acts_waits_history' doesn't have this option
+update performance_schema.acts_waits_history
+set timer_start=12;
+ERROR HY000: Table storage engine for 'acts_waits_history' doesn't have this option
+update performance_schema.acts_waits_history
+set timer_start=12 where thread_id=0;
+ERROR HY000: Table storage engine for 'acts_waits_history' doesn't have this option
+delete from performance_schema.acts_waits_history;
+ERROR HY000: Table storage engine for 'acts_waits_history' doesn't have this option
+delete from performance_schema.acts_waits_history
+where thread_id=1;
+ERROR HY000: Table storage engine for 'acts_waits_history' doesn't have this option
=== added file 'mysql-test/suite/perfschema/r/dml_acts_waits_history_long.result'
--- a/mysql-test/suite/perfschema/r/dml_acts_waits_history_long.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/dml_acts_waits_history_long.result 2008-11-20 16:31:49 +0000
@@ -0,0 +1,22 @@
+select * from performance_schema.acts_waits_history
+where act_name='Wait/Synch/Mutex/Sql/LOCK_thread_count' limit 1;
+THREAD_ID ACT_ID ACT_NAME TIMER_START TIMER_END TIMER_WAIT SPINS OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME OBJECT_INSTANCE_BEGIN
+# # Wait/Synch/Mutex/Sql/LOCK_thread_count # # # NULL NULL NULL NULL #
+select * from performance_schema.acts_waits_history
+where act_name='FOO';
+THREAD_ID ACT_ID ACT_NAME TIMER_START TIMER_END TIMER_WAIT SPINS OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME OBJECT_INSTANCE_BEGIN
+insert into performance_schema.acts_waits_history
+set thread_id='1', act_id=1,
+act_name='FOO', timer_start=1, timer_end=2, timer_wait=3;
+ERROR HY000: Table storage engine for 'acts_waits_history' doesn't have this option
+update performance_schema.acts_waits_history
+set timer_start=12;
+ERROR HY000: Table storage engine for 'acts_waits_history' doesn't have this option
+update performance_schema.acts_waits_history
+set timer_start=12 where thread_id=0;
+ERROR HY000: Table storage engine for 'acts_waits_history' doesn't have this option
+delete from performance_schema.acts_waits_history;
+ERROR HY000: Table storage engine for 'acts_waits_history' doesn't have this option
+delete from performance_schema.acts_waits_history
+where thread_id=1;
+ERROR HY000: Table storage engine for 'acts_waits_history' doesn't have this option
=== modified file 'mysql-test/suite/perfschema/r/dml_setup_consumers.result'
--- a/mysql-test/suite/perfschema/r/dml_setup_consumers.result 2008-11-12 22:15:30 +0000
+++ b/mysql-test/suite/perfschema/r/dml_setup_consumers.result 2008-11-20 16:31:49 +0000
@@ -2,7 +2,7 @@ select * from performance_schema.setup_c
NAME ENABLED NUMBER_OF_ROWS_FILLED
acts_waits_current YES 0
acts_waits_history YES 0
-acts_waits_history_long NO 0
+acts_waits_history_long YES 0
select * from performance_schema.setup_consumers
where name='acts_waits_current';
NAME ENABLED NUMBER_OF_ROWS_FILLED
@@ -12,10 +12,10 @@ where enabled='YES';
NAME ENABLED NUMBER_OF_ROWS_FILLED
acts_waits_current YES 0
acts_waits_history YES 0
+acts_waits_history_long YES 0
select * from performance_schema.setup_consumers
where enabled='NO';
NAME ENABLED NUMBER_OF_ROWS_FILLED
-acts_waits_history_long NO 0
insert into performance_schema.setup_consumers
set name='FOO', enabled='YES', number_of_rows_filled=0;
ERROR HY000: Table storage engine for 'setup_consumers' doesn't have this option
=== modified file 'mysql-test/suite/perfschema/r/information_schema.result'
--- a/mysql-test/suite/perfschema/r/information_schema.result 2008-11-12 22:15:30 +0000
+++ b/mysql-test/suite/perfschema/r/information_schema.result 2008-11-20 16:31:49 +0000
@@ -3,6 +3,8 @@ from information_schema.tables
where TABLE_SCHEMA='performance_schema';
TABLE_SCHEMA TABLE_NAME TABLE_CATALOG
performance_schema acts_waits_current NULL
+performance_schema acts_waits_history NULL
+performance_schema acts_waits_history_long NULL
performance_schema performance_timers NULL
performance_schema processlist NULL
performance_schema setup_actors NULL
@@ -14,6 +16,8 @@ from information_schema.tables
where TABLE_SCHEMA='performance_schema';
TABLE_NAME TABLE_TYPE ENGINE
acts_waits_current BASE TABLE PERFORMANCE_SCHEMA
+acts_waits_history BASE TABLE PERFORMANCE_SCHEMA
+acts_waits_history_long BASE TABLE PERFORMANCE_SCHEMA
performance_timers BASE TABLE PERFORMANCE_SCHEMA
processlist BASE TABLE PERFORMANCE_SCHEMA
setup_actors BASE TABLE PERFORMANCE_SCHEMA
@@ -25,6 +29,8 @@ from information_schema.tables
where TABLE_SCHEMA='performance_schema';
TABLE_NAME VERSION ROW_FORMAT
acts_waits_current 10 Dynamic
+acts_waits_history 10 Dynamic
+acts_waits_history_long 10 Dynamic
performance_timers 10 Fixed
processlist 10 Dynamic
setup_actors 10 Dynamic
@@ -36,6 +42,8 @@ from information_schema.tables
where TABLE_SCHEMA='performance_schema';
TABLE_NAME TABLE_ROWS AVG_ROW_LENGTH
acts_waits_current 1000 0
+acts_waits_history 1000 0
+acts_waits_history_long 1000 0
performance_timers 5 0
processlist 1000 0
setup_actors 99 0
@@ -47,6 +55,8 @@ from information_schema.tables
where TABLE_SCHEMA='performance_schema';
TABLE_NAME DATA_LENGTH MAX_DATA_LENGTH
acts_waits_current 0 0
+acts_waits_history 0 0
+acts_waits_history_long 0 0
performance_timers 0 0
processlist 0 0
setup_actors 0 0
@@ -58,6 +68,8 @@ from information_schema.tables
where TABLE_SCHEMA='performance_schema';
TABLE_NAME INDEX_LENGTH DATA_FREE AUTO_INCREMENT
acts_waits_current 0 0 NULL
+acts_waits_history 0 0 NULL
+acts_waits_history_long 0 0 NULL
performance_timers 0 0 NULL
processlist 0 0 NULL
setup_actors 0 0 NULL
@@ -69,6 +81,8 @@ from information_schema.tables
where TABLE_SCHEMA='performance_schema';
TABLE_NAME CREATE_TIME UPDATE_TIME CHECK_TIME
acts_waits_current NULL NULL NULL
+acts_waits_history NULL NULL NULL
+acts_waits_history_long NULL NULL NULL
performance_timers NULL NULL NULL
processlist NULL NULL NULL
setup_actors NULL NULL NULL
@@ -80,6 +94,8 @@ from information_schema.tables
where TABLE_SCHEMA='performance_schema';
TABLE_NAME TABLE_COLLATION CHECKSUM
acts_waits_current utf8_general_ci NULL
+acts_waits_history utf8_general_ci NULL
+acts_waits_history_long utf8_general_ci NULL
performance_timers utf8_general_ci NULL
processlist utf8_general_ci NULL
setup_actors utf8_general_ci NULL
@@ -91,6 +107,8 @@ from information_schema.tables
where TABLE_SCHEMA='performance_schema';
TABLE_NAME CREATE_OPTIONS TABLESPACE_NAME
acts_waits_current NULL
+acts_waits_history NULL
+acts_waits_history_long NULL
performance_timers NULL
processlist NULL
setup_actors NULL
@@ -102,6 +120,8 @@ from information_schema.tables
where TABLE_SCHEMA='performance_schema';
TABLE_NAME TABLE_COMMENT
acts_waits_current
+acts_waits_history
+acts_waits_history_long
performance_timers
processlist
setup_actors
=== modified file 'mysql-test/suite/perfschema/r/schema.result'
--- a/mysql-test/suite/perfschema/r/schema.result 2008-11-12 22:15:30 +0000
+++ b/mysql-test/suite/perfschema/r/schema.result 2008-11-20 16:31:49 +0000
@@ -8,12 +8,74 @@ use performance_schema;
show tables;
Tables_in_performance_schema
acts_waits_current
+acts_waits_history
+acts_waits_history_long
performance_timers
processlist
setup_actors
setup_consumers
setup_instruments
setup_timers
+show create table performance_schema.acts_waits_current;
+Table Create Table
+acts_waits_current CREATE TABLE `acts_waits_current` (
+ `THREAD_ID` int(11) NOT NULL,
+ `ACT_ID` bigint(20) NOT NULL,
+ `ACT_NAME` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
+ `TIMER_START` bigint(20) DEFAULT NULL,
+ `TIMER_END` bigint(20) DEFAULT NULL,
+ `TIMER_WAIT` bigint(20) DEFAULT NULL,
+ `SPINS` int(11) DEFAULT NULL,
+ `OBJECT_TYPE` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
+ `OBJECT_SCHEMA` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
+ `OBJECT_NAME` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
+ `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL
+) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
+show create table performance_schema.acts_waits_history;
+Table Create Table
+acts_waits_history CREATE TABLE `acts_waits_history` (
+ `THREAD_ID` int(11) NOT NULL,
+ `ACT_ID` bigint(20) NOT NULL,
+ `ACT_NAME` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
+ `TIMER_START` bigint(20) DEFAULT NULL,
+ `TIMER_END` bigint(20) DEFAULT NULL,
+ `TIMER_WAIT` bigint(20) DEFAULT NULL,
+ `SPINS` int(11) DEFAULT NULL,
+ `OBJECT_TYPE` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
+ `OBJECT_SCHEMA` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
+ `OBJECT_NAME` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
+ `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL
+) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
+show create table performance_schema.acts_waits_history_long;
+Table Create Table
+acts_waits_history_long CREATE TABLE `acts_waits_history_long` (
+ `THREAD_ID` int(11) NOT NULL,
+ `ACT_ID` bigint(20) NOT NULL,
+ `ACT_NAME` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
+ `TIMER_START` bigint(20) DEFAULT NULL,
+ `TIMER_END` bigint(20) DEFAULT NULL,
+ `TIMER_WAIT` bigint(20) DEFAULT NULL,
+ `SPINS` int(11) DEFAULT NULL,
+ `OBJECT_TYPE` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
+ `OBJECT_SCHEMA` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
+ `OBJECT_NAME` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
+ `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL
+) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
+show create table performance_schema.performance_timers;
+Table Create Table
+performance_timers CREATE TABLE `performance_timers` (
+ `TIMER_NAME` enum('CYCLE','NANOSECOND','MICROSECOND','MILLISECOND','TICK') NOT NULL,
+ `TIMER_FREQUENCY` bigint(20) NOT NULL,
+ `TIMER_INTERVAL` bigint(20) NOT NULL,
+ `TIMER_OVERHEAD` bigint(20) NOT NULL
+) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
+show create table performance_schema.processlist;
+Table Create Table
+processlist CREATE TABLE `processlist` (
+ `THREAD_ID` int(11) NOT NULL,
+ `ID` int(11) NOT NULL,
+ `NAME` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL
+) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
show create table performance_schema.setup_actors;
Table Create Table
setup_actors CREATE TABLE `setup_actors` (
@@ -41,11 +103,3 @@ setup_timers CREATE TABLE `setup_timers`
`NAME` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`TIMER_NAME` enum('CYCLE','NANOSECOND','MICROSECOND','MILLISECOND','TICK') NOT NULL
) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table performance_schema.performance_timers;
-Table Create Table
-performance_timers CREATE TABLE `performance_timers` (
- `TIMER_NAME` enum('CYCLE','NANOSECOND','MICROSECOND','MILLISECOND','TICK') NOT NULL,
- `TIMER_FREQUENCY` bigint(20) NOT NULL,
- `TIMER_INTERVAL` bigint(20) NOT NULL,
- `TIMER_OVERHEAD` bigint(20) NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
=== modified file 'mysql-test/suite/perfschema/t/dml_acts_waits_current.test'
--- a/mysql-test/suite/perfschema/t/dml_acts_waits_current.test 2008-11-13 02:20:15 +0000
+++ b/mysql-test/suite/perfschema/t/dml_acts_waits_current.test 2008-11-20 16:31:49 +0000
@@ -1,6 +1,7 @@
---replace_column 2 # 4 # 5 # 6 # 11 #
-select * from performance_schema.acts_waits_current limit 1;
+--replace_column 1 # 2 # 4 # 5 # 6 # 11 #
+select * from performance_schema.acts_waits_current
+ where act_name='Wait/Synch/Mutex/Sql/LOCK_thread_count' limit 1;
select * from performance_schema.acts_waits_current
where act_name='FOO';
=== added file 'mysql-test/suite/perfschema/t/dml_acts_waits_history.test'
--- a/mysql-test/suite/perfschema/t/dml_acts_waits_history.test 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/dml_acts_waits_history.test 2008-11-20 16:31:49 +0000
@@ -0,0 +1,29 @@
+
+--replace_column 1 # 2 # 4 # 5 # 6 # 11 #
+select * from performance_schema.acts_waits_history
+ where act_name='Wait/Synch/Mutex/Sql/LOCK_thread_count' limit 1;
+
+select * from performance_schema.acts_waits_history
+ where act_name='FOO';
+
+--error ER_ILLEGAL_HA
+insert into performance_schema.acts_waits_history
+ set thread_id='1', act_id=1,
+ act_name='FOO', timer_start=1, timer_end=2, timer_wait=3;
+
+--error ER_ILLEGAL_HA
+update performance_schema.acts_waits_history
+ set timer_start=12;
+
+--error ER_ILLEGAL_HA
+update performance_schema.acts_waits_history
+ set timer_start=12 where thread_id=0;
+
+--error ER_ILLEGAL_HA
+delete from performance_schema.acts_waits_history;
+
+--error ER_ILLEGAL_HA
+delete from performance_schema.acts_waits_history
+ where thread_id=1;
+
+
=== added file 'mysql-test/suite/perfschema/t/dml_acts_waits_history_long.test'
--- a/mysql-test/suite/perfschema/t/dml_acts_waits_history_long.test 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/dml_acts_waits_history_long.test 2008-11-20 16:31:49 +0000
@@ -0,0 +1,29 @@
+
+--replace_column 1 # 2 # 4 # 5 # 6 # 11 #
+select * from performance_schema.acts_waits_history
+ where act_name='Wait/Synch/Mutex/Sql/LOCK_thread_count' limit 1;
+
+select * from performance_schema.acts_waits_history
+ where act_name='FOO';
+
+--error ER_ILLEGAL_HA
+insert into performance_schema.acts_waits_history
+ set thread_id='1', act_id=1,
+ act_name='FOO', timer_start=1, timer_end=2, timer_wait=3;
+
+--error ER_ILLEGAL_HA
+update performance_schema.acts_waits_history
+ set timer_start=12;
+
+--error ER_ILLEGAL_HA
+update performance_schema.acts_waits_history
+ set timer_start=12 where thread_id=0;
+
+--error ER_ILLEGAL_HA
+delete from performance_schema.acts_waits_history;
+
+--error ER_ILLEGAL_HA
+delete from performance_schema.acts_waits_history
+ where thread_id=1;
+
+
=== modified file 'mysql-test/suite/perfschema/t/schema.test'
--- a/mysql-test/suite/perfschema/t/schema.test 2008-11-06 17:25:15 +0000
+++ b/mysql-test/suite/perfschema/t/schema.test 2008-11-20 16:31:49 +0000
@@ -5,9 +5,13 @@ use performance_schema;
show tables;
+show create table performance_schema.acts_waits_current;
+show create table performance_schema.acts_waits_history;
+show create table performance_schema.acts_waits_history_long;
+show create table performance_schema.performance_timers;
+show create table performance_schema.processlist;
show create table performance_schema.setup_actors;
show create table performance_schema.setup_consumers;
show create table performance_schema.setup_instruments;
show create table performance_schema.setup_timers;
-show create table performance_schema.performance_timers;
=== modified file 'storage/perfschema/Makefile.am'
--- a/storage/perfschema/Makefile.am 2008-11-13 03:12:30 +0000
+++ b/storage/perfschema/Makefile.am 2008-11-20 16:31:49 +0000
@@ -37,7 +37,7 @@ noinst_HEADERS = ha_perfschema.h pse_tab
pse_column_types.h pse_column_values.h \
table_setup_instruments.h table_performance_timers.h \
table_setup_timers.h table_setup_actors.h \
- table_setup_consumers.h table_acts_waits_current.h \
+ table_setup_consumers.h table_acts_waits.h \
pse_acts_waits.h pse_timer.h table_processlist.h
PSE_SOURCES = ha_perfschema.cc pse_table.cc pse.cc pse_server.cc \
@@ -45,7 +45,7 @@ PSE_SOURCES = ha_perfschema.cc pse_table
pse_bootstrap.cc pse_column_values.cc \
table_setup_instruments.cc table_performance_timers.cc \
table_setup_timers.cc table_setup_actors.cc \
- table_setup_consumers.cc table_acts_waits_current.cc \
+ table_setup_consumers.cc table_acts_waits.cc \
pse_acts_waits.cc pse_timer.cc table_processlist.cc
EXTRA_LIBRARIES = libperfschema.a
=== modified file 'storage/perfschema/pse.cc'
--- a/storage/perfschema/pse.cc 2008-11-13 03:12:30 +0000
+++ b/storage/perfschema/pse.cc 2008-11-20 16:31:49 +0000
@@ -336,7 +336,7 @@ static PSI_locker* get_thread_mutex_lock
PSE_locker *pse_locker;
pse_locker= & pse_thread->m_locker_stack[pse_thread->m_locker_count];
- pse_locker->m_timer_name= TIMER_NAME_CYCLE; // TODO
+ pse_locker->m_timer_name= wait_timer;
pse_locker->m_target.m_mutex= pse_mutex;
pse_locker->m_waits_current.m_thread= pse_thread;
pse_locker->m_waits_current.m_info= pse_mutex->m_info;
@@ -350,28 +350,68 @@ static PSI_locker* get_thread_mutex_lock
static PSI_locker* get_thread_rwlock_locker_v1(PSI_rwlock *rwlock)
{
- PSE_thread *pse;
- pse= my_pthread_getspecific_ptr(PSE_thread*, THR_PSE);
- if (pse)
- {
- PSE_locker dummy;
- PSE_locker *pse= & dummy;
- return (PSI_locker*) pse;
+ PSE_rwlock *pse_rwlock= (PSE_rwlock*) rwlock;
+ PSE_thread *pse_thread;
+ DBUG_ASSERT(pse_rwlock != NULL);
+ DBUG_ASSERT(pse_rwlock->m_info != NULL);
+ if (! pse_rwlock->m_info->m_enabled)
+ return NULL;
+ pse_thread= my_pthread_getspecific_ptr(PSE_thread*, THR_PSE);
+ if (pse_thread == NULL)
+ return NULL;
+ if (! pse_thread->m_enabled)
+ return NULL;
+ if (pse_thread->m_locker_count >= LOCKER_STACK_SIZE)
+ {
+ locker_lost++;
+ return NULL;
}
- return NULL;
+ PSE_locker *pse_locker;
+ pse_locker= & pse_thread->m_locker_stack[pse_thread->m_locker_count];
+
+ pse_locker->m_timer_name= wait_timer;
+ pse_locker->m_target.m_rwlock= pse_rwlock;
+ pse_locker->m_waits_current.m_thread= pse_thread;
+ pse_locker->m_waits_current.m_info= pse_rwlock->m_info;
+ pse_locker->m_waits_current.m_timed= pse_rwlock->m_info->m_timed;
+ pse_locker->m_waits_current.m_identity= pse_rwlock->m_identity;
+ pse_locker->m_waits_current.m_wait_class= WAIT_CLASS_RWLOCK;
+
+ pse_thread->m_locker_count++;
+ return (PSI_locker*) pse_locker;
}
static PSI_locker* get_thread_cond_locker_v1(PSI_cond *cond, PSI_mutex *mutex)
{
- PSE_thread *pse;
- pse= my_pthread_getspecific_ptr(PSE_thread*, THR_PSE);
- if (pse)
- {
- PSE_locker dummy;
- PSE_locker *pse= & dummy;
- return (PSI_locker*) pse;
+ PSE_cond *pse_cond= (PSE_cond*) cond;
+ PSE_thread *pse_thread;
+ DBUG_ASSERT(pse_cond != NULL);
+ DBUG_ASSERT(pse_cond->m_info != NULL);
+ if (! pse_cond->m_info->m_enabled)
+ return NULL;
+ pse_thread= my_pthread_getspecific_ptr(PSE_thread*, THR_PSE);
+ if (pse_thread == NULL)
+ return NULL;
+ if (! pse_thread->m_enabled)
+ return NULL;
+ if (pse_thread->m_locker_count >= LOCKER_STACK_SIZE)
+ {
+ locker_lost++;
+ return NULL;
}
- return NULL;
+ PSE_locker *pse_locker;
+ pse_locker= & pse_thread->m_locker_stack[pse_thread->m_locker_count];
+
+ pse_locker->m_timer_name= wait_timer;
+ pse_locker->m_target.m_cond= pse_cond;
+ pse_locker->m_waits_current.m_thread= pse_thread;
+ pse_locker->m_waits_current.m_info= pse_cond->m_info;
+ pse_locker->m_waits_current.m_timed= pse_cond->m_info->m_timed;
+ pse_locker->m_waits_current.m_identity= pse_cond->m_identity;
+ pse_locker->m_waits_current.m_wait_class= WAIT_CLASS_COND;
+
+ pse_thread->m_locker_count++;
+ return (PSI_locker*) pse_locker;
}
static PSI_locker* get_mutex_locker_v1(PSI_thread *thread, PSI_mutex *mutex)
@@ -462,12 +502,9 @@ static void end_wait_v1(PSI_locker* lock
if (wait->m_timed)
wait->m_timer_end= get_timer_value(pse_locker->m_timer_name);
if (flag_acts_waits_history)
- {
- }
-
+ insert_acts_waits_history(wait->m_thread, wait);
if (flag_acts_waits_history_long)
- {
- }
+ insert_acts_waits_history_long(wait);
}
if (rc == 0)
@@ -483,48 +520,117 @@ static void start_rdwait_v1(PSI_locker*
{
PSE_locker *pse_locker= (PSE_locker*) locker;
DBUG_ASSERT(pse_locker != NULL);
+ DBUG_ASSERT(pse_locker->m_waits_current.m_wait_class == WAIT_CLASS_RWLOCK);
+ if (! flag_acts_waits_current)
+ return;
+ PSE_acts_waits *wait= & pse_locker->m_waits_current;
+ if (wait->m_timed)
+ wait->m_timer_start= get_timer_value_and_actid(pse_locker->m_timer_name,
+ & wait->m_act_id);
+ else
+ wait->m_act_id= get_next_actid();
}
static void end_rdwait_v1(PSI_locker* locker, int rc)
{
PSE_locker *pse_locker= (PSE_locker*) locker;
DBUG_ASSERT(pse_locker != NULL);
-#ifdef LATER
+ PSE_acts_waits *wait= & pse_locker->m_waits_current;
+ DBUG_ASSERT(wait->m_wait_class == WAIT_CLASS_RWLOCK);
+ if (flag_acts_waits_current)
+ {
+ if (wait->m_timed)
+ wait->m_timer_end= get_timer_value(pse_locker->m_timer_name);
+ if (flag_acts_waits_history)
+ insert_acts_waits_history(wait->m_thread, wait);
+ if (flag_acts_waits_history_long)
+ insert_acts_waits_history_long(wait);
+ }
+
if (rc == 0)
- pse_rwlock->m_stat.m_read_count++;
-#endif
+ {
+ PSE_rwlock *rwlock= pse_locker->m_target.m_rwlock;
+ rwlock->m_stat.m_read_count++;
+ }
+ wait->m_thread->m_locker_count--;
}
static void start_wrwait_v1(PSI_locker* locker, int must)
{
PSE_locker *pse_locker= (PSE_locker*) locker;
DBUG_ASSERT(pse_locker != NULL);
+ DBUG_ASSERT(pse_locker->m_waits_current.m_wait_class == WAIT_CLASS_RWLOCK);
+ if (! flag_acts_waits_current)
+ return;
+ PSE_acts_waits *wait= & pse_locker->m_waits_current;
+ if (wait->m_timed)
+ wait->m_timer_start= get_timer_value_and_actid(pse_locker->m_timer_name,
+ & wait->m_act_id);
+ else
+ wait->m_act_id= get_next_actid();
}
static void end_wrwait_v1(PSI_locker* locker, int rc)
{
PSE_locker *pse_locker= (PSE_locker*) locker;
DBUG_ASSERT(pse_locker != NULL);
-#ifdef LATER
+ PSE_acts_waits *wait= & pse_locker->m_waits_current;
+ DBUG_ASSERT(wait->m_wait_class == WAIT_CLASS_RWLOCK);
+ if (flag_acts_waits_current)
+ {
+ if (wait->m_timed)
+ wait->m_timer_end= get_timer_value(pse_locker->m_timer_name);
+ if (flag_acts_waits_history)
+ insert_acts_waits_history(wait->m_thread, wait);
+ if (flag_acts_waits_history_long)
+ insert_acts_waits_history_long(wait);
+ }
+
if (rc == 0)
- pse_rwlock->m_stat.m_write_count++;
-#endif
+ {
+ PSE_rwlock *rwlock= pse_locker->m_target.m_rwlock;
+ rwlock->m_stat.m_write_count++;
+ }
+ wait->m_thread->m_locker_count--;
}
static void start_condwait_v1(PSI_locker* locker, int must)
{
PSE_locker *pse_locker= (PSE_locker*) locker;
DBUG_ASSERT(pse_locker != NULL);
+ DBUG_ASSERT(pse_locker->m_waits_current.m_wait_class == WAIT_CLASS_COND);
+ if (! flag_acts_waits_current)
+ return;
+ PSE_acts_waits *wait= & pse_locker->m_waits_current;
+ if (wait->m_timed)
+ wait->m_timer_start= get_timer_value_and_actid(pse_locker->m_timer_name,
+ & wait->m_act_id);
+ else
+ wait->m_act_id= get_next_actid();
}
static void end_condwait_v1(PSI_locker* locker, int rc)
{
PSE_locker *pse_locker= (PSE_locker*) locker;
DBUG_ASSERT(pse_locker != NULL);
-#ifdef LATER
+ PSE_acts_waits *wait= & pse_locker->m_waits_current;
+ DBUG_ASSERT(wait->m_wait_class == WAIT_CLASS_COND);
+ if (flag_acts_waits_current)
+ {
+ if (wait->m_timed)
+ wait->m_timer_end= get_timer_value(pse_locker->m_timer_name);
+ if (flag_acts_waits_history)
+ insert_acts_waits_history(wait->m_thread, wait);
+ if (flag_acts_waits_history_long)
+ insert_acts_waits_history_long(wait);
+ }
+
if (rc == 0)
- pse_cond->m_stat.m_wait_count++;
-#endif
+ {
+ PSE_cond *cond= pse_locker->m_target.m_cond;
+ cond->m_stat.m_wait_count++;
+ }
+ wait->m_thread->m_locker_count--;
}
struct PSI_v1 PSE_v1=
=== modified file 'storage/perfschema/pse_acts_waits.cc'
--- a/storage/perfschema/pse_acts_waits.cc 2008-11-13 03:12:30 +0000
+++ b/storage/perfschema/pse_acts_waits.cc 2008-11-20 16:31:49 +0000
@@ -14,9 +14,50 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "my_global.h"
+#include "m_string.h"
+#include "pse_sync.h"
#include "pse_acts_waits.h"
bool flag_acts_waits_current= true;
bool flag_acts_waits_history= true;
-bool flag_acts_waits_history_long= false;
+bool flag_acts_waits_history_long= true;
+
+bool acts_waits_history_long_full= false;
+uint acts_waits_history_long_index= 0;
+PSE_acts_waits acts_waits_history_long_array[WAITS_HISTORY_LONG_SIZE];
+
+void insert_acts_waits_history(PSE_thread *thread, PSE_acts_waits *wait)
+{
+ uint index;
+
+ index= thread->m_waits_history_index;
+
+ memcpy_fixed(& thread->m_waits_history[index],
+ wait,
+ sizeof(PSE_acts_waits));
+
+ index++;
+ if (index >= WAITS_HISTORY_SIZE)
+ {
+ index= 0;
+ thread->m_waits_history_full= true;
+ }
+ thread->m_waits_history_index= index;
+}
+
+void insert_acts_waits_history_long(PSE_acts_waits *wait)
+{
+ uint index;
+
+ // TODO: atomic
+ index= acts_waits_history_long_index++;
+
+ index= index % WAITS_HISTORY_LONG_SIZE;
+ if (index == 0)
+ acts_waits_history_long_full= true;
+
+ memcpy_fixed(& acts_waits_history_long_array[index],
+ wait,
+ sizeof(PSE_acts_waits));
+}
=== modified file 'storage/perfschema/pse_acts_waits.h'
--- a/storage/perfschema/pse_acts_waits.h 2008-11-13 03:12:30 +0000
+++ b/storage/perfschema/pse_acts_waits.h 2008-11-20 16:31:49 +0000
@@ -58,9 +58,16 @@ struct PSE_locker
PSE_acts_waits m_waits_current;
};
+void insert_acts_waits_history(PSE_thread *thread, PSE_acts_waits *wait);
+void insert_acts_waits_history_long(PSE_acts_waits *wait);
+
extern bool flag_acts_waits_current;
extern bool flag_acts_waits_history;
extern bool flag_acts_waits_history_long;
+extern bool acts_waits_history_long_full;
+extern uint acts_waits_history_long_index;
+extern PSE_acts_waits acts_waits_history_long_array[];
+
#endif
=== modified file 'storage/perfschema/pse_bootstrap.cc'
--- a/storage/perfschema/pse_bootstrap.cc 2008-11-13 03:12:30 +0000
+++ b/storage/perfschema/pse_bootstrap.cc 2008-11-20 16:31:49 +0000
@@ -34,6 +34,38 @@ const char* pse_bootstrap_queries[]=
"OBJECT_INSTANCE_BEGIN BIGINT not null"
") ENGINE=PERFORMANCE_SCHEMA;"
,
+ "DROP TABLE IF EXISTS performance_schema.acts_waits_history;"
+ ,
+ "CREATE TABLE performance_schema.acts_waits_history("
+ "THREAD_ID INTEGER not null, "
+ "ACT_ID BIGINT not null, "
+ "ACT_NAME VARCHAR(64) character set utf8 collate utf8_unicode_ci not null, "
+ "TIMER_START BIGINT,"
+ "TIMER_END BIGINT,"
+ "TIMER_WAIT BIGINT,"
+ "SPINS INTEGER,"
+ "OBJECT_TYPE VARCHAR(64) character set utf8 collate utf8_unicode_ci, "
+ "OBJECT_SCHEMA VARCHAR(64) character set utf8 collate utf8_unicode_ci, "
+ "OBJECT_NAME VARCHAR(64) character set utf8 collate utf8_unicode_ci, "
+ "OBJECT_INSTANCE_BEGIN BIGINT not null"
+ ") ENGINE=PERFORMANCE_SCHEMA;"
+ ,
+ "DROP TABLE IF EXISTS performance_schema.acts_waits_history_long;"
+ ,
+ "CREATE TABLE performance_schema.acts_waits_history_long("
+ "THREAD_ID INTEGER not null, "
+ "ACT_ID BIGINT not null, "
+ "ACT_NAME VARCHAR(64) character set utf8 collate utf8_unicode_ci not null, "
+ "TIMER_START BIGINT,"
+ "TIMER_END BIGINT,"
+ "TIMER_WAIT BIGINT,"
+ "SPINS INTEGER,"
+ "OBJECT_TYPE VARCHAR(64) character set utf8 collate utf8_unicode_ci, "
+ "OBJECT_SCHEMA VARCHAR(64) character set utf8 collate utf8_unicode_ci, "
+ "OBJECT_NAME VARCHAR(64) character set utf8 collate utf8_unicode_ci, "
+ "OBJECT_INSTANCE_BEGIN BIGINT not null"
+ ") ENGINE=PERFORMANCE_SCHEMA;"
+ ,
"DROP TABLE IF EXISTS performance_schema.setup_actors;"
,
"CREATE TABLE performance_schema.setup_actors("
=== modified file 'storage/perfschema/pse_sync.cc'
--- a/storage/perfschema/pse_sync.cc 2008-11-13 03:12:30 +0000
+++ b/storage/perfschema/pse_sync.cc 2008-11-20 16:31:49 +0000
@@ -212,6 +212,9 @@ PSE_thread* create_thread(PSE_thread_inf
pse->m_enabled= true;
pse->m_identity= identity;
pse->m_info= info;
+ pse->m_locker_count= 0;
+ pse->m_waits_history_full= false;
+ pse->m_waits_history_index= 0;
return pse;
}
}
=== modified file 'storage/perfschema/pse_sync.h'
--- a/storage/perfschema/pse_sync.h 2008-11-13 03:12:30 +0000
+++ b/storage/perfschema/pse_sync.h 2008-11-20 16:31:49 +0000
@@ -68,6 +68,8 @@ struct PSE_cond
};
#define LOCKER_STACK_SIZE 3
+#define WAITS_HISTORY_SIZE 10
+#define WAITS_HISTORY_LONG_SIZE 10000
struct PSE_thread
{
@@ -79,6 +81,9 @@ struct PSE_thread
PSE_thread_info *m_info;
uint m_locker_count;
PSE_locker m_locker_stack[LOCKER_STACK_SIZE];
+ bool m_waits_history_full;
+ uint m_waits_history_index;
+ PSE_acts_waits m_waits_history[WAITS_HISTORY_SIZE];
};
int init_sync(uint mutex_sizing,
=== modified file 'storage/perfschema/pse_table.cc'
--- a/storage/perfschema/pse_table.cc 2008-11-17 23:04:33 +0000
+++ b/storage/perfschema/pse_table.cc 2008-11-20 16:31:49 +0000
@@ -16,7 +16,7 @@
#include "mysql_priv.h"
#include "pse_table.h"
-#include "table_acts_waits_current.h"
+#include "table_acts_waits.h"
#include "table_setup_actors.h"
#include "table_setup_consumers.h"
#include "table_setup_instruments.h"
@@ -27,6 +27,8 @@
static pse_table_info *pse_all_tables[]=
{
& table_acts_waits_current::m_info,
+ & table_acts_waits_history::m_info,
+ & table_acts_waits_history_long::m_info,
& table_setup_actors::m_info,
& table_setup_consumers::m_info,
& table_setup_instruments::m_info,
=== added file 'storage/perfschema/table_acts_waits.cc'
--- a/storage/perfschema/table_acts_waits.cc 1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/table_acts_waits.cc 2008-11-20 16:31:49 +0000
@@ -0,0 +1,416 @@
+/* Copyright (C) 2008 Sun Microsystems, Inc
+
+ 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, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#include "mysql_priv.h"
+#include "table_acts_waits.h"
+#include "pse_sync_info.h"
+#include "pse_sync.h"
+
+pse_table_info
+table_acts_waits_current::m_info=
+{
+ { C_STRING_WITH_LEN("acts_waits_current") },
+ & table_acts_waits_current::create,
+ NULL,
+ 1000, // TODO: records
+ 0, // deleted
+ sizeof(row_acts_waits), // rec length
+ 0, // options
+ sizeof(pos_acts_waits_current), // ref length
+ 1000 // TODO: estimate rows upper bound
+};
+
+pse_table_info
+table_acts_waits_history::m_info=
+{
+ { C_STRING_WITH_LEN("acts_waits_history") },
+ & table_acts_waits_history::create,
+ NULL,
+ 1000, // TODO: records
+ 0, // deleted
+ sizeof(row_acts_waits), // rec length
+ 0, // options
+ sizeof(pos_acts_waits_history), // ref length
+ 1000 // TODO: estimate rows upper bound
+};
+
+pse_table_info
+table_acts_waits_history_long::m_info=
+{
+ { C_STRING_WITH_LEN("acts_waits_history_long") },
+ & table_acts_waits_history_long::create,
+ NULL,
+ 1000, // TODO: records
+ 0, // deleted
+ sizeof(row_acts_waits), // rec length
+ 0, // options
+ sizeof(pos_acts_waits_history_long), // ref length
+ 1000 // TODO: estimate rows upper bound
+};
+
+table_acts_waits_common::table_acts_waits_common()
+{
+ memset(& m_row, 0, sizeof(m_row));
+ m_row_exists= false;
+}
+
+void table_acts_waits_common::make_row(PSE_thread *pse_thread,
+ PSE_acts_waits *wait)
+{
+ m_row.m_thread_internal_id= pse_thread->m_thread_internal_id;
+ m_row.m_act_id= wait->m_act_id;
+ m_row.m_name= wait->m_info->m_name;
+ m_row.m_name_length= wait->m_info->m_name_length;
+ m_row.m_timed= wait->m_timed;
+ m_row.m_timer_start= wait->m_timer_start;
+ m_row.m_timer_end= wait->m_timer_end;
+ m_row.m_object_instance= wait->m_identity;
+ m_row_exists= true;
+}
+
+int table_acts_waits_common::read_row_values(TABLE *table,
+ unsigned char *buf,
+ Field **fields,
+ bool read_all)
+{
+ Field *f;
+ Field_long *col_thread_id;
+ Field_longlong *col_act_id;
+ Field_varstring *col_act_name;
+ Field_longlong *col_timer_start;
+ Field_longlong *col_timer_end;
+ Field_longlong *col_timer_wait;
+ Field_long *col_spins;
+ Field_varstring *col_object_type;
+ Field_varstring *col_object_schema;
+ Field_varstring *col_object_name;
+ Field_longlong *col_object_instance_begin;
+ CHARSET_INFO *cs;
+
+ cs= & my_charset_utf8_bin;
+
+ /* Set the null bits */
+ DBUG_ASSERT(table->s->null_bytes == 1);
+ buf[0]= 0;
+
+ for (; *fields ; fields++)
+ {
+ f= *fields;
+
+ if (read_all || bitmap_is_set(table->read_set, f->field_index))
+ {
+ switch(f->field_index)
+ {
+ case 0:
+ DBUG_ASSERT(f->real_type() == MYSQL_TYPE_LONG);
+ col_thread_id= (Field_long*) f;
+ col_thread_id->store(m_row.m_thread_internal_id);
+ break;
+ case 1:
+ DBUG_ASSERT(f->real_type() == MYSQL_TYPE_LONGLONG);
+ col_act_id= (Field_longlong*) f;
+ col_act_id->store(m_row.m_act_id);
+ break;
+ case 2:
+ DBUG_ASSERT(f->real_type() == MYSQL_TYPE_VARCHAR);
+ col_act_name= (Field_varstring*) f;
+ col_act_name->store(m_row.m_name, m_row.m_name_length, cs);
+ break;
+ case 3:
+ DBUG_ASSERT(f->real_type() == MYSQL_TYPE_LONGLONG);
+ col_timer_start= (Field_longlong*) f;
+ col_timer_start->store(m_row.m_timer_start);
+ break;
+ case 4:
+ DBUG_ASSERT(f->real_type() == MYSQL_TYPE_LONGLONG);
+ col_timer_end= (Field_longlong*) f;
+ col_timer_end->store(m_row.m_timer_end);
+ break;
+ case 5:
+ DBUG_ASSERT(f->real_type() == MYSQL_TYPE_LONGLONG);
+ col_timer_wait= (Field_longlong*) f;
+ col_timer_wait->store(m_row.m_timer_end - m_row.m_timer_start);
+ break;
+ case 6:
+ DBUG_ASSERT(f->real_type() == MYSQL_TYPE_LONG);
+ col_spins= (Field_long*) f;
+ col_spins->set_null();
+ break;
+ case 7:
+ DBUG_ASSERT(f->real_type() == MYSQL_TYPE_VARCHAR);
+ col_object_type= (Field_varstring*) f;
+ col_object_type->set_null();
+ break;
+ case 8:
+ DBUG_ASSERT(f->real_type() == MYSQL_TYPE_VARCHAR);
+ col_object_schema= (Field_varstring*) f;
+ col_object_schema->set_null();
+ break;
+ case 9:
+ DBUG_ASSERT(f->real_type() == MYSQL_TYPE_VARCHAR);
+ col_object_name= (Field_varstring*) f;
+ col_object_name->set_null();
+ break;
+ case 10:
+ DBUG_ASSERT(f->real_type() == MYSQL_TYPE_LONGLONG);
+ col_object_instance_begin= (Field_longlong*) f;
+ col_object_instance_begin->store((intptr) m_row.m_object_instance);
+ break;
+ default:
+ DBUG_ASSERT(false);
+ }
+ }
+ }
+ return 0;
+}
+
+pse_table* table_acts_waits_current::create()
+{
+ return new table_acts_waits_current();
+}
+
+table_acts_waits_current::table_acts_waits_current()
+{
+ m_pos.m_thread_index= 0;
+ m_pos.m_local_index= 0;
+ m_next_local_index= 0;
+}
+
+int table_acts_waits_current::rnd_next(void *ref)
+{
+ PSE_thread *pse_thread;
+ PSE_acts_waits *wait;
+
+ m_pos.m_local_index= m_next_local_index;
+
+ for ( ; m_pos.m_thread_index < thread_max; )
+ {
+ pse_thread= & thread_array[m_pos.m_thread_index];
+
+ if (! pse_thread->m_allocated)
+ {
+ /* This thread does not exist */
+ goto next_thread;
+ }
+
+// #define ONLY_SHOW_CURRENT_WAITS
+
+#ifdef ONLY_SHOW_CURRENT_WAITS
+ if (m_pos.m_local_index >= pse_thread->m_locker_count)
+#else
+ if (m_pos.m_local_index >= LOCKER_STACK_SIZE)
+#endif
+ {
+ /* This thread does not have more locker */
+ goto next_thread;
+ }
+
+ if (pse_thread->m_locker_stack[m_pos.m_local_index]
+ .m_waits_current.m_wait_class == NO_WAIT_CLASS)
+ {
+ /*
+ This locker does not exist.
+ There can not be more lockers in the stack, skip to the next thread
+ */
+ goto next_thread;
+ }
+
+ wait= & pse_thread->m_locker_stack[m_pos.m_local_index].m_waits_current;
+
+ record_position(ref);
+ make_row(pse_thread, wait);
+ /* Next iteration, look for the next locker in this thread */
+ m_next_local_index= m_pos.m_local_index + 1;
+ return 0;
+
+next_thread:
+ m_pos.m_thread_index++;
+ m_pos.m_local_index= 0;
+ }
+
+ return HA_ERR_END_OF_FILE;
+}
+
+int table_acts_waits_current::rnd_pos(void *ref, const void *pos)
+{
+ set_position(pos);
+ if (ref != pos)
+ record_position(ref);
+
+ return HA_ERR_WRONG_COMMAND;
+}
+
+void table_acts_waits_current::record_position(void *ref)
+{
+ memcpy(ref, & m_pos, sizeof(pos_acts_waits_current));
+}
+
+void table_acts_waits_current::set_position(const void *ref)
+{
+ memcpy(& m_pos, ref, sizeof(pos_acts_waits_current));
+}
+
+pse_table* table_acts_waits_history::create()
+{
+ return new table_acts_waits_history();
+}
+
+table_acts_waits_history::table_acts_waits_history()
+{
+ m_pos.m_thread_index= 0;
+ m_pos.m_local_index= 0;
+ m_next_local_index= 0;
+}
+
+int table_acts_waits_history::rnd_next(void *ref)
+{
+ PSE_thread *pse_thread;
+ PSE_acts_waits *wait;
+
+ m_pos.m_local_index= m_next_local_index;
+
+ for ( ; m_pos.m_thread_index < thread_max; )
+ {
+ pse_thread= & thread_array[m_pos.m_thread_index];
+
+ if (! pse_thread->m_allocated)
+ {
+ /* This thread does not exist */
+ goto next_thread;
+ }
+
+ if (m_pos.m_local_index >= WAITS_HISTORY_SIZE)
+ {
+ /* This thread does not have more (full) history */
+ goto next_thread;
+ }
+
+ if ( ! pse_thread->m_waits_history_full &&
+ (m_pos.m_local_index >= pse_thread->m_waits_history_index))
+ {
+ /* This thread does not have more (not full) history */
+ goto next_thread;
+ }
+
+ if (pse_thread->m_waits_history[m_pos.m_local_index].m_wait_class
+ == NO_WAIT_CLASS)
+ {
+ /*
+ This locker does not exist.
+ There can not be more lockers in the stack, skip to the next thread
+ */
+ goto next_thread;
+ }
+
+ wait= & pse_thread->m_waits_history[m_pos.m_local_index];
+
+ record_position(ref);
+ make_row(pse_thread, wait);
+ /* Next iteration, look for the next history in this thread */
+ m_next_local_index= m_pos.m_local_index + 1;
+ return 0;
+
+next_thread:
+ m_pos.m_thread_index++;
+ m_pos.m_local_index= 0;
+ }
+
+ return HA_ERR_END_OF_FILE;
+}
+
+int table_acts_waits_history::rnd_pos(void *ref, const void *pos)
+{
+ set_position(pos);
+ if (ref != pos)
+ record_position(ref);
+
+ return HA_ERR_WRONG_COMMAND;
+}
+
+void table_acts_waits_history::record_position(void *ref)
+{
+ memcpy(ref, & m_pos, sizeof(pos_acts_waits_history));
+}
+
+void table_acts_waits_history::set_position(const void *ref)
+{
+ memcpy(& m_pos, ref, sizeof(pos_acts_waits_history));
+}
+
+pse_table* table_acts_waits_history_long::create()
+{
+ return new table_acts_waits_history_long();
+}
+
+table_acts_waits_history_long::table_acts_waits_history_long()
+{
+ m_pos.m_index= 0;
+ m_next_index= 0;
+}
+
+int table_acts_waits_history_long::rnd_next(void *ref)
+{
+ PSE_acts_waits *wait;
+ uint limit;
+
+ if (acts_waits_history_long_full)
+ limit= WAITS_HISTORY_LONG_SIZE;
+ else
+ limit= acts_waits_history_long_index % WAITS_HISTORY_LONG_SIZE;
+
+ m_pos.m_index= m_next_index;
+
+ for ( ; m_pos.m_index < limit; )
+ {
+ wait= & acts_waits_history_long_array[m_pos.m_index];
+
+ if (wait->m_wait_class == NO_WAIT_CLASS)
+ {
+ /* This wait does not exist */
+ goto next_entry;
+ }
+
+ record_position(ref);
+ make_row(wait->m_thread, wait);
+ /* Next iteration, look for the next entry */
+ m_next_index= m_pos.m_index + 1;
+ return 0;
+
+next_entry:
+ m_pos.m_index++ ;
+ }
+
+ return HA_ERR_END_OF_FILE;
+}
+
+int table_acts_waits_history_long::rnd_pos(void *ref, const void *pos)
+{
+ set_position(pos);
+ if (ref != pos)
+ record_position(ref);
+
+ return HA_ERR_WRONG_COMMAND;
+}
+
+void table_acts_waits_history_long::record_position(void *ref)
+{
+ memcpy(ref, & m_pos, sizeof(pos_acts_waits_history_long));
+}
+
+void table_acts_waits_history_long::set_position(const void *ref)
+{
+ memcpy(& m_pos, ref, sizeof(pos_acts_waits_history_long));
+}
+
=== added file 'storage/perfschema/table_acts_waits.h'
--- a/storage/perfschema/table_acts_waits.h 1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/table_acts_waits.h 2008-11-20 16:31:49 +0000
@@ -0,0 +1,145 @@
+/* Copyright (C) 2008 Sun Microsystems, Inc
+
+ 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, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#ifndef TABLE_ACTS_WAITS_H
+#define TABLE_ACTS_WAITS_H
+
+#include "pse_column_types.h"
+#include "pse_table.h"
+
+struct PSE_thread;
+struct PSE_acts_waits;
+
+struct row_acts_waits
+{
+ ulong m_thread_internal_id;
+ longlong m_act_id;
+ const char* m_name;
+ int m_name_length;
+ bool m_timed;
+ longlong m_timer_start;
+ longlong m_timer_end;
+ longlong m_timer_wait;
+ void * m_object_instance;
+};
+
+struct pos_acts_waits_current
+{
+ uint m_thread_index;
+ uint m_local_index;
+};
+
+struct pos_acts_waits_history
+{
+ uint m_thread_index;
+ uint m_local_index;
+};
+
+struct pos_acts_waits_history_long
+{
+ uint m_index;
+};
+
+class table_acts_waits_common : public pse_readonly_table
+{
+protected:
+ virtual int read_row_values(TABLE *table,
+ unsigned char *buf,
+ Field **fields,
+ bool read_all);
+
+ table_acts_waits_common();
+
+public:
+ ~table_acts_waits_common()
+ {}
+
+protected:
+ void make_row(PSE_thread *pse_thread, PSE_acts_waits *wait);
+
+ row_acts_waits m_row;
+ bool m_row_exists;
+};
+
+class table_acts_waits_current : public table_acts_waits_common
+{
+public:
+ static pse_table_info m_info;
+ static pse_table* create();
+
+ virtual int rnd_next(void *ref);
+ virtual int rnd_pos(void *ref, const void *pos);
+ virtual void record_position(void *ref);
+ virtual void set_position(const void *ref);
+
+protected:
+ table_acts_waits_current();
+
+public:
+ ~table_acts_waits_current()
+ {}
+
+private:
+ pos_acts_waits_current m_pos;
+ uint m_next_local_index;
+};
+
+class table_acts_waits_history : public table_acts_waits_common
+{
+public:
+ static pse_table_info m_info;
+ static pse_table* create();
+
+ virtual int rnd_next(void *ref);
+ virtual int rnd_pos(void *ref, const void *pos);
+ virtual void record_position(void *ref);
+ virtual void set_position(const void *ref);
+
+protected:
+ table_acts_waits_history();
+
+public:
+ ~table_acts_waits_history()
+ {}
+
+private:
+ pos_acts_waits_history m_pos;
+ uint m_next_local_index;
+};
+
+class table_acts_waits_history_long : public table_acts_waits_common
+{
+public:
+ static pse_table_info m_info;
+ static pse_table* create();
+
+ virtual int rnd_next(void *ref);
+ virtual int rnd_pos(void *ref, const void *pos);
+ virtual void record_position(void *ref);
+ virtual void set_position(const void *ref);
+
+protected:
+ table_acts_waits_history_long();
+
+public:
+ ~table_acts_waits_history_long()
+ {}
+
+private:
+ pos_acts_waits_history_long m_pos;
+ uint m_next_index;
+};
+
+#endif
=== removed file 'storage/perfschema/table_acts_waits_current.cc'
--- a/storage/perfschema/table_acts_waits_current.cc 2008-11-17 23:04:33 +0000
+++ b/storage/perfschema/table_acts_waits_current.cc 1970-01-01 00:00:00 +0000
@@ -1,234 +0,0 @@
-/* Copyright (C) 2008 Sun Microsystems, Inc
-
- 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, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-#include "mysql_priv.h"
-#include "table_acts_waits_current.h"
-#include "pse_sync_info.h"
-#include "pse_sync.h"
-
-pse_table_info
-table_acts_waits_current::m_info=
-{
- { C_STRING_WITH_LEN("acts_waits_current") },
- & table_acts_waits_current::create,
- NULL,
- 1000, // TODO: records
- 0, // deleted
- sizeof(row_acts_waits_current), // rec length
- 0, // options
- sizeof(pos_acts_waits_current), // ref length
- 1000 // TODO: estimate rows upper bound
-};
-
-pse_table* table_acts_waits_current::create()
-{
- return new table_acts_waits_current();
-}
-
-table_acts_waits_current::table_acts_waits_current()
-{
- m_pos.m_thread_index= 0;
- m_pos.m_local_index= 0;
- m_next_local_index= 0;
- memset(& m_row, 0, sizeof(m_row));
- m_row_exists= false;
-}
-
-int table_acts_waits_current::rnd_next(void *ref)
-{
- PSE_thread *pse_thread;
- PSE_acts_waits *wait;
-
- m_pos.m_local_index= m_next_local_index;
-
- for ( ; m_pos.m_thread_index < thread_max; )
- {
- pse_thread= & thread_array[m_pos.m_thread_index];
-
- if (! pse_thread->m_allocated)
- {
- /* This thread does not exist, skip to the next thread */
- m_pos.m_thread_index++;
- m_pos.m_local_index= 0;
- continue;
- }
-
-// #define ONLY_SHOW_CURRENT_WAITS
-
-#ifdef ONLY_SHOW_CURRENT_WAITS
- if (m_pos.m_local_index >= pse_thread->m_locker_count)
-#else
- if (m_pos.m_local_index >= LOCKER_STACK_SIZE)
-#endif
- {
- /* This thread does not have more locker, skip to the next thread */
- m_pos.m_thread_index++;
- m_pos.m_local_index= 0;
- continue;
- }
-
- if (pse_thread->m_locker_stack[m_pos.m_local_index]
- .m_waits_current.m_wait_class == NO_WAIT_CLASS)
- {
- /*
- This locker does not exist.
- There can not be more lockers in the stack, skip to the next thread
- */
- m_pos.m_thread_index++;
- m_pos.m_local_index= 0;
- continue;
- }
-
- wait= & pse_thread->m_locker_stack[m_pos.m_local_index].m_waits_current;
-
- record_position(ref);
- make_row(pse_thread, wait);
- /* Next iteration, look for the next locker in this thread */
- m_next_local_index= m_pos.m_local_index + 1;
- return 0;
- }
-
- return HA_ERR_END_OF_FILE;
-}
-
-int table_acts_waits_current::rnd_pos(void *ref, const void *pos)
-{
- set_position(pos);
- if (ref != pos)
- record_position(ref);
-
- return HA_ERR_WRONG_COMMAND;
-}
-
-void table_acts_waits_current::record_position(void *ref)
-{
- memcpy(ref, & m_pos, sizeof(pos_acts_waits_current));
-}
-
-void table_acts_waits_current::set_position(const void *ref)
-{
- memcpy(& m_pos, ref, sizeof(pos_acts_waits_current));
-}
-
-void table_acts_waits_current::make_row(PSE_thread *pse_thread,
- PSE_acts_waits *wait)
-{
- m_row.m_thread_internal_id= pse_thread->m_thread_internal_id;
- m_row.m_act_id= wait->m_act_id;
- m_row.m_name= wait->m_info->m_name;
- m_row.m_name_length= wait->m_info->m_name_length;
- m_row.m_timed= wait->m_timed;
- m_row.m_timer_start= wait->m_timer_start;
- m_row.m_timer_end= wait->m_timer_end;
- m_row.m_object_instance= wait->m_identity;
- m_row_exists= true;
-}
-
-int table_acts_waits_current::read_row_values(TABLE *table,
- unsigned char *buf,
- Field **fields,
- bool read_all)
-{
- Field *f;
- Field_long *col_thread_id;
- Field_longlong *col_act_id;
- Field_varstring *col_act_name;
- Field_longlong *col_timer_start;
- Field_longlong *col_timer_end;
- Field_longlong *col_timer_wait;
- Field_long *col_spins;
- Field_varstring *col_object_type;
- Field_varstring *col_object_schema;
- Field_varstring *col_object_name;
- Field_longlong *col_object_instance_begin;
- CHARSET_INFO *cs;
-
- cs= & my_charset_utf8_bin;
-
- /* Set the null bits */
- DBUG_ASSERT(table->s->null_bytes == 1);
- buf[0]= 0;
-
- for (; *fields ; fields++)
- {
- f= *fields;
-
- if (read_all || bitmap_is_set(table->read_set, f->field_index))
- {
- switch(f->field_index)
- {
- case 0:
- DBUG_ASSERT(f->real_type() == MYSQL_TYPE_LONG);
- col_thread_id= (Field_long*) f;
- col_thread_id->store(m_row.m_thread_internal_id);
- break;
- case 1:
- DBUG_ASSERT(f->real_type() == MYSQL_TYPE_LONGLONG);
- col_act_id= (Field_longlong*) f;
- col_act_id->store(m_row.m_act_id);
- break;
- case 2:
- DBUG_ASSERT(f->real_type() == MYSQL_TYPE_VARCHAR);
- col_act_name= (Field_varstring*) f;
- col_act_name->store(m_row.m_name, m_row.m_name_length, cs);
- break;
- case 3:
- DBUG_ASSERT(f->real_type() == MYSQL_TYPE_LONGLONG);
- col_timer_start= (Field_longlong*) f;
- col_timer_start->store(m_row.m_timer_start);
- break;
- case 4:
- DBUG_ASSERT(f->real_type() == MYSQL_TYPE_LONGLONG);
- col_timer_end= (Field_longlong*) f;
- col_timer_end->store(m_row.m_timer_end);
- break;
- case 5:
- DBUG_ASSERT(f->real_type() == MYSQL_TYPE_LONGLONG);
- col_timer_wait= (Field_longlong*) f;
- col_timer_wait->store(m_row.m_timer_end - m_row.m_timer_start);
- break;
- case 6:
- DBUG_ASSERT(f->real_type() == MYSQL_TYPE_LONG);
- col_spins= (Field_long*) f;
- col_spins->set_null();
- break;
- case 7:
- DBUG_ASSERT(f->real_type() == MYSQL_TYPE_VARCHAR);
- col_object_type= (Field_varstring*) f;
- col_object_type->set_null();
- break;
- case 8:
- DBUG_ASSERT(f->real_type() == MYSQL_TYPE_VARCHAR);
- col_object_schema= (Field_varstring*) f;
- col_object_schema->set_null();
- break;
- case 9:
- DBUG_ASSERT(f->real_type() == MYSQL_TYPE_VARCHAR);
- col_object_name= (Field_varstring*) f;
- col_object_name->set_null();
- break;
- case 10:
- DBUG_ASSERT(f->real_type() == MYSQL_TYPE_LONGLONG);
- col_object_instance_begin= (Field_longlong*) f;
- col_object_instance_begin->store((intptr) m_row.m_object_instance);
- break;
- default:
- DBUG_ASSERT(false);
- }
- }
- }
- return 0;
-}
-
=== removed file 'storage/perfschema/table_acts_waits_current.h'
--- a/storage/perfschema/table_acts_waits_current.h 2008-11-17 23:04:33 +0000
+++ b/storage/perfschema/table_acts_waits_current.h 1970-01-01 00:00:00 +0000
@@ -1,77 +0,0 @@
-/* Copyright (C) 2008 Sun Microsystems, Inc
-
- 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, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-#ifndef TABLE_ACTS_WAITS_CURRENT_H
-#define TABLE_ACTS_WAITS_CURRENT_H
-
-#include "pse_column_types.h"
-#include "pse_table.h"
-
-struct PSE_thread;
-struct PSE_acts_waits;
-
-struct row_acts_waits_current
-{
- ulong m_thread_internal_id;
- longlong m_act_id;
- const char* m_name;
- int m_name_length;
- bool m_timed;
- longlong m_timer_start;
- longlong m_timer_end;
- longlong m_timer_wait;
- void * m_object_instance;
-};
-
-struct pos_acts_waits_current
-{
- uint m_thread_index;
- uint m_local_index;
-};
-
-class table_acts_waits_current : public pse_readonly_table
-{
-public:
- static pse_table_info m_info;
- static pse_table* create();
-
- virtual int rnd_next(void *ref);
- virtual int rnd_pos(void *ref, const void *pos);
- virtual void record_position(void *ref);
- virtual void set_position(const void *ref);
-
-protected:
- virtual int read_row_values(TABLE *table,
- unsigned char *buf,
- Field **fields,
- bool read_all);
-
-protected:
- table_acts_waits_current();
-
-public:
- ~table_acts_waits_current()
- {}
-
-private:
- void make_row(PSE_thread *pse_thread, PSE_acts_waits *wait);
-
- pos_acts_waits_current m_pos;
- uint m_next_local_index;
- row_acts_waits_current m_row;
- bool m_row_exists;
-};
-
-#endif
| Thread |
|---|
| • bzr commit into mysql-6.0-perf branch (marc.alff:2740) | Marc Alff | 20 Nov |