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.
This commit is contained in:
Marc Alff 2010-07-09 17:00:24 -06:00
commit ec41287630
12 changed files with 544 additions and 183 deletions

View file

@ -676,11 +676,12 @@ pfs_rw_lock_x_lock_func(
ulint line) /*!< in: line where requested */
{
struct PSI_rwlock_locker* locker = NULL;
PSI_rwlock_locker_state state;
/* Record the entry of rw x lock request in performance schema */
if (UNIV_LIKELY(PSI_server && lock->pfs_psi)) {
locker = PSI_server->get_thread_rwlock_locker(
lock->pfs_psi, PSI_RWLOCK_WRITELOCK);
&state, lock->pfs_psi, PSI_RWLOCK_WRITELOCK);
if (locker) {
PSI_server->start_rwlock_wrwait(locker,
@ -710,12 +711,13 @@ pfs_rw_lock_x_lock_func_nowait(
ulint line) /*!< in: line where requested */
{
struct PSI_rwlock_locker* locker = NULL;
PSI_rwlock_locker_state state;
ibool ret;
/* Record the entry of rw x lock request in performance schema */
if (UNIV_LIKELY(PSI_server && lock->pfs_psi)) {
locker = PSI_server->get_thread_rwlock_locker(
lock->pfs_psi, PSI_RWLOCK_WRITELOCK);
&state, lock->pfs_psi, PSI_RWLOCK_WRITELOCK);
if (locker) {
PSI_server->start_rwlock_wrwait(locker,
@ -765,11 +767,12 @@ pfs_rw_lock_s_lock_func(
ulint line) /*!< in: line where requested */
{
struct PSI_rwlock_locker* locker = NULL;
PSI_rwlock_locker_state state;
/* Instrumented to inform we are aquiring a shared rwlock */
if (UNIV_LIKELY(PSI_server && lock->pfs_psi)) {
locker = PSI_server->get_thread_rwlock_locker(
lock->pfs_psi, PSI_RWLOCK_READLOCK);
&state, lock->pfs_psi, PSI_RWLOCK_READLOCK);
if (locker) {
PSI_server->start_rwlock_rdwait(locker,
file_name, line);
@ -800,12 +803,13 @@ pfs_rw_lock_s_lock_low(
{
struct PSI_rwlock_locker* locker = NULL;
PSI_rwlock_locker_state state;
ibool ret;
/* Instrumented to inform we are aquiring a shared rwlock */
if (UNIV_LIKELY(PSI_server && lock->pfs_psi)) {
locker = PSI_server->get_thread_rwlock_locker(
lock->pfs_psi, PSI_RWLOCK_READLOCK);
&state, lock->pfs_psi, PSI_RWLOCK_READLOCK);
if (locker) {
PSI_server->start_rwlock_rdwait(locker,
file_name, line);
@ -838,11 +842,7 @@ pfs_rw_lock_x_unlock_func(
{
/* Inform performance schema we are unlocking the lock */
if (UNIV_LIKELY(PSI_server && lock->pfs_psi)) {
struct PSI_thread* thread;
thread = PSI_server->get_thread();
if (thread) {
PSI_server->unlock_rwlock(thread, lock->pfs_psi);
}
PSI_server->unlock_rwlock(lock->pfs_psi);
}
rw_lock_x_unlock_func(
@ -869,11 +869,7 @@ pfs_rw_lock_s_unlock_func(
{
/* Inform performance schema we are unlocking the lock */
if (UNIV_LIKELY(PSI_server && lock->pfs_psi)) {
struct PSI_thread* thread;
thread = PSI_server->get_thread();
if (thread) {
PSI_server->unlock_rwlock(thread, lock->pfs_psi);
}
PSI_server->unlock_rwlock(lock->pfs_psi);
}
rw_lock_s_unlock_func(