#At file:///home/malff/BZR-TREE/mysql-6.0-perfschema/ based on revid:marc.alff@stripped
3152 Marc Alff 2009-05-26
Misc cleanup
Fixed a build issue with Windows in pthread_create
modified:
include/my_pthread.h
include/mysql/psi/mysql_mutex.h
include/mysql/psi/psi.h
mysql-test/suite/perfschema/r/no_threads.result
mysql-test/suite/perfschema/r/start_server32_on.result
mysql-test/suite/perfschema/t/disabled.def
mysys/my_winthread.c
sql/ha_ndbcluster_binlog.cc
sql/ha_ndbcluster_connection.cc
sql/mysqld.cc
sql/scheduler.cc
sql/scheduler.h
sql/sql_class.cc
sql/sql_class.h
storage/perfschema/pfs.cc
=== modified file 'include/my_pthread.h'
--- a/include/my_pthread.h 2009-05-18 15:36:08 +0000
+++ b/include/my_pthread.h 2009-05-26 21:15:12 +0000
@@ -100,7 +100,7 @@ struct timespec {
} while(0)
int win_pthread_mutex_trylock(pthread_mutex_t *mutex);
-int pthread_create(pthread_t *,pthread_attr_t *,pthread_handler,void *);
+int pthread_create(pthread_t *, const pthread_attr_t *, pthread_handler, void *);
int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr);
int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex);
int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
=== modified file 'include/mysql/psi/mysql_mutex.h'
--- a/include/mysql/psi/mysql_mutex.h 2009-05-21 19:42:38 +0000
+++ b/include/mysql/psi/mysql_mutex.h 2009-05-26 21:15:12 +0000
@@ -291,6 +291,35 @@
*/
#define mysql_cond_broadcast(C) inline_mysql_cond_broadcast(C)
+
+/**
+ @def mysql_thread_create(K,P1,P2,P3,P4)
+ Instrumented pthread_create.
+ This function creates both the thread instrumentation and a thread.
+ @c mysql_thread_create is a replacement for @c pthread_create.
+ @param K The PSI_thread_key for this instrumented thread
+ @param P1 pthread_create parameter 1
+ @param P2 pthread_create parameter 2
+ @param P3 pthread_create parameter 3
+ @param P4 pthread_create parameter 4
+*/
+#ifdef HAVE_PSI_INTERFACE
+ #define mysql_thread_create(K,P1,P2,P3,P4) inline_mysql_thread_create(K,P1,P2,P3,P4)
+#else
+ #define mysql_thread_create(K,P1,P2,P3,P4) pthread_create(P1,P2,P3,P4)
+#endif
+
+/**
+ @def mysql_thread_set_id(I)
+ Set the thread indentifier for the instrumentation.
+ @param I The thread identifier
+*/
+#ifdef HAVE_PSI_INTERFACE
+ #define mysql_thread_set_id(I) inline_mysql_thread_set_id(I)
+#else
+ #define mysql_thread_set_id(I) do while (0)
+#endif
+
/**
An instrumented mutex structure.
@sa mysql_mutex_t
@@ -739,24 +768,6 @@ static inline int inline_mysql_cond_broa
}
#ifdef HAVE_PSI_INTERFACE
- #define mysql_thread_create(K,P1,P2,P3,P4) inline_mysql_thread_create(K,P1,P2,P3,P4)
-#else
- #define mysql_thread_create(K,P1,P2,P3,P4) pthread_create(P1,P2,P3,P4)
-#endif
-
-#ifdef HAVE_PSI_INTERFACE
- #define mysql_thread_set_id(I) inline_mysql_thread_set_id(I)
-#else
- #define mysql_thread_set_id(I) do while (0)
-#endif
-
-#ifdef HAVE_PSI_INTERFACE
- #define mysql_thread_prepare(P1,P2,P3,P4) inline_mysql_thread_prepare(P1,P2,P3,P4)
-#else
- #define mysql_thread_prepare(P1,P2,P3,P4) inline_mysql_thread_prepare(P4)
-#endif
-
-#ifdef HAVE_PSI_INTERFACE
static inline int inline_mysql_thread_create(
PSI_thread_key key,
pthread_t *thread, const pthread_attr_t *attr,
@@ -779,7 +790,6 @@ static inline void inline_mysql_thread_s
PSI_server->set_thread_id(psi, id);
}
}
-
#endif
static inline void inline_mysql_thread_prepare(
@@ -796,7 +806,6 @@ static inline void inline_mysql_thread_p
*hdl= NULL;
}
-
/**
@} (end of group Mutex_instrumentation)
*/
=== modified file 'include/mysql/psi/psi.h'
--- a/include/mysql/psi/psi.h 2009-05-21 19:42:38 +0000
+++ b/include/mysql/psi/psi.h 2009-05-26 21:15:12 +0000
@@ -563,6 +563,15 @@ typedef void (*close_table_v1_t)(struct
*/
typedef void (*create_file_v1_t)(PSI_file_key key, const char *name, File file);
+/**
+ Spawn a thread.
+ This method creates a new thread, with instrumentation.
+ @param key the instrumentation key for this thread
+ @param thread the resulting thread
+ @param attr the thread attributes
+ @param start_routine the thread start routine
+ @param arg the thread start routine argument
+*/
typedef int (*spawn_thread_v1_t)(PSI_thread_key key,
pthread_t *thread, const pthread_attr_t *attr,
void *(*start_routine)(void*), void *arg);
=== modified file 'mysql-test/suite/perfschema/r/no_threads.result'
--- a/mysql-test/suite/perfschema/r/no_threads.result 2009-05-21 19:42:38 +0000
+++ b/mysql-test/suite/perfschema/r/no_threads.result 2009-05-26 21:15:12 +0000
@@ -24,7 +24,7 @@ count(*)
select count(*) from performance_schema.PROCESSLIST
where name like "thread/sql/OneConnection";
count(*)
-2
+0
select event_name, operation, source
from performance_schema.EVENTS_WAITS_CURRENT;
event_name operation source
=== modified file 'mysql-test/suite/perfschema/r/start_server32_on.result'
--- a/mysql-test/suite/perfschema/r/start_server32_on.result 2009-04-17 18:44:53 +0000
+++ b/mysql-test/suite/perfschema/r/start_server32_on.result 2009-05-26 21:15:12 +0000
@@ -10,34 +10,34 @@ if (version() like "%perfschema%", "Comp
Compiled In
show engine PERFORMANCE_SCHEMA status;
Type Name Status
-performance_schema EVENTS_WAITS_CURRENT.ROW_SIZE 92
+performance_schema EVENTS_WAITS_CURRENT.ROW_SIZE 84
performance_schema EVENTS_WAITS_CURRENT.ROW_COUNT 3000
-performance_schema EVENTS_WAITS_HISTORY.ROW_SIZE 84
+performance_schema EVENTS_WAITS_HISTORY.ROW_SIZE 76
performance_schema EVENTS_WAITS_HISTORY.ROW_COUNT 10000
-performance_schema EVENTS_WAITS_HISTORY.MEMORY 840000
-performance_schema EVENTS_WAITS_HISTORY_LONG.ROW_SIZE 84
+performance_schema EVENTS_WAITS_HISTORY.MEMORY 760000
+performance_schema EVENTS_WAITS_HISTORY_LONG.ROW_SIZE 76
performance_schema EVENTS_WAITS_HISTORY_LONG.ROW_COUNT 10000
-performance_schema EVENTS_WAITS_HISTORY_LONG.MEMORY 840000
-performance_schema (PFS_MUTEX_INFO).ROW_SIZE 228
-performance_schema (PFS_MUTEX_INFO).ROW_COUNT 200
-performance_schema (PFS_MUTEX_INFO).ROW_LOST 0
-performance_schema (PFS_MUTEX_INFO).MEMORY 45600
-performance_schema (PFS_RWLOCK_INFO).ROW_SIZE 268
-performance_schema (PFS_RWLOCK_INFO).ROW_COUNT 20
-performance_schema (PFS_RWLOCK_INFO).ROW_LOST 0
-performance_schema (PFS_RWLOCK_INFO).MEMORY 5360
-performance_schema (PFS_COND_INFO).ROW_SIZE 204
-performance_schema (PFS_COND_INFO).ROW_COUNT 80
-performance_schema (PFS_COND_INFO).ROW_LOST 0
-performance_schema (PFS_COND_INFO).MEMORY 16320
-performance_schema (PFS_THREAD_INFO).ROW_SIZE 140
-performance_schema (PFS_THREAD_INFO).ROW_COUNT 50
-performance_schema (PFS_THREAD_INFO).ROW_LOST 0
-performance_schema (PFS_THREAD_INFO).MEMORY 7000
-performance_schema (PFS_FILE_INFO).ROW_SIZE 220
-performance_schema (PFS_FILE_INFO).ROW_COUNT 50
-performance_schema (PFS_FILE_INFO).ROW_LOST 0
-performance_schema (PFS_FILE_INFO).MEMORY 11000
+performance_schema EVENTS_WAITS_HISTORY_LONG.MEMORY 760000
+performance_schema (PFS_MUTEX_CLASS).ROW_SIZE 224
+performance_schema (PFS_MUTEX_CLASS).ROW_COUNT 200
+performance_schema (PFS_MUTEX_CLASS).ROW_LOST 0
+performance_schema (PFS_MUTEX_CLASS).MEMORY 44800
+performance_schema (PFS_RWLOCK_CLASS).ROW_SIZE 264
+performance_schema (PFS_RWLOCK_CLASS).ROW_COUNT 20
+performance_schema (PFS_RWLOCK_CLASS).ROW_LOST 0
+performance_schema (PFS_RWLOCK_CLASS).MEMORY 5280
+performance_schema (PFS_COND_CLASS).ROW_SIZE 200
+performance_schema (PFS_COND_CLASS).ROW_COUNT 80
+performance_schema (PFS_COND_CLASS).ROW_LOST 0
+performance_schema (PFS_COND_CLASS).MEMORY 16000
+performance_schema (PFS_THREAD_CLASS).ROW_SIZE 136
+performance_schema (PFS_THREAD_CLASS).ROW_COUNT 50
+performance_schema (PFS_THREAD_CLASS).ROW_LOST 0
+performance_schema (PFS_THREAD_CLASS).MEMORY 6800
+performance_schema (PFS_FILE_CLASS).ROW_SIZE 220
+performance_schema (PFS_FILE_CLASS).ROW_COUNT 50
+performance_schema (PFS_FILE_CLASS).ROW_LOST 0
+performance_schema (PFS_FILE_CLASS).MEMORY 11000
performance_schema (PFS_MUTEX).ROW_SIZE 108
performance_schema (PFS_MUTEX).ROW_COUNT 1000
performance_schema (PFS_MUTEX).ROW_LOST 0
@@ -50,18 +50,18 @@ performance_schema (PFS_COND).ROW_SIZE 7
performance_schema (PFS_COND).ROW_COUNT 1000
performance_schema (PFS_COND).ROW_LOST 0
performance_schema (PFS_COND).MEMORY 72000
-performance_schema (PFS_THREAD).ROW_SIZE 332
+performance_schema (PFS_THREAD).ROW_SIZE 304
performance_schema (PFS_THREAD).ROW_COUNT 1000
performance_schema (PFS_THREAD).ROW_LOST 0
-performance_schema (PFS_THREAD).MEMORY 332000
-performance_schema (PFS_FILE).ROW_SIZE 1124
+performance_schema (PFS_THREAD).MEMORY 304000
+performance_schema (PFS_FILE).ROW_SIZE 612
performance_schema (PFS_FILE).ROW_COUNT 1000
performance_schema (PFS_FILE).ROW_LOST 0
-performance_schema (PFS_FILE).MEMORY 1124000
+performance_schema (PFS_FILE).MEMORY 612000
performance_schema EVENTS_WAITS_SUMMARY_BY_THREAD_BY_NAME.ROW_SIZE 32
performance_schema EVENTS_WAITS_SUMMARY_BY_THREAD_BY_NAME.ROW_COUNT 350000
performance_schema EVENTS_WAITS_SUMMARY_BY_THREAD_BY_NAME.MEMORY 11200000
-performance_schema PERFORMANCE_SCHEMA.MEMORY 14765280
+performance_schema PERFORMANCE_SCHEMA.MEMORY 14063880
performance_schema PERFORMANCE_SCHEMA.LOST 0
select count(*) from performance_schema.PERFORMANCE_TIMERS;
count(*)
=== modified file 'mysql-test/suite/perfschema/t/disabled.def'
--- a/mysql-test/suite/perfschema/t/disabled.def 2009-05-06 21:18:31 +0000
+++ b/mysql-test/suite/perfschema/t/disabled.def 2009-05-26 21:15:12 +0000
@@ -9,7 +9,6 @@
# Do not use any TAB characters for whitespace.
#
##############################################################################
-start_server32_off : WL#2360 Marc Need a 32bit box to record the result
-start_server32_on : WL#2360 Marc Need a 32bit box to record the result
+start_server32_off : WL#4876 Marc Need to parse command line
start_server64_off : WL#4876 Marc Need to parse command line
=== modified file 'mysys/my_winthread.c'
--- a/mysys/my_winthread.c 2008-11-24 15:30:37 +0000
+++ b/mysys/my_winthread.c 2009-05-26 21:15:12 +0000
@@ -63,7 +63,7 @@ static unsigned int __stdcall pthread_st
}
-int pthread_create(pthread_t *thread_id, pthread_attr_t *attr,
+int pthread_create(pthread_t *thread_id, const pthread_attr_t *attr,
pthread_handler func, void *param)
{
uintptr_t handle;
=== modified file 'sql/ha_ndbcluster_binlog.cc'
--- a/sql/ha_ndbcluster_binlog.cc 2009-05-21 19:42:38 +0000
+++ b/sql/ha_ndbcluster_binlog.cc 2009-05-26 21:15:12 +0000
@@ -116,7 +116,6 @@ static int ndbcluster_binlog_terminating
and injector thread
*/
pthread_t ndb_binlog_thread;
-
mysql_mutex_t injector_mutex;
mysql_cond_t injector_cond;
@@ -127,7 +126,6 @@ static ulonglong ndb_latest_received_bin
NDB_SHARE *ndb_apply_status_share= 0;
NDB_SHARE *ndb_schema_share= 0;
-
mysql_mutex_t ndb_schema_share_mutex;
extern my_bool opt_log_slave_updates;
=== modified file 'sql/ha_ndbcluster_connection.cc'
--- a/sql/ha_ndbcluster_connection.cc 2009-05-12 03:15:02 +0000
+++ b/sql/ha_ndbcluster_connection.cc 2009-05-26 21:15:12 +0000
@@ -34,7 +34,6 @@ Ndb_cluster_connection* g_ndb_cluster_co
static Ndb_cluster_connection **g_ndb_cluster_connection_pool= NULL;
static ulong g_ndb_cluster_connection_pool_alloc= 0;
static ulong g_ndb_cluster_connection_pool_pos= 0;
-
static mysql_mutex_t g_ndb_cluster_connection_pool_mutex;
int ndbcluster_connect(int (*connect_callback)(void))
=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc 2009-05-21 19:42:38 +0000
+++ b/sql/mysqld.cc 2009-05-26 21:15:12 +0000
@@ -5107,8 +5107,6 @@ static bool read_init_file(char *file_na
void handle_connection_in_main_thread(THD *thd)
{
- mysql_thread_prepare(key_thread_one_connection, thd, thd->thread_id, & thd->m_psi);
-
mysql_mutex_assert_owner(&LOCK_thread_count);
thread_cache_size=0; // Safety
threads.append(thd);
@@ -5125,8 +5123,6 @@ void create_thread_to_handle_connection(
{
if (cached_thread_count > wake_thread)
{
- mysql_thread_prepare(key_thread_one_connection, thd, thd->thread_id, & thd->m_psi);
-
/* Get thread from cache */
thread_cache.append(thd);
wake_thread++;
=== modified file 'sql/scheduler.cc'
--- a/sql/scheduler.cc 2009-05-21 19:42:38 +0000
+++ b/sql/scheduler.cc 2009-05-26 21:15:12 +0000
@@ -167,7 +167,7 @@ static void close_socketpair(int sock_pa
*/
thd_scheduler::thd_scheduler()
- : logged_in(FALSE), io_event(NULL), thread_attached(FALSE)
+ : logged_in(FALSE), io_event(NULL), thread_attached(FALSE), m_psi(NULL)
{
#ifndef DBUG_OFF
dbug_explain[0]= '\0';
@@ -216,12 +216,12 @@ bool thd_scheduler::thread_attach()
{
/*
Until now, this thread is running under the libevent instrumentation.
- Save this instrumentation, and bind to the job instrumentation, THD::m_psi.
+ Save this instrumentation, and bind to the user job instrumentation, m_psi.
*/
PSI_thread *psi= (PSI_server ? PSI_server->get_thread() : NULL);
my_pthread_setspecific_ptr(THR_PSI_backup, psi);
if (PSI_server)
- PSI_server->set_thread(thd->m_psi);
+ PSI_server->set_thread(m_psi);
}
#endif
@@ -257,11 +257,11 @@ void thd_scheduler::thread_detach()
#ifdef HAVE_PSI_INTERFACE
{
/*
- Until now, this thread is running under the job instrumentation.
+ Until now, this thread is running under the user job instrumentation.
Restore the libevent instrumentation before giving up the job,
so that from now on:
- waits are properly counted against libevent,
- - race conditions are not generated in the job THD::m_psi,
+ - race conditions are not generated in the user job m_psi,
which might be picked up by another thread.
*/
if (PSI_server)
@@ -516,7 +516,10 @@ static void libevent_add_connection(THD
DBUG_VOID_RETURN;
}
- mysql_thread_prepare(key_thread_one_connection, thd, thd->thread_id, & thd->m_psi);
+#ifdef HAVE_PSI_INTERFACE
+ if (PSI_server)
+ thd->scheduler.m_psi= PSI_server->new_thread(key_thread_one_connection, thd, thd->thread_id);
+#endif
thd->set_time();
thd->thr_create_utime= my_micro_time();
=== modified file 'sql/scheduler.h'
--- a/sql/scheduler.h 2008-04-25 18:45:33 +0000
+++ b/sql/scheduler.h 2009-05-26 21:15:12 +0000
@@ -61,7 +61,16 @@ public:
struct event* io_event;
LIST list;
bool thread_attached; /* Indicates if THD is attached to the OS thread */
-
+ /**
+ Thread instrumentation for the user job.
+ This member holds the instrumentation while the user job is not run
+ by a thread.
+ Note that this member is not conditionally declared (ifdef HAVE_PSI_INTERFACE),
+ because doing so will change the binary layout of THD,
+ which is exposed to plugin code that may be compiled differently.
+ */
+ PSI_thread *m_psi;
+
#ifndef DBUG_OFF
char dbug_explain[256];
bool set_explain;
=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc 2009-05-21 19:42:38 +0000
+++ b/sql/sql_class.cc 2009-05-26 21:15:12 +0000
@@ -474,8 +474,7 @@ THD::THD()
debug_sync_control(0),
#endif /* defined(ENABLED_DEBUG_SYNC) */
locked_tables_root(NULL),
- main_warning_info(0),
- m_psi(NULL)
+ main_warning_info(0)
{
ulong tmp;
=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h 2009-05-21 19:42:38 +0000
+++ b/sql/sql_class.h 2009-05-26 21:15:12 +0000
@@ -2447,9 +2447,6 @@ private:
MEM_ROOT main_mem_root;
Warning_info main_warning_info;
Diagnostics_area main_da;
-
-public:
- PSI_thread *m_psi;
};
=== modified file 'storage/perfschema/pfs.cc'
--- a/storage/perfschema/pfs.cc 2009-05-21 19:42:38 +0000
+++ b/storage/perfschema/pfs.cc 2009-05-26 21:15:12 +0000
@@ -1003,7 +1003,7 @@ void* pfs_spawn_thread(void *arg)
/* Then, execute the user code for this thread. */
typed_arg->m_user_start_routine(typed_arg->m_user_arg);
- free(typed_arg);
+ my_free(typed_arg, MYF(0));
return NULL;
}
@@ -1014,7 +1014,8 @@ static int spawn_thread_v1(PSI_thread_ke
PFS_spawn_thread_arg *psi_arg;
/* psi_arg can not be global, and can not be a local variable. */
- psi_arg= (PFS_spawn_thread_arg*) malloc(sizeof(PFS_spawn_thread_arg));
+ psi_arg= (PFS_spawn_thread_arg*) my_malloc(sizeof(PFS_spawn_thread_arg),
+ MYF(MY_WME));
if (psi_arg == NULL)
return EAGAIN;