diff options
author | Marc Alff <marc.alff@oracle.com> | 2010-07-09 17:00:24 -0600 |
---|---|---|
committer | Marc Alff <marc.alff@oracle.com> | 2010-07-09 17:00:24 -0600 |
commit | ec41287630b2b740acbcb468b54c8a0a23a823cf (patch) | |
tree | be615d5caa61d6f096f4fc96df6c5a56e956fb11 /include/mysql/psi/mysql_thread.h | |
parent | f56dd32bf7c5b8a8cf35984f39f1a253b75945ff (diff) | |
download | mariadb-git-ec41287630b2b740acbcb468b54c8a0a23a823cf.tar.gz |
Bug#55087 Performance schema: optimization of the instrumentation interface
This change is for performance optimization.
Fixed the performance schema instrumentation interface as follows:
- simplified mysql_unlock_mutex()
- simplified mysql_unlock_rwlock()
- simplified mysql_cond_signal()
- simplified mysql_cond_broadcast()
Changed the get_thread_XXX_locker apis to have one extra parameter,
to provide memory to the instrumentation implementation.
This API change allows to use memory provided by the caller,
to avoid having to use thread local storage.
Using this extra parameter will be done in a separate fix,
this change is for the interface only.
Adjusted all the code and unit tests accordingly.
Diffstat (limited to 'include/mysql/psi/mysql_thread.h')
-rw-r--r-- | include/mysql/psi/mysql_thread.h | 71 |
1 files changed, 29 insertions, 42 deletions
diff --git a/include/mysql/psi/mysql_thread.h b/include/mysql/psi/mysql_thread.h index 193cb89647d..d133f2655fb 100644 --- a/include/mysql/psi/mysql_thread.h +++ b/include/mysql/psi/mysql_thread.h @@ -625,9 +625,10 @@ static inline int inline_mysql_mutex_lock( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_mutex_locker *locker= NULL; + PSI_mutex_locker_state state; if (likely(PSI_server && that->m_psi)) { - locker= PSI_server->get_thread_mutex_locker(that->m_psi, PSI_MUTEX_LOCK); + locker= PSI_server->get_thread_mutex_locker(&state, that->m_psi, PSI_MUTEX_LOCK); if (likely(locker != NULL)) PSI_server->start_mutex_wait(locker, src_file, src_line); } @@ -654,9 +655,10 @@ static inline int inline_mysql_mutex_trylock( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_mutex_locker *locker= NULL; + PSI_mutex_locker_state state; if (likely(PSI_server && that->m_psi)) { - locker= PSI_server->get_thread_mutex_locker(that->m_psi, PSI_MUTEX_TRYLOCK); + locker= PSI_server->get_thread_mutex_locker(&state, that->m_psi, PSI_MUTEX_TRYLOCK); if (likely(locker != NULL)) PSI_server->start_mutex_wait(locker, src_file, src_line); } @@ -682,13 +684,8 @@ static inline int inline_mysql_mutex_unlock( { int result; #ifdef HAVE_PSI_INTERFACE - struct PSI_thread *thread; if (likely(PSI_server && that->m_psi)) - { - thread= PSI_server->get_thread(); - if (likely(thread != NULL)) - PSI_server->unlock_mutex(thread, that->m_psi); - } + PSI_server->unlock_mutex(that->m_psi); #endif #ifdef SAFE_MUTEX result= safe_mutex_unlock(&that->m_mutex, src_file, src_line); @@ -771,9 +768,10 @@ static inline int inline_mysql_rwlock_rdlock( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_rwlock_locker *locker= NULL; + PSI_rwlock_locker_state state; if (likely(PSI_server && that->m_psi)) { - locker= PSI_server->get_thread_rwlock_locker(that->m_psi, + locker= PSI_server->get_thread_rwlock_locker(&state, that->m_psi, PSI_RWLOCK_READLOCK); if (likely(locker != NULL)) PSI_server->start_rwlock_rdwait(locker, src_file, src_line); @@ -798,9 +796,10 @@ static inline int inline_mysql_prlock_rdlock( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_rwlock_locker *locker= NULL; + PSI_rwlock_locker_state state; if (likely(PSI_server && that->m_psi)) { - locker= PSI_server->get_thread_rwlock_locker(that->m_psi, + locker= PSI_server->get_thread_rwlock_locker(&state, that->m_psi, PSI_RWLOCK_READLOCK); if (likely(locker != NULL)) PSI_server->start_rwlock_rdwait(locker, src_file, src_line); @@ -825,9 +824,10 @@ static inline int inline_mysql_rwlock_wrlock( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_rwlock_locker *locker= NULL; + PSI_rwlock_locker_state state; if (likely(PSI_server && that->m_psi)) { - locker= PSI_server->get_thread_rwlock_locker(that->m_psi, + locker= PSI_server->get_thread_rwlock_locker(&state, that->m_psi, PSI_RWLOCK_WRITELOCK); if (likely(locker != NULL)) PSI_server->start_rwlock_wrwait(locker, src_file, src_line); @@ -852,9 +852,10 @@ static inline int inline_mysql_prlock_wrlock( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_rwlock_locker *locker= NULL; + PSI_rwlock_locker_state state; if (likely(PSI_server && that->m_psi)) { - locker= PSI_server->get_thread_rwlock_locker(that->m_psi, + locker= PSI_server->get_thread_rwlock_locker(&state, that->m_psi, PSI_RWLOCK_WRITELOCK); if (likely(locker != NULL)) PSI_server->start_rwlock_wrwait(locker, src_file, src_line); @@ -879,9 +880,10 @@ static inline int inline_mysql_rwlock_tryrdlock( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_rwlock_locker *locker= NULL; + PSI_rwlock_locker_state state; if (likely(PSI_server && that->m_psi)) { - locker= PSI_server->get_thread_rwlock_locker(that->m_psi, + locker= PSI_server->get_thread_rwlock_locker(&state, that->m_psi, PSI_RWLOCK_TRYREADLOCK); if (likely(locker != NULL)) PSI_server->start_rwlock_rdwait(locker, src_file, src_line); @@ -906,9 +908,10 @@ static inline int inline_mysql_prlock_tryrdlock( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_rwlock_locker *locker= NULL; + PSI_rwlock_locker_state state; if (likely(PSI_server && that->m_psi)) { - locker= PSI_server->get_thread_rwlock_locker(that->m_psi, + locker= PSI_server->get_thread_rwlock_locker(&state, that->m_psi, PSI_RWLOCK_TRYREADLOCK); if (likely(locker != NULL)) PSI_server->start_rwlock_rdwait(locker, src_file, src_line); @@ -933,9 +936,10 @@ static inline int inline_mysql_rwlock_trywrlock( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_rwlock_locker *locker= NULL; + PSI_rwlock_locker_state state; if (likely(PSI_server && that->m_psi)) { - locker= PSI_server->get_thread_rwlock_locker(that->m_psi, + locker= PSI_server->get_thread_rwlock_locker(&state, that->m_psi, PSI_RWLOCK_TRYWRITELOCK); if (likely(locker != NULL)) PSI_server->start_rwlock_wrwait(locker, src_file, src_line); @@ -960,9 +964,10 @@ static inline int inline_mysql_prlock_trywrlock( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_rwlock_locker *locker= NULL; + PSI_rwlock_locker_state state; if (likely(PSI_server && that->m_psi)) { - locker= PSI_server->get_thread_rwlock_locker(that->m_psi, + locker= PSI_server->get_thread_rwlock_locker(&state, that->m_psi, PSI_RWLOCK_TRYWRITELOCK); if (likely(locker != NULL)) PSI_server->start_rwlock_wrwait(locker, src_file, src_line); @@ -982,13 +987,8 @@ static inline int inline_mysql_rwlock_unlock( { int result; #ifdef HAVE_PSI_INTERFACE - struct PSI_thread *thread; if (likely(PSI_server && that->m_psi)) - { - thread= PSI_server->get_thread(); - if (likely(thread != NULL)) - PSI_server->unlock_rwlock(thread, that->m_psi); - } + PSI_server->unlock_rwlock(that->m_psi); #endif result= rw_unlock(&that->m_rwlock); return result; @@ -1000,13 +1000,8 @@ static inline int inline_mysql_prlock_unlock( { int result; #ifdef HAVE_PSI_INTERFACE - struct PSI_thread *thread; if (likely(PSI_server && that->m_psi)) - { - thread= PSI_server->get_thread(); - if (likely(thread != NULL)) - PSI_server->unlock_rwlock(thread, that->m_psi); - } + PSI_server->unlock_rwlock(that->m_psi); #endif result= rw_pr_unlock(&that->m_prlock); return result; @@ -1053,9 +1048,10 @@ static inline int inline_mysql_cond_wait( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_cond_locker *locker= NULL; + PSI_cond_locker_state state; if (likely(PSI_server && that->m_psi)) { - locker= PSI_server->get_thread_cond_locker(that->m_psi, mutex->m_psi, + locker= PSI_server->get_thread_cond_locker(&state, that->m_psi, mutex->m_psi, PSI_COND_WAIT); if (likely(locker != NULL)) PSI_server->start_cond_wait(locker, src_file, src_line); @@ -1081,9 +1077,10 @@ static inline int inline_mysql_cond_timedwait( int result; #ifdef HAVE_PSI_INTERFACE struct PSI_cond_locker *locker= NULL; + PSI_cond_locker_state state; if (likely(PSI_server && that->m_psi)) { - locker= PSI_server->get_thread_cond_locker(that->m_psi, mutex->m_psi, + locker= PSI_server->get_thread_cond_locker(&state, that->m_psi, mutex->m_psi, PSI_COND_TIMEDWAIT); if (likely(locker != NULL)) PSI_server->start_cond_wait(locker, src_file, src_line); @@ -1102,13 +1099,8 @@ static inline int inline_mysql_cond_signal( { int result; #ifdef HAVE_PSI_INTERFACE - struct PSI_thread *thread; if (likely(PSI_server && that->m_psi)) - { - thread= PSI_server->get_thread(); - if (likely(thread != NULL)) - PSI_server->signal_cond(thread, that->m_psi); - } + PSI_server->signal_cond(that->m_psi); #endif result= pthread_cond_signal(&that->m_cond); return result; @@ -1119,13 +1111,8 @@ static inline int inline_mysql_cond_broadcast( { int result; #ifdef HAVE_PSI_INTERFACE - struct PSI_thread *thread; if (likely(PSI_server && that->m_psi)) - { - thread= PSI_server->get_thread(); - if (likely(thread != NULL)) - PSI_server->broadcast_cond(thread, that->m_psi); - } + PSI_server->broadcast_cond(that->m_psi); #endif result= pthread_cond_broadcast(&that->m_cond); return result; |