From: Marc Alff Date: May 4 2011 3:18am Subject: bzr push into mysql-trunk-pfs-tuning branch (marc.alff:3365 to 3366) List-Archive: http://lists.mysql.com/commits/136604 Message-Id: <201105040318.p443IROX000747@acsmt356.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3366 Marc Alff 2011-05-03 PERFORMANCE SCHEMA optimiztion Potential improvements, to benchmark: 1) Removed "locker= NULL" from the main instrumentation path 2) Removed "if (locker == NULL) from the main instrumentation path, for most end events 3) Pushed "if (that->m_psi != NULL)" from the interface to the implementation 4) In the implementation, pushed "if (that->m_psi != NULL)" after the check for the global_instrumentation consumer, to shorten the instrumentation path. modified: include/mysql/psi/mysql_file.h include/mysql/psi/mysql_table.h include/mysql/psi/mysql_thread.h storage/innobase/include/os0sync.ic storage/innobase/include/sync0rw.ic storage/innobase/include/sync0sync.ic storage/innobase/include/univ.i storage/perfschema/pfs.cc 3365 Marc Alff 2011-05-03 PERFORMANCE SCHEMA optimization. Potential optimization, to benchmark: - removed "if (likely(PSI_server != NULL))" from the instrumented code path. PSI_server is guaranteed to exist, it may point to PSI_noop. added: mysys/psi_noop.cc modified: include/mysql/psi/mysql_file.h include/mysql/psi/mysql_stage.h include/mysql/psi/mysql_statement.h include/mysql/psi/mysql_table.h include/mysql/psi/mysql_thread.h mysys/CMakeLists.txt mysys/my_static.c === modified file 'include/mysql/psi/mysql_file.h' --- a/include/mysql/psi/mysql_file.h 2011-05-03 23:49:32 +0000 +++ b/include/mysql/psi/mysql_file.h 2011-05-04 03:17:46 +0000 @@ -531,21 +531,20 @@ inline_mysql_file_fgets( { char *result; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker= NULL; + struct PSI_file_locker *locker; PSI_file_locker_state state; - if (likely(file->m_psi != NULL)) + locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, + PSI_FILE_READ); + if (likely(locker != NULL)) { - locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, - PSI_FILE_READ); - if (likely(locker != NULL)) - PSI_server->start_file_wait(locker, (size_t) size, src_file, src_line); + PSI_server->start_file_wait(locker, (size_t) size, src_file, src_line); + result= fgets(str, size, file->m_file); + PSI_server->end_file_wait(locker, result ? strlen(result) : 0); + return result; } #endif + result= fgets(str, size, file->m_file); -#ifdef HAVE_PSI_FILE_INTERFACE - if (likely(locker != NULL)) - PSI_server->end_file_wait(locker, result ? strlen(result) : 0); -#endif return result; } @@ -558,21 +557,20 @@ inline_mysql_file_fgetc( { int result; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker= NULL; + struct PSI_file_locker *locker; PSI_file_locker_state state; - if (likely(file->m_psi != NULL)) + locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, + PSI_FILE_READ); + if (likely(locker != NULL)) { - locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, - PSI_FILE_READ); - if (likely(locker != NULL)) - PSI_server->start_file_wait(locker, (size_t) 1, src_file, src_line); + PSI_server->start_file_wait(locker, (size_t) 1, src_file, src_line); + result= fgetc(file->m_file); + PSI_server->end_file_wait(locker, (size_t) 1); + return result; } #endif + result= fgetc(file->m_file); -#ifdef HAVE_PSI_FILE_INTERFACE - if (likely(locker != NULL)) - PSI_server->end_file_wait(locker, (size_t) 1); -#endif return result; } @@ -587,23 +585,20 @@ inline_mysql_file_fputs( #ifdef HAVE_PSI_FILE_INTERFACE struct PSI_file_locker *locker= NULL; PSI_file_locker_state state; - size_t bytes= 0; - if (likely(file->m_psi != NULL)) + size_t bytes; + locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, + PSI_FILE_WRITE); + if (likely(locker != NULL)) { - locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, - PSI_FILE_WRITE); - if (likely(locker != NULL)) - { - bytes= str ? strlen(str) : 0; - PSI_server->start_file_wait(locker, bytes, src_file, src_line); - } + bytes= str ? strlen(str) : 0; + PSI_server->start_file_wait(locker, bytes, src_file, src_line); + result= fputs(str, file->m_file); + PSI_server->end_file_wait(locker, bytes); + return result; } #endif + result= fputs(str, file->m_file); -#ifdef HAVE_PSI_FILE_INTERFACE - if (likely(locker != NULL)) - PSI_server->end_file_wait(locker, bytes); -#endif return result; } @@ -616,21 +611,20 @@ inline_mysql_file_fputc( { int result; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker= NULL; + struct PSI_file_locker *locker; PSI_file_locker_state state; - if (likely(file->m_psi != NULL)) + locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, + PSI_FILE_WRITE); + if (likely(locker != NULL)) { - locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, - PSI_FILE_WRITE); - if (likely(locker != NULL)) - PSI_server->start_file_wait(locker, (size_t) 1, src_file, src_line); + PSI_server->start_file_wait(locker, (size_t) 1, src_file, src_line); + result= fputc(c, file->m_file); + PSI_server->end_file_wait(locker, (size_t) 1); + return result; } #endif + result= fputc(c, file->m_file); -#ifdef HAVE_PSI_FILE_INTERFACE - if (likely(locker != NULL)) - PSI_server->end_file_wait(locker, (size_t) 1); -#endif return result; } @@ -643,23 +637,24 @@ inline_mysql_file_fprintf(MYSQL_FILE *fi int result; va_list args; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker= NULL; + struct PSI_file_locker *locker; PSI_file_locker_state state; - if (likely(file->m_psi != NULL)) + locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, + PSI_FILE_WRITE); + if (likely(locker != NULL)) { - locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, - PSI_FILE_WRITE); - if (likely(locker != NULL)) - PSI_server->start_file_wait(locker, (size_t) 0, __FILE__, __LINE__); + PSI_server->start_file_wait(locker, (size_t) 0, __FILE__, __LINE__); + va_start(args, format); + result= vfprintf(file->m_file, format, args); + va_end(args); + PSI_server->end_file_wait(locker, (size_t) result); + return result; } #endif + va_start(args, format); result= vfprintf(file->m_file, format, args); va_end(args); -#ifdef HAVE_PSI_FILE_INTERFACE - if (likely(locker != NULL)) - PSI_server->end_file_wait(locker, (size_t) result); -#endif return result; } @@ -672,21 +667,20 @@ inline_mysql_file_vfprintf( { int result; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker= NULL; + struct PSI_file_locker *locker; PSI_file_locker_state state; - if (likely(file->m_psi != NULL)) + locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, + PSI_FILE_WRITE); + if (likely(locker != NULL)) { - locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, - PSI_FILE_WRITE); - if (likely(locker != NULL)) - PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line); + PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line); + result= vfprintf(file->m_file, format, args); + PSI_server->end_file_wait(locker, (size_t) result); + return result; } #endif + result= vfprintf(file->m_file, format, args); -#ifdef HAVE_PSI_FILE_INTERFACE - if (likely(locker != NULL)) - PSI_server->end_file_wait(locker, (size_t) result); -#endif return result; } @@ -699,21 +693,20 @@ inline_mysql_file_fflush( { int result; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker= NULL; + struct PSI_file_locker *locker; PSI_file_locker_state state; - if (likely(file->m_psi != NULL)) + locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, + PSI_FILE_FLUSH); + if (likely(locker != NULL)) { - locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, - PSI_FILE_FLUSH); - if (likely(locker != NULL)) - PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line); + PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line); + result= fflush(file->m_file); + PSI_server->end_file_wait(locker, (size_t) 0); + return result; } #endif + result= fflush(file->m_file); -#ifdef HAVE_PSI_FILE_INTERFACE - if (likely(locker != NULL)) - PSI_server->end_file_wait(locker, (size_t) 0); -#endif return result; } @@ -808,27 +801,33 @@ inline_mysql_file_fopen( that= (MYSQL_FILE*) my_malloc(sizeof(MYSQL_FILE), MYF(MY_WME)); if (likely(that != NULL)) { - that->m_psi= NULL; - { #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker= NULL; - PSI_file_locker_state state; - locker= PSI_server->get_thread_file_name_locker - (&state, key, PSI_FILE_STREAM_OPEN, filename, that); - if (likely(locker != NULL)) - that->m_psi= PSI_server->start_file_open_wait(locker, src_file, - src_line); -#endif + struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; + locker= PSI_server->get_thread_file_name_locker + (&state, key, PSI_FILE_STREAM_OPEN, filename, that); + if (likely(locker != NULL)) + { + that->m_psi= PSI_server->start_file_open_wait(locker, src_file, + src_line); that->m_file= my_fopen(filename, flags, myFlags); -#ifdef HAVE_PSI_FILE_INTERFACE - if (likely(locker != NULL)) - PSI_server->end_file_open_wait(locker); -#endif + PSI_server->end_file_open_wait(locker); + if (unlikely(that->m_file == NULL)) { my_free(that); return NULL; } + return that; + } +#endif + + that->m_psi= NULL; + that->m_file= my_fopen(filename, flags, myFlags); + if (unlikely(that->m_file == NULL)) + { + my_free(that); + return NULL; } } return that; @@ -845,22 +844,21 @@ inline_mysql_file_fclose( if (likely(file != NULL)) { #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker= NULL; + struct PSI_file_locker *locker; PSI_file_locker_state state; - DBUG_ASSERT(file != NULL); - if (likely(file->m_psi != NULL)) + locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, + PSI_FILE_STREAM_CLOSE); + if (likely(locker != NULL)) { - locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, - PSI_FILE_STREAM_CLOSE); - if (likely(locker != NULL)) - PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line); + PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line); + result= my_fclose(file->m_file, flags); + PSI_server->end_file_wait(locker, (size_t) 0); + my_free(file); + return result; } #endif + result= my_fclose(file->m_file, flags); -#ifdef HAVE_PSI_FILE_INTERFACE - if (likely(locker != NULL)) - PSI_server->end_file_wait(locker, (size_t) 0); -#endif my_free(file); } return result; @@ -873,30 +871,27 @@ inline_mysql_file_fread( #endif MYSQL_FILE *file, uchar *buffer, size_t count, myf flags) { - size_t result= 0; + size_t result; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker= NULL; + struct PSI_file_locker *locker; PSI_file_locker_state state; - if (likely(file->m_psi != NULL)) - { - locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, - PSI_FILE_READ); - if (likely(locker != NULL)) - PSI_server->start_file_wait(locker, count, src_file, src_line); - } -#endif - result= my_fread(file->m_file, buffer, count, flags); -#ifdef HAVE_PSI_FILE_INTERFACE + size_t bytes_read; + locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, + PSI_FILE_READ); if (likely(locker != NULL)) { - size_t bytes_read; + PSI_server->start_file_wait(locker, count, src_file, src_line); + result= my_fread(file->m_file, buffer, count, flags); if (flags & (MY_NABP | MY_FNABP)) bytes_read= (result == 0) ? count : 0; else bytes_read= (result != MY_FILE_ERROR) ? result : 0; PSI_server->end_file_wait(locker, bytes_read); + return result; } #endif + + result= my_fread(file->m_file, buffer, count, flags); return result; } @@ -907,30 +902,27 @@ inline_mysql_file_fwrite( #endif MYSQL_FILE *file, const uchar *buffer, size_t count, myf flags) { - size_t result= 0; + size_t result; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker= NULL; + struct PSI_file_locker *locker; PSI_file_locker_state state; - if (likely(file->m_psi != NULL)) - { - locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, - PSI_FILE_WRITE); - if (likely(locker != NULL)) - PSI_server->start_file_wait(locker, count, src_file, src_line); - } -#endif - result= my_fwrite(file->m_file, buffer, count, flags); -#ifdef HAVE_PSI_FILE_INTERFACE + size_t bytes_written; + locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, + PSI_FILE_WRITE); if (likely(locker != NULL)) { - size_t bytes_written; + PSI_server->start_file_wait(locker, count, src_file, src_line); + result= my_fwrite(file->m_file, buffer, count, flags); if (flags & (MY_NABP | MY_FNABP)) bytes_written= (result == 0) ? count : 0; else bytes_written= (result != MY_FILE_ERROR) ? result : 0; PSI_server->end_file_wait(locker, bytes_written); + return result; } #endif + + result= my_fwrite(file->m_file, buffer, count, flags); return result; } @@ -943,21 +935,20 @@ inline_mysql_file_fseek( { my_off_t result; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker= NULL; + struct PSI_file_locker *locker; PSI_file_locker_state state; - if (likely(file->m_psi != NULL)) + locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, + PSI_FILE_SEEK); + if (likely(locker != NULL)) { - locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, - PSI_FILE_SEEK); - if (likely(locker != NULL)) - PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line); + PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line); + result= my_fseek(file->m_file, pos, whence, flags); + PSI_server->end_file_wait(locker, (size_t) 0); + return result; } #endif + result= my_fseek(file->m_file, pos, whence, flags); -#ifdef HAVE_PSI_FILE_INTERFACE - if (likely(locker != NULL)) - PSI_server->end_file_wait(locker, (size_t) 0); -#endif return result; } @@ -970,21 +961,20 @@ inline_mysql_file_ftell( { my_off_t result; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker= NULL; + struct PSI_file_locker *locker; PSI_file_locker_state state; - if (likely(file->m_psi != NULL)) + locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, + PSI_FILE_TELL); + if (likely(locker != NULL)) { - locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi, - PSI_FILE_TELL); - if (likely(locker != NULL)) - PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line); + PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line); + result= my_ftell(file->m_file, flags); + PSI_server->end_file_wait(locker, (size_t) 0); + return result; } #endif + result= my_ftell(file->m_file, flags); -#ifdef HAVE_PSI_FILE_INTERFACE - if (likely(locker != NULL)) - PSI_server->end_file_wait(locker, (size_t) 0); -#endif return result; } === modified file 'include/mysql/psi/mysql_table.h' --- a/include/mysql/psi/mysql_table.h 2011-05-03 23:49:32 +0000 +++ b/include/mysql/psi/mysql_table.h 2011-05-04 03:17:46 +0000 @@ -97,13 +97,10 @@ inline_mysql_start_table_io_wait(PSI_tab uint index, const char *src_file, int src_line) { - struct PSI_table_locker *locker= NULL; - if (likely(psi != NULL)) - { - locker= PSI_server->get_thread_table_io_locker(state, psi, op, index); - if (likely(locker != NULL)) - PSI_server->start_table_io_wait(locker, src_file, src_line); - } + struct PSI_table_locker *locker; + locker= PSI_server->get_thread_table_io_locker(state, psi, op, index); + if (likely(locker != NULL)) + PSI_server->start_table_io_wait(locker, src_file, src_line); return locker; } @@ -165,13 +162,10 @@ inline_mysql_start_table_lock_wait(PSI_t enum PSI_table_lock_operation op, ulong flags, const char *src_file, int src_line) { - struct PSI_table_locker *locker= NULL; - if (likely(psi != NULL)) - { - locker= PSI_server->get_thread_table_lock_locker(state, psi, op, flags); - if (likely(locker != NULL)) - PSI_server->start_table_lock_wait(locker, src_file, src_line); - } + struct PSI_table_locker *locker; + locker= PSI_server->get_thread_table_lock_locker(state, psi, op, flags); + if (likely(locker != NULL)) + PSI_server->start_table_lock_wait(locker, src_file, src_line); return locker; } === modified file 'include/mysql/psi/mysql_thread.h' --- a/include/mysql/psi/mysql_thread.h 2011-05-03 23:49:32 +0000 +++ b/include/mysql/psi/mysql_thread.h 2011-05-04 03:17:46 +0000 @@ -623,11 +623,8 @@ static inline int inline_mysql_mutex_des ) { #ifdef HAVE_PSI_MUTEX_INTERFACE - if (likely(that->m_psi != NULL)) - { - PSI_server->destroy_mutex(that->m_psi); - that->m_psi= NULL; - } + PSI_server->destroy_mutex(that->m_psi); + that->m_psi= NULL; #endif #ifdef SAFE_MUTEX return safe_mutex_destroy(&that->m_mutex, src_file, src_line); @@ -645,24 +642,27 @@ static inline int inline_mysql_mutex_loc { int result; #ifdef HAVE_PSI_MUTEX_INTERFACE - struct PSI_mutex_locker *locker= NULL; + struct PSI_mutex_locker *locker; PSI_mutex_locker_state state; - if (likely(that->m_psi != NULL)) + locker= PSI_server->get_thread_mutex_locker(&state, that->m_psi, PSI_MUTEX_LOCK); + if (likely(locker != NULL)) { - 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); + PSI_server->start_mutex_wait(locker, src_file, src_line); +#ifdef SAFE_MUTEX + result= safe_mutex_lock(&that->m_mutex, FALSE, src_file, src_line); +#else + result= pthread_mutex_lock(&that->m_mutex); +#endif + PSI_server->end_mutex_wait(locker, result); + return result; } #endif + #ifdef SAFE_MUTEX result= safe_mutex_lock(&that->m_mutex, FALSE, src_file, src_line); #else result= pthread_mutex_lock(&that->m_mutex); #endif -#ifdef HAVE_PSI_MUTEX_INTERFACE - if (likely(locker != NULL)) - PSI_server->end_mutex_wait(locker, result); -#endif return result; } @@ -675,24 +675,27 @@ static inline int inline_mysql_mutex_try { int result; #ifdef HAVE_PSI_MUTEX_INTERFACE - struct PSI_mutex_locker *locker= NULL; + struct PSI_mutex_locker *locker; PSI_mutex_locker_state state; - if (likely(that->m_psi != NULL)) + locker= PSI_server->get_thread_mutex_locker(&state, that->m_psi, PSI_MUTEX_TRYLOCK); + if (likely(locker != NULL)) { - 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); + PSI_server->start_mutex_wait(locker, src_file, src_line); +#ifdef SAFE_MUTEX + result= safe_mutex_lock(&that->m_mutex, TRUE, src_file, src_line); +#else + result= pthread_mutex_trylock(&that->m_mutex); +#endif + PSI_server->end_mutex_wait(locker, result); + return result; } #endif + #ifdef SAFE_MUTEX result= safe_mutex_lock(&that->m_mutex, TRUE, src_file, src_line); #else result= pthread_mutex_trylock(&that->m_mutex); #endif -#ifdef HAVE_PSI_MUTEX_INTERFACE - if (likely(locker != NULL)) - PSI_server->end_mutex_wait(locker, result); -#endif return result; } @@ -705,8 +708,7 @@ static inline int inline_mysql_mutex_unl { int result; #ifdef HAVE_PSI_MUTEX_INTERFACE - if (likely(that->m_psi != NULL)) - PSI_server->unlock_mutex(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); @@ -770,11 +772,8 @@ static inline int inline_mysql_rwlock_de mysql_rwlock_t *that) { #ifdef HAVE_PSI_RWLOCK_INTERFACE - if (likely(that->m_psi != NULL)) - { - PSI_server->destroy_rwlock(that->m_psi); - that->m_psi= NULL; - } + PSI_server->destroy_rwlock(that->m_psi); + that->m_psi= NULL; #endif return rwlock_destroy(&that->m_rwlock); } @@ -784,11 +783,8 @@ static inline int inline_mysql_prlock_de mysql_prlock_t *that) { #ifdef HAVE_PSI_RWLOCK_INTERFACE - if (likely(that->m_psi != NULL)) - { - PSI_server->destroy_rwlock(that->m_psi); - that->m_psi= NULL; - } + PSI_server->destroy_rwlock(that->m_psi); + that->m_psi= NULL; #endif return rw_pr_destroy(&that->m_prlock); } @@ -803,21 +799,20 @@ static inline int inline_mysql_rwlock_rd { int result; #ifdef HAVE_PSI_RWLOCK_INTERFACE - struct PSI_rwlock_locker *locker= NULL; + struct PSI_rwlock_locker *locker; PSI_rwlock_locker_state state; - if (likely(that->m_psi != NULL)) + locker= PSI_server->get_thread_rwlock_locker(&state, that->m_psi, + PSI_RWLOCK_READLOCK); + if (likely(locker != NULL)) { - 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); + PSI_server->start_rwlock_rdwait(locker, src_file, src_line); + result= rw_rdlock(&that->m_rwlock); + PSI_server->end_rwlock_rdwait(locker, result); + return result; } #endif + result= rw_rdlock(&that->m_rwlock); -#ifdef HAVE_PSI_RWLOCK_INTERFACE - if (likely(locker != NULL)) - PSI_server->end_rwlock_rdwait(locker, result); -#endif return result; } @@ -831,21 +826,20 @@ static inline int inline_mysql_prlock_rd { int result; #ifdef HAVE_PSI_RWLOCK_INTERFACE - struct PSI_rwlock_locker *locker= NULL; + struct PSI_rwlock_locker *locker; PSI_rwlock_locker_state state; - if (likely(that->m_psi != NULL)) + locker= PSI_server->get_thread_rwlock_locker(&state, that->m_psi, + PSI_RWLOCK_READLOCK); + if (likely(locker != NULL)) { - 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); + PSI_server->start_rwlock_rdwait(locker, src_file, src_line); + result= rw_pr_rdlock(&that->m_prlock); + PSI_server->end_rwlock_rdwait(locker, result); + return result; } #endif + result= rw_pr_rdlock(&that->m_prlock); -#ifdef HAVE_PSI_RWLOCK_INTERFACE - if (likely(locker != NULL)) - PSI_server->end_rwlock_rdwait(locker, result); -#endif return result; } #endif @@ -859,21 +853,20 @@ static inline int inline_mysql_rwlock_wr { int result; #ifdef HAVE_PSI_RWLOCK_INTERFACE - struct PSI_rwlock_locker *locker= NULL; + struct PSI_rwlock_locker *locker; PSI_rwlock_locker_state state; - if (likely(that->m_psi != NULL)) + locker= PSI_server->get_thread_rwlock_locker(&state, that->m_psi, + PSI_RWLOCK_WRITELOCK); + if (likely(locker != NULL)) { - 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); + PSI_server->start_rwlock_wrwait(locker, src_file, src_line); + result= rw_wrlock(&that->m_rwlock); + PSI_server->end_rwlock_wrwait(locker, result); + return result; } #endif + result= rw_wrlock(&that->m_rwlock); -#ifdef HAVE_PSI_RWLOCK_INTERFACE - if (likely(locker != NULL)) - PSI_server->end_rwlock_wrwait(locker, result); -#endif return result; } @@ -887,21 +880,20 @@ static inline int inline_mysql_prlock_wr { int result; #ifdef HAVE_PSI_RWLOCK_INTERFACE - struct PSI_rwlock_locker *locker= NULL; + struct PSI_rwlock_locker *locker; PSI_rwlock_locker_state state; - if (likely(that->m_psi != NULL)) + locker= PSI_server->get_thread_rwlock_locker(&state, that->m_psi, + PSI_RWLOCK_WRITELOCK); + if (likely(locker != NULL)) { - 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); + PSI_server->start_rwlock_wrwait(locker, src_file, src_line); + result= rw_pr_wrlock(&that->m_prlock); + PSI_server->end_rwlock_wrwait(locker, result); + return result; } #endif + result= rw_pr_wrlock(&that->m_prlock); -#ifdef HAVE_PSI_RWLOCK_INTERFACE - if (likely(locker != NULL)) - PSI_server->end_rwlock_wrwait(locker, result); -#endif return result; } #endif @@ -915,21 +907,20 @@ static inline int inline_mysql_rwlock_tr { int result; #ifdef HAVE_PSI_RWLOCK_INTERFACE - struct PSI_rwlock_locker *locker= NULL; + struct PSI_rwlock_locker *locker; PSI_rwlock_locker_state state; - if (likely(that->m_psi != NULL)) + locker= PSI_server->get_thread_rwlock_locker(&state, that->m_psi, + PSI_RWLOCK_TRYREADLOCK); + if (likely(locker != NULL)) { - 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); + PSI_server->start_rwlock_rdwait(locker, src_file, src_line); + result= rw_tryrdlock(&that->m_rwlock); + PSI_server->end_rwlock_rdwait(locker, result); + return result; } #endif + result= rw_tryrdlock(&that->m_rwlock); -#ifdef HAVE_PSI_RWLOCK_INTERFACE - if (likely(locker != NULL)) - PSI_server->end_rwlock_rdwait(locker, result); -#endif return result; } @@ -942,21 +933,20 @@ static inline int inline_mysql_rwlock_tr { int result; #ifdef HAVE_PSI_RWLOCK_INTERFACE - struct PSI_rwlock_locker *locker= NULL; + struct PSI_rwlock_locker *locker; PSI_rwlock_locker_state state; - if (likely(that->m_psi != NULL)) + locker= PSI_server->get_thread_rwlock_locker(&state, that->m_psi, + PSI_RWLOCK_TRYWRITELOCK); + if (likely(locker != NULL)) { - 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); + PSI_server->start_rwlock_wrwait(locker, src_file, src_line); + result= rw_trywrlock(&that->m_rwlock); + PSI_server->end_rwlock_wrwait(locker, result); + return result; } #endif + result= rw_trywrlock(&that->m_rwlock); -#ifdef HAVE_PSI_RWLOCK_INTERFACE - if (likely(locker != NULL)) - PSI_server->end_rwlock_wrwait(locker, result); -#endif return result; } @@ -965,8 +955,7 @@ static inline int inline_mysql_rwlock_un { int result; #ifdef HAVE_PSI_RWLOCK_INTERFACE - if (likely(that->m_psi != NULL)) - PSI_server->unlock_rwlock(that->m_psi); + PSI_server->unlock_rwlock(that->m_psi); #endif result= rw_unlock(&that->m_rwlock); return result; @@ -978,8 +967,7 @@ static inline int inline_mysql_prlock_un { int result; #ifdef HAVE_PSI_RWLOCK_INTERFACE - if (likely(that->m_psi != NULL)) - PSI_server->unlock_rwlock(that->m_psi); + PSI_server->unlock_rwlock(that->m_psi); #endif result= rw_pr_unlock(&that->m_prlock); return result; @@ -1022,11 +1010,8 @@ static inline int inline_mysql_cond_dest mysql_cond_t *that) { #ifdef HAVE_PSI_COND_INTERFACE - if (likely(that->m_psi != NULL)) - { - PSI_server->destroy_cond(that->m_psi); - that->m_psi= NULL; - } + PSI_server->destroy_cond(that->m_psi); + that->m_psi= NULL; #endif return pthread_cond_destroy(&that->m_cond); } @@ -1041,21 +1026,20 @@ static inline int inline_mysql_cond_wait { int result; #ifdef HAVE_PSI_COND_INTERFACE - struct PSI_cond_locker *locker= NULL; + struct PSI_cond_locker *locker; PSI_cond_locker_state state; - if (likely(that->m_psi != NULL)) + locker= PSI_server->get_thread_cond_locker(&state, that->m_psi, mutex->m_psi, + PSI_COND_WAIT); + if (likely(locker != NULL)) { - 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); + PSI_server->start_cond_wait(locker, src_file, src_line); + result= pthread_cond_wait(&that->m_cond, &mutex->m_mutex); + PSI_server->end_cond_wait(locker, result); + return result; } #endif + result= pthread_cond_wait(&that->m_cond, &mutex->m_mutex); -#ifdef HAVE_PSI_COND_INTERFACE - if (likely(locker != NULL)) - PSI_server->end_cond_wait(locker, result); -#endif return result; } @@ -1070,21 +1054,20 @@ static inline int inline_mysql_cond_time { int result; #ifdef HAVE_PSI_COND_INTERFACE - struct PSI_cond_locker *locker= NULL; + struct PSI_cond_locker *locker; PSI_cond_locker_state state; - if (likely(that->m_psi != NULL)) + locker= PSI_server->get_thread_cond_locker(&state, that->m_psi, mutex->m_psi, + PSI_COND_TIMEDWAIT); + if (likely(locker != NULL)) { - 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); + PSI_server->start_cond_wait(locker, src_file, src_line); + result= pthread_cond_timedwait(&that->m_cond, &mutex->m_mutex, abstime); + PSI_server->end_cond_wait(locker, result); + return result; } #endif + result= pthread_cond_timedwait(&that->m_cond, &mutex->m_mutex, abstime); -#ifdef HAVE_PSI_COND_INTERFACE - if (likely(locker != NULL)) - PSI_server->end_cond_wait(locker, result); -#endif return result; } @@ -1093,8 +1076,7 @@ static inline int inline_mysql_cond_sign { int result; #ifdef HAVE_PSI_COND_INTERFACE - if (likely(that->m_psi != NULL)) - PSI_server->signal_cond(that->m_psi); + PSI_server->signal_cond(that->m_psi); #endif result= pthread_cond_signal(&that->m_cond); return result; @@ -1105,8 +1087,7 @@ static inline int inline_mysql_cond_broa { int result; #ifdef HAVE_PSI_COND_INTERFACE - if (likely(that->m_psi != NULL)) - PSI_server->broadcast_cond(that->m_psi); + PSI_server->broadcast_cond(that->m_psi); #endif result= pthread_cond_broadcast(&that->m_cond); return result; === modified file 'storage/innobase/include/os0sync.ic' --- a/storage/innobase/include/os0sync.ic 2011-02-15 09:40:34 +0000 +++ b/storage/innobase/include/os0sync.ic 2011-05-04 03:17:46 +0000 @@ -65,10 +65,11 @@ pfs_os_fast_mutex_init( key */ os_fast_mutex_t* fast_mutex) /*!< out: fast mutex */ { - fast_mutex->pfs_psi = (PSI_server && PFS_IS_INSTRUMENTED(key)) - ? PSI_server->init_mutex(key, - &fast_mutex->mutex) - : NULL; +#ifdef HAVE_PSI_MUTEX_INTERFACE + fast_mutex->pfs_psi = PSI_server->init_mutex(key, &fast_mutex->mutex); +#else + fast_mutex->pfs_psi = NULL; +#endif os_fast_mutex_init_func(&fast_mutex->mutex); } @@ -83,10 +84,10 @@ pfs_os_fast_mutex_free( /*===================*/ os_fast_mutex_t* fast_mutex) /*!< in/out: mutex */ { - if (UNIV_LIKELY(PSI_server && fast_mutex->pfs_psi)) { - PSI_server->destroy_mutex(fast_mutex->pfs_psi); - fast_mutex->pfs_psi = NULL; - } +#ifdef HAVE_PSI_MUTEX_INTERFACE + PSI_server->destroy_mutex(fast_mutex->pfs_psi); +#endif + fast_mutex->pfs_psi = NULL; os_fast_mutex_free_func(&fast_mutex->mutex); } @@ -104,23 +105,22 @@ pfs_os_fast_mutex_lock( locked */ ulint line) /*!< in: line where locked */ { - struct PSI_mutex_locker* locker = NULL; +#ifdef HAVE_PSI_MUTEX_INTERFACE + struct PSI_mutex_locker* locker; PSI_mutex_locker_state state; - int result = 0; - if (UNIV_LIKELY(PSI_server && fast_mutex->pfs_psi)) { - locker = PSI_server->get_thread_mutex_locker( + locker = PSI_server->get_thread_mutex_locker( &state, fast_mutex->pfs_psi, PSI_MUTEX_LOCK); - if (locker) { - PSI_server->start_mutex_wait(locker, file_name, line); - } + if (UNIV_LIKELY(locker != NULL)) + { + PSI_server->start_mutex_wait(locker, file_name, line); + os_fast_mutex_lock_func(&fast_mutex->mutex); + PSI_server->end_mutex_wait(locker, 0); + return; } +#endif os_fast_mutex_lock_func(&fast_mutex->mutex); - - if (locker) { - PSI_server->end_mutex_wait(locker, result); - } } /**********************************************************//** NOTE! Please use the corresponding macro os_fast_mutex_unlock, not directly @@ -133,9 +133,9 @@ pfs_os_fast_mutex_unlock( /*=====================*/ os_fast_mutex_t* fast_mutex) /*!< in/out: mutex to release */ { - if (UNIV_LIKELY(PSI_server && fast_mutex->pfs_psi)) { - PSI_server->unlock_mutex(fast_mutex->pfs_psi); - } +#ifdef HAVE_PSI_MUTEX_INTERFACE + PSI_server->unlock_mutex(fast_mutex->pfs_psi); +#endif os_fast_mutex_unlock_func(&fast_mutex->mutex); } === modified file 'storage/innobase/include/sync0rw.ic' --- a/storage/innobase/include/sync0rw.ic 2011-04-12 01:21:37 +0000 +++ b/storage/innobase/include/sync0rw.ic 2011-05-04 03:17:46 +0000 @@ -645,10 +645,12 @@ pfs_rw_lock_create_func( const char* cfile_name, /*!< in: file name where created */ ulint cline) /*!< in: file line where created */ { +#ifdef HAVE_PSI_RWLOCK_INTERFACE /* Initialize the rwlock for performance schema */ - lock->pfs_psi = (PSI_server && PFS_IS_INSTRUMENTED(key)) - ? PSI_server->init_rwlock(key, lock) - : NULL; + lock->pfs_psi = PSI_server->init_rwlock(key, lock); +#else + lock->pfs_psi = NULL; +#endif /* The actual function to initialize an rwlock */ rw_lock_create_func(lock, @@ -675,25 +677,24 @@ pfs_rw_lock_x_lock_func( const char* file_name,/*!< in: file name where lock requested */ ulint line) /*!< in: line where requested */ { - struct PSI_rwlock_locker* locker = NULL; +#ifdef HAVE_PSI_RWLOCK_INTERFACE + struct PSI_rwlock_locker* locker; 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( + locker = PSI_server->get_thread_rwlock_locker( &state, lock->pfs_psi, PSI_RWLOCK_WRITELOCK); - if (locker) { - PSI_server->start_rwlock_wrwait(locker, - file_name, line); - } + if (UNIV_LIKELY(locker != NULL)) + { + PSI_server->start_rwlock_wrwait(locker, file_name, line); + rw_lock_x_lock_func(lock, pass, file_name, line); + PSI_server->end_rwlock_wrwait(locker, 0); + return; } +#endif rw_lock_x_lock_func(lock, pass, file_name, line); - - if (locker) { - PSI_server->end_rwlock_wrwait(locker, 0); - } } /******************************************************************//** Performance schema instrumented wrap function for @@ -710,27 +711,25 @@ pfs_rw_lock_x_lock_func_nowait( requested */ ulint line) /*!< in: line where requested */ { - struct PSI_rwlock_locker* locker = NULL; +#ifdef HAVE_PSI_RWLOCK_INTERFACE + struct PSI_rwlock_locker* locker; 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( + locker = PSI_server->get_thread_rwlock_locker( &state, lock->pfs_psi, PSI_RWLOCK_WRITELOCK); - if (locker) { - PSI_server->start_rwlock_wrwait(locker, - file_name, line); - } - } - - ret = rw_lock_x_lock_func_nowait(lock, file_name, line); - - if (locker) { + if (UNIV_LIKELY(locker != NULL)) + { + PSI_server->start_rwlock_wrwait(locker, file_name, line); + ret = rw_lock_x_lock_func_nowait(lock, file_name, line); PSI_server->end_rwlock_wrwait(locker, 0); + return(ret); } +#endif + ret = rw_lock_x_lock_func_nowait(lock, file_name, line); return(ret); } /******************************************************************//** @@ -743,10 +742,10 @@ pfs_rw_lock_free_func( /*==================*/ rw_lock_t* lock) /*!< in: pointer to rw-lock */ { - if (UNIV_LIKELY(PSI_server && lock->pfs_psi)) { - PSI_server->destroy_rwlock(lock->pfs_psi); - lock->pfs_psi = NULL; - } +#ifdef HAVE_PSI_RWLOCK_INTERFACE + PSI_server->destroy_rwlock(lock->pfs_psi); +#endif + lock->pfs_psi = NULL; rw_lock_free_func(lock); } @@ -766,24 +765,23 @@ pfs_rw_lock_s_lock_func( requested */ ulint line) /*!< in: line where requested */ { +#ifdef HAVE_PSI_RWLOCK_INTERFACE 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( + locker = PSI_server->get_thread_rwlock_locker( &state, lock->pfs_psi, PSI_RWLOCK_READLOCK); - if (locker) { - PSI_server->start_rwlock_rdwait(locker, - file_name, line); - } + if (UNIV_LIKELY(locker != NULL)) + { + PSI_server->start_rwlock_rdwait(locker, file_name, line); + rw_lock_s_lock_func(lock, pass, file_name, line); + PSI_server->end_rwlock_rdwait(locker, 0); + return; } +#endif rw_lock_s_lock_func(lock, pass, file_name, line); - - if (locker) { - PSI_server->end_rwlock_rdwait(locker, 0); - } } /******************************************************************//** Performance schema instrumented wrap function for rw_lock_s_lock_func() @@ -801,26 +799,24 @@ pfs_rw_lock_s_lock_low( const char* file_name, /*!< in: file name where lock requested */ ulint line) /*!< in: line where requested */ { +#ifdef HAVE_PSI_RWLOCK_INTERFACE 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( + locker = PSI_server->get_thread_rwlock_locker( &state, lock->pfs_psi, PSI_RWLOCK_READLOCK); - if (locker) { - PSI_server->start_rwlock_rdwait(locker, - file_name, line); - } - } - - ret = rw_lock_s_lock_low(lock, pass, file_name, line); - - if (locker) { + if (UNIV_LIKELY(locker != NULL)) + { + PSI_server->start_rwlock_rdwait(locker, file_name, line); + ret = rw_lock_s_lock_low(lock, pass, file_name, line); PSI_server->end_rwlock_rdwait(locker, 0); + return(ret); } +#endif + ret = rw_lock_s_lock_low(lock, pass, file_name, line); return(ret); } @@ -839,10 +835,10 @@ pfs_rw_lock_x_unlock_func( #endif rw_lock_t* lock) /*!< in/out: rw-lock */ { +#ifdef HAVE_PSI_RWLOCK_INTERFACE /* Inform performance schema we are unlocking the lock */ - if (UNIV_LIKELY(PSI_server && lock->pfs_psi)) { - PSI_server->unlock_rwlock(lock->pfs_psi); - } + PSI_server->unlock_rwlock(lock->pfs_psi); +#endif rw_lock_x_unlock_func( #ifdef UNIV_SYNC_DEBUG @@ -866,10 +862,10 @@ pfs_rw_lock_s_unlock_func( #endif rw_lock_t* lock) /*!< in/out: rw-lock */ { +#ifdef HAVE_PSI_RWLOCK_INTERFACE /* Inform performance schema we are unlocking the lock */ - if (UNIV_LIKELY(PSI_server && lock->pfs_psi)) { - PSI_server->unlock_rwlock(lock->pfs_psi); - } + PSI_server->unlock_rwlock(lock->pfs_psi); +#endif rw_lock_s_unlock_func( #ifdef UNIV_SYNC_DEBUG === modified file 'storage/innobase/include/sync0sync.ic' --- a/storage/innobase/include/sync0sync.ic 2010-10-26 23:14:42 +0000 +++ b/storage/innobase/include/sync0sync.ic 2011-05-04 03:17:46 +0000 @@ -236,23 +236,22 @@ pfs_mutex_enter_func( const char* file_name, /*!< in: file name where locked */ ulint line) /*!< in: line where locked */ { - struct PSI_mutex_locker* locker = NULL; +#ifdef HAVE_PSI_MUTEX_INTERFACE + struct PSI_mutex_locker* locker; PSI_mutex_locker_state state; - int result = 0; - if (UNIV_LIKELY(PSI_server && mutex->pfs_psi)) { - locker = PSI_server->get_thread_mutex_locker( + locker = PSI_server->get_thread_mutex_locker( &state, mutex->pfs_psi, PSI_MUTEX_LOCK); - if (locker) { - PSI_server->start_mutex_wait(locker, file_name, line); - } + if (UNIV_LIKELY(locker != NULL)) + { + PSI_server->start_mutex_wait(locker, file_name, line); + mutex_enter_func(mutex, file_name, line); + PSI_server->end_mutex_wait(locker, 0); + return; } +#endif mutex_enter_func(mutex, file_name, line); - - if (locker) { - PSI_server->end_mutex_wait(locker, result); - } } /********************************************************************//** NOTE! Please use the corresponding macro mutex_enter_nowait(), not directly @@ -270,24 +269,23 @@ pfs_mutex_enter_nowait_func( ulint line) /*!< in: line where requested */ { ulint ret; + +#ifdef HAVE_PSI_MUTEX_INTERFACE struct PSI_mutex_locker* locker = NULL; PSI_mutex_locker_state state; - int result = 0; - if (UNIV_LIKELY(PSI_server && mutex->pfs_psi)) { - locker = PSI_server->get_thread_mutex_locker( + locker = PSI_server->get_thread_mutex_locker( &state, mutex->pfs_psi, PSI_MUTEX_LOCK); - if (locker) { - PSI_server->start_mutex_wait(locker, file_name, line); - } + if (UNIV_LIKELY(locker != NULL)) + { + PSI_server->start_mutex_wait(locker, file_name, line); + ret = mutex_enter_nowait_func(mutex, file_name, line); + PSI_server->end_mutex_wait(locker, 0); + return(ret); } +#endif ret = mutex_enter_nowait_func(mutex, file_name, line); - - if (locker) { - PSI_server->end_mutex_wait(locker, result); - } - return(ret); } /******************************************************************//** @@ -301,9 +299,9 @@ pfs_mutex_exit_func( /*================*/ mutex_t* mutex) /*!< in: pointer to mutex */ { - if (UNIV_LIKELY(PSI_server && mutex->pfs_psi)) { - PSI_server->unlock_mutex(mutex->pfs_psi); - } +#ifdef HAVE_PSI_MUTEX_INTERFACE + PSI_server->unlock_mutex(mutex->pfs_psi); +#endif mutex_exit_func(mutex); } @@ -329,9 +327,11 @@ pfs_mutex_create_func( const char* cfile_name, /*!< in: file name where created */ ulint cline) /*!< in: file line where created */ { - mutex->pfs_psi = (PSI_server && PFS_IS_INSTRUMENTED(key)) - ? PSI_server->init_mutex(key, mutex) - : NULL; +#ifdef HAVE_PSI_MUTEX_INTERFACE + mutex->pfs_psi = PSI_server->init_mutex(key, mutex); +#else + mutex->pfs_psi = NULL; +#endif mutex_create_func(mutex, # ifdef UNIV_DEBUG @@ -354,10 +354,10 @@ pfs_mutex_free_func( /*================*/ mutex_t* mutex) /*!< in: mutex */ { - if (UNIV_LIKELY(PSI_server && mutex->pfs_psi)) { - PSI_server->destroy_mutex(mutex->pfs_psi); - mutex->pfs_psi = NULL; - } +#ifdef HAVE_PSI_MUTEX_INTERFACE + PSI_server->destroy_mutex(mutex->pfs_psi); +#endif + mutex->pfs_psi = NULL; mutex_free_func(mutex); } === modified file 'storage/innobase/include/univ.i' --- a/storage/innobase/include/univ.i 2011-04-27 21:49:19 +0000 +++ b/storage/innobase/include/univ.i 2011-05-04 03:17:46 +0000 @@ -150,7 +150,7 @@ instrumentation even if their correspond define is set. And this PFS_NOT_INSTRUMENTED is used as the key value to identify those objects that would be excluded from instrumentation. */ -# define PFS_NOT_INSTRUMENTED ULINT32_UNDEFINED +# define PFS_NOT_INSTRUMENTED 0 # define PFS_IS_INSTRUMENTED(key) ((key) != PFS_NOT_INSTRUMENTED) === modified file 'storage/perfschema/pfs.cc' --- a/storage/perfschema/pfs.cc 2011-02-14 14:23:55 +0000 +++ b/storage/perfschema/pfs.cc 2011-05-04 03:17:46 +0000 @@ -1352,6 +1352,10 @@ init_mutex_v1(PSI_mutex_key key, const v static void destroy_mutex_v1(PSI_mutex* mutex) { PFS_mutex *pfs= reinterpret_cast (mutex); + + if (unlikely(pfs == NULL)) + return; + destroy_mutex(pfs); } @@ -1372,6 +1376,10 @@ init_rwlock_v1(PSI_rwlock_key key, const static void destroy_rwlock_v1(PSI_rwlock* rwlock) { PFS_rwlock *pfs= reinterpret_cast (rwlock); + + if (unlikely(pfs == NULL)) + return; + destroy_rwlock(pfs); } @@ -1392,6 +1400,10 @@ init_cond_v1(PSI_cond_key key, const voi static void destroy_cond_v1(PSI_cond* cond) { PFS_cond *pfs= reinterpret_cast (cond); + + if (unlikely(pfs == NULL)) + return; + destroy_cond(pfs); } @@ -1879,15 +1891,19 @@ static PSI_mutex_locker* get_thread_mutex_locker_v1(PSI_mutex_locker_state *state, PSI_mutex *mutex, PSI_mutex_operation op) { - PFS_mutex *pfs_mutex= reinterpret_cast (mutex); DBUG_ASSERT((int) op >= 0); DBUG_ASSERT((uint) op < array_elements(mutex_operation_map)); DBUG_ASSERT(state != NULL); - DBUG_ASSERT(pfs_mutex != NULL); - DBUG_ASSERT(pfs_mutex->m_class != NULL); if (! flag_global_instrumentation) return NULL; + + PFS_mutex *pfs_mutex= reinterpret_cast (mutex); + if (unlikely(pfs_mutex == NULL)) + return NULL; + + DBUG_ASSERT(pfs_mutex->m_class != NULL); + PFS_mutex_class *klass= pfs_mutex->m_class; if (! klass->m_enabled) return NULL; @@ -1967,15 +1983,19 @@ static PSI_rwlock_locker* get_thread_rwlock_locker_v1(PSI_rwlock_locker_state *state, PSI_rwlock *rwlock, PSI_rwlock_operation op) { - PFS_rwlock *pfs_rwlock= reinterpret_cast (rwlock); DBUG_ASSERT(static_cast (op) >= 0); DBUG_ASSERT(static_cast (op) < array_elements(rwlock_operation_map)); DBUG_ASSERT(state != NULL); - DBUG_ASSERT(pfs_rwlock != NULL); - DBUG_ASSERT(pfs_rwlock->m_class != NULL); if (! flag_global_instrumentation) return NULL; + + PFS_rwlock *pfs_rwlock= reinterpret_cast (rwlock); + if (unlikely(pfs_rwlock == NULL)) + return NULL; + + DBUG_ASSERT(pfs_rwlock->m_class != NULL); + PFS_rwlock_class *klass= pfs_rwlock->m_class; if (! klass->m_enabled) return NULL; @@ -2067,15 +2087,19 @@ get_thread_cond_locker_v1(PSI_cond_locke this parameter here will be used to adjust the mutex state, in start_cond_wait_v1() and end_cond_wait_v1(). */ - PFS_cond *pfs_cond= reinterpret_cast (cond); DBUG_ASSERT(static_cast (op) >= 0); DBUG_ASSERT(static_cast (op) < array_elements(cond_operation_map)); DBUG_ASSERT(state != NULL); - DBUG_ASSERT(pfs_cond != NULL); - DBUG_ASSERT(pfs_cond->m_class != NULL); if (! flag_global_instrumentation) return NULL; + + PFS_cond *pfs_cond= reinterpret_cast (cond); + if (unlikely(pfs_cond == NULL)) + return NULL; + + DBUG_ASSERT(pfs_cond->m_class != NULL); + PFS_cond_class *klass= pfs_cond->m_class; if (! klass->m_enabled) return NULL; @@ -2205,13 +2229,17 @@ get_thread_table_io_locker_v1(PSI_table_ DBUG_ASSERT(static_cast (op) >= 0); DBUG_ASSERT(static_cast (op) < array_elements(table_io_operation_map)); DBUG_ASSERT(state != NULL); - PFS_table *pfs_table= reinterpret_cast (table); - DBUG_ASSERT(pfs_table != NULL); - DBUG_ASSERT(pfs_table->m_share != NULL); if (! flag_global_instrumentation) return NULL; + PFS_table *pfs_table= reinterpret_cast (table); + + if (unlikely(pfs_table == NULL)) + return NULL; + + DBUG_ASSERT(pfs_table->m_share != NULL); + if (! global_table_io_class.m_enabled) return NULL; @@ -2311,10 +2339,6 @@ get_thread_table_lock_locker_v1(PSI_tabl PSI_table *table, PSI_table_lock_operation op, ulong op_flags) { DBUG_ASSERT(state != NULL); - PFS_table *pfs_table= reinterpret_cast (table); - DBUG_ASSERT(pfs_table != NULL); - DBUG_ASSERT(pfs_table->m_share != NULL); - DBUG_ASSERT((op == PSI_TABLE_LOCK) || (op == PSI_TABLE_EXTERNAL_LOCK)); if (! flag_global_instrumentation) @@ -2323,6 +2347,13 @@ get_thread_table_lock_locker_v1(PSI_tabl if (! global_table_lock_class.m_enabled) return NULL; + PFS_table *pfs_table= reinterpret_cast (table); + + if (unlikely(pfs_table == NULL)) + return NULL; + + DBUG_ASSERT(pfs_table->m_share != NULL); + PFS_table_share *share= pfs_table->m_share; if (unlikely(setup_objects_version != share->m_setup_objects_version)) { @@ -2518,9 +2549,6 @@ static PSI_file_locker* get_thread_file_stream_locker_v1(PSI_file_locker_state *state, PSI_file *file, PSI_file_operation op) { - PFS_file *pfs_file= reinterpret_cast (file); - DBUG_ASSERT(pfs_file != NULL); - DBUG_ASSERT(pfs_file->m_class != NULL); DBUG_ASSERT(static_cast (op) >= 0); DBUG_ASSERT(static_cast (op) < array_elements(file_operation_map)); DBUG_ASSERT(state != NULL); @@ -2528,6 +2556,12 @@ get_thread_file_stream_locker_v1(PSI_fil if (! flag_global_instrumentation) return NULL; + PFS_file *pfs_file= reinterpret_cast (file); + if (unlikely(pfs_file == NULL)) + return NULL; + + DBUG_ASSERT(pfs_file->m_class != NULL); + PFS_file_class *klass= pfs_file->m_class; if (! klass->m_enabled) return NULL; @@ -2708,7 +2742,9 @@ get_thread_file_descriptor_locker_v1(PSI static void unlock_mutex_v1(PSI_mutex *mutex) { PFS_mutex *pfs_mutex= reinterpret_cast (mutex); - DBUG_ASSERT(pfs_mutex != NULL); + + if (unlikely(pfs_mutex == NULL)) + return; /* Note that this code is still protected by the instrumented mutex, @@ -2751,7 +2787,10 @@ static void unlock_mutex_v1(PSI_mutex *m static void unlock_rwlock_v1(PSI_rwlock *rwlock) { PFS_rwlock *pfs_rwlock= reinterpret_cast (rwlock); - DBUG_ASSERT(pfs_rwlock != NULL); + + if (unlikely(pfs_rwlock == NULL)) + return; + bool last_writer= false; bool last_reader= false; @@ -2831,7 +2870,9 @@ static void unlock_rwlock_v1(PSI_rwlock static void signal_cond_v1(PSI_cond* cond) { PFS_cond *pfs_cond= reinterpret_cast (cond); - DBUG_ASSERT(pfs_cond != NULL); + + if (unlikely(pfs_cond == NULL)) + return; pfs_cond->m_cond_stat.m_signal_count++; } @@ -2843,7 +2884,9 @@ static void signal_cond_v1(PSI_cond* con static void broadcast_cond_v1(PSI_cond* cond) { PFS_cond *pfs_cond= reinterpret_cast (cond); - DBUG_ASSERT(pfs_cond != NULL); + + if (unlikely(pfs_cond == NULL)) + return; pfs_cond->m_cond_stat.m_broadcast_count++; } No bundle (reason: useless for push emails).