From 9b40d87204ad2b1a06928fff7d41f492c711143a Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Mon, 18 Apr 2011 21:29:06 -0600 Subject: [PATCH] Bug#12346211 PERF IMPACT OF PERFORMANCE-SCHEMA WITH DISABLED INSTRUMENTS/CONSUMERS Not a fix. Instrumentation patch, to help investigations. The code can now be compiled with the added #defines: DISABLE_PSI_MUTEX DISABLE_PSI_RWLOCK DISABLE_PSI_COND DISABLE_PSI_FILE DISABLE_PSI_TABLE DISABLE_PSI_STAGE DISABLE_PSI_STATEMENT to avoid building with a given instrumentation. For example, to disable mutexes, add -DDISABLE_PSI_MUTEX to CFLAGS. --- include/mysql/psi/mysql_file.h | 275 ++++++++++++---------- include/mysql/psi/mysql_stage.h | 25 +- include/mysql/psi/mysql_statement.h | 35 ++- include/mysql/psi/mysql_table.h | 14 +- include/mysql/psi/mysql_thread.h | 227 +++++++++++++----- include/mysql/psi/psi.h | 84 +++++++ mysys/my_init.c | 11 +- plugin/semisync/semisync_master_plugin.cc | 7 +- sql/debug_sync.cc | 7 +- sql/events.cc | 9 +- sql/ha_ndbcluster.cc | 11 +- sql/handler.cc | 10 +- sql/item_func.cc | 6 +- sql/mdl.cc | 10 +- sql/mysqld.cc | 29 ++- sql/rpl_master.cc | 6 +- sql/rpl_slave.cc | 5 +- sql/sp_cache.cc | 5 +- sql/sql_acl.cc | 4 +- sql/sql_audit.cc | 5 +- sql/sql_base.cc | 9 +- sql/sql_class.cc | 69 +++--- sql/sql_db.cc | 5 +- sql/sql_parse.cc | 2 +- sql/sql_plugin.cc | 5 +- sql/sql_servers.cc | 5 +- sql/sql_udf.cc | 5 +- sql/table.cc | 2 +- sql/tztime.cc | 5 +- storage/archive/ha_archive.cc | 5 +- storage/blackhole/ha_blackhole.cc | 5 +- storage/csv/ha_tina.cc | 7 +- storage/example/ha_example.cc | 5 +- storage/federated/ha_federated.cc | 5 +- storage/heap/hp_static.c | 5 +- storage/innobase/handler/ha_innodb.cc | 12 +- storage/myisam/mi_static.c | 13 +- storage/myisammrg/myrg_static.c | 7 +- 38 files changed, 561 insertions(+), 395 deletions(-) diff --git a/include/mysql/psi/mysql_file.h b/include/mysql/psi/mysql_file.h index 6fc6689c47d..4658b8b65c1 100644 --- a/include/mysql/psi/mysql_file.h +++ b/include/mysql/psi/mysql_file.h @@ -49,12 +49,19 @@ @{ */ +/** + @def mysql_file_register(P1, P2, P3) + File registration. +*/ +#define mysql_file_register(P1, P2, P3) \ + inline_mysql_file_register(P1, P2, P3) + /** @def mysql_file_fgets(P1, P2, F) Instrumented fgets. @c mysql_file_fgets is a replacement for @c fgets. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE #define mysql_file_fgets(P1, P2, F) \ inline_mysql_file_fgets(__FILE__, __LINE__, P1, P2, F) #else @@ -67,7 +74,7 @@ Instrumented fgetc. @c mysql_file_fgetc is a replacement for @c fgetc. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE #define mysql_file_fgetc(F) inline_mysql_file_fgetc(__FILE__, __LINE__, F) #else #define mysql_file_fgetc(F) inline_mysql_file_fgetc(F) @@ -78,7 +85,7 @@ Instrumented fputs. @c mysql_file_fputs is a replacement for @c fputs. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE #define mysql_file_fputs(P1, F) \ inline_mysql_file_fputs(__FILE__, __LINE__, P1, F) #else @@ -91,7 +98,7 @@ Instrumented fputc. @c mysql_file_fputc is a replacement for @c fputc. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE #define mysql_file_fputc(P1, F) \ inline_mysql_file_fputc(__FILE__, __LINE__, P1, F) #else @@ -111,7 +118,7 @@ Instrumented vfprintf. @c mysql_file_vfprintf is a replacement for @c vfprintf. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE #define mysql_file_vfprintf(F, P1, P2) \ inline_mysql_file_vfprintf(__FILE__, __LINE__, F, P1, P2) #else @@ -124,7 +131,7 @@ Instrumented fflush. @c mysql_file_fflush is a replacement for @c fflush. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE #define mysql_file_fflush(F) \ inline_mysql_file_fflush(__FILE__, __LINE__, F) #else @@ -144,7 +151,7 @@ Instrumented fstat. @c mysql_file_fstat is a replacement for @c my_fstat. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE #define mysql_file_fstat(FN, S, FL) \ inline_mysql_file_fstat(__FILE__, __LINE__, FN, S, FL) #else @@ -157,7 +164,7 @@ Instrumented stat. @c mysql_file_stat is a replacement for @c my_stat. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE #define mysql_file_stat(K, FN, S, FL) \ inline_mysql_file_stat(K, __FILE__, __LINE__, FN, S, FL) #else @@ -170,7 +177,7 @@ Instrumented chsize. @c mysql_file_chsize is a replacement for @c my_chsize. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE #define mysql_file_chsize(F, P1, P2, P3) \ inline_mysql_file_chsize(__FILE__, __LINE__, F, P1, P2, P3) #else @@ -183,7 +190,7 @@ Instrumented fopen. @c mysql_file_fopen is a replacement for @c my_fopen. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE #define mysql_file_fopen(K, N, F1, F2) \ inline_mysql_file_fopen(K, __FILE__, __LINE__, N, F1, F2) #else @@ -203,7 +210,7 @@ @code DBUG_ASSERT(file != NULL) @endcode, since doing so could introduce regressions. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE #define mysql_file_fclose(FD, FL) \ inline_mysql_file_fclose(__FILE__, __LINE__, FD, FL) #else @@ -216,7 +223,7 @@ Instrumented fread. @c mysql_file_fread is a replacement for @c my_fread. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE #define mysql_file_fread(FD, P1, P2, P3) \ inline_mysql_file_fread(__FILE__, __LINE__, FD, P1, P2, P3) #else @@ -229,7 +236,7 @@ Instrumented fwrite. @c mysql_file_fwrite is a replacement for @c my_fwrite. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE #define mysql_file_fwrite(FD, P1, P2, P3) \ inline_mysql_file_fwrite(__FILE__, __LINE__, FD, P1, P2, P3) #else @@ -242,7 +249,7 @@ Instrumented fseek. @c mysql_file_fseek is a replacement for @c my_fseek. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE #define mysql_file_fseek(FD, P, W, F) \ inline_mysql_file_fseek(__FILE__, __LINE__, FD, P, W, F) #else @@ -255,7 +262,7 @@ Instrumented ftell. @c mysql_file_ftell is a replacement for @c my_ftell. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE #define mysql_file_ftell(FD, F) \ inline_mysql_file_ftell(__FILE__, __LINE__, FD, F) #else @@ -268,7 +275,7 @@ Instrumented create. @c mysql_file_create is a replacement for @c my_create. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE #define mysql_file_create(K, N, F1, F2, F3) \ inline_mysql_file_create(K, __FILE__, __LINE__, N, F1, F2, F3) #else @@ -281,7 +288,7 @@ Instrumented create_temp_file. @c mysql_file_create_temp is a replacement for @c create_temp_file. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE #define mysql_file_create_temp(K, T, D, P, M, F) \ inline_mysql_file_create_temp(K, T, D, P, M, F) #else @@ -294,7 +301,7 @@ Instrumented open. @c mysql_file_open is a replacement for @c my_open. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE #define mysql_file_open(K, N, F1, F2) \ inline_mysql_file_open(K, __FILE__, __LINE__, N, F1, F2) #else @@ -307,7 +314,7 @@ Instrumented close. @c mysql_file_close is a replacement for @c my_close. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE #define mysql_file_close(FD, F) \ inline_mysql_file_close(__FILE__, __LINE__, FD, F) #else @@ -320,7 +327,7 @@ Instrumented read. @c mysql_read is a replacement for @c my_read. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE #define mysql_file_read(FD, B, S, F) \ inline_mysql_file_read(__FILE__, __LINE__, FD, B, S, F) #else @@ -333,7 +340,7 @@ Instrumented write. @c mysql_file_write is a replacement for @c my_write. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE #define mysql_file_write(FD, B, S, F) \ inline_mysql_file_write(__FILE__, __LINE__, FD, B, S, F) #else @@ -346,7 +353,7 @@ Instrumented pread. @c mysql_pread is a replacement for @c my_pread. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE #define mysql_file_pread(FD, B, S, O, F) \ inline_mysql_file_pread(__FILE__, __LINE__, FD, B, S, O, F) #else @@ -359,7 +366,7 @@ Instrumented pwrite. @c mysql_file_pwrite is a replacement for @c my_pwrite. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE #define mysql_file_pwrite(FD, B, S, O, F) \ inline_mysql_file_pwrite(__FILE__, __LINE__, FD, B, S, O, F) #else @@ -372,7 +379,7 @@ Instrumented seek. @c mysql_file_seek is a replacement for @c my_seek. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE #define mysql_file_seek(FD, P, W, F) \ inline_mysql_file_seek(__FILE__, __LINE__, FD, P, W, F) #else @@ -385,7 +392,7 @@ Instrumented tell. @c mysql_file_tell is a replacement for @c my_tell. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE #define mysql_file_tell(FD, F) \ inline_mysql_file_tell(__FILE__, __LINE__, FD, F) #else @@ -398,7 +405,7 @@ Instrumented delete. @c mysql_file_delete is a replacement for @c my_delete. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE #define mysql_file_delete(K, P1, P2) \ inline_mysql_file_delete(K, __FILE__, __LINE__, P1, P2) #else @@ -411,7 +418,7 @@ Instrumented rename. @c mysql_file_rename is a replacement for @c my_rename. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE #define mysql_file_rename(K, P1, P2, P3) \ inline_mysql_file_rename(K, __FILE__, __LINE__, P1, P2, P3) #else @@ -425,7 +432,7 @@ @c mysql_file_create_with_symlink is a replacement for @c my_create_with_symlink. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE #define mysql_file_create_with_symlink(K, P1, P2, P3, P4, P5) \ inline_mysql_file_create_with_symlink(K, __FILE__, __LINE__, \ P1, P2, P3, P4, P5) @@ -440,7 +447,7 @@ @c mysql_file_delete_with_symlink is a replacement for @c my_delete_with_symlink. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE #define mysql_file_delete_with_symlink(K, P1, P2) \ inline_mysql_file_delete_with_symlink(K, __FILE__, __LINE__, P1, P2) #else @@ -454,7 +461,7 @@ @c mysql_file_rename_with_symlink is a replacement for @c my_rename_with_symlink. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE #define mysql_file_rename_with_symlink(K, P1, P2, P3) \ inline_mysql_file_rename_with_symlink(K, __FILE__, __LINE__, P1, P2, P3) #else @@ -467,7 +474,7 @@ Instrumented file sync. @c mysql_file_sync is a replacement for @c my_sync. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE #define mysql_file_sync(P1, P2) \ inline_mysql_file_sync(__FILE__, __LINE__, P1, P2) #else @@ -498,15 +505,33 @@ struct st_mysql_file */ typedef struct st_mysql_file MYSQL_FILE; +static inline void inline_mysql_file_register( +#ifdef HAVE_PSI_FILE_INTERFACE + const char *category, + PSI_file_info *info, + int count +#else + const char *category __attribute__ ((unused)), + PSI_file_info *info __attribute__ ((unused)), + int count __attribute__ ((unused)) +#endif +) +{ +#ifdef HAVE_PSI_FILE_INTERFACE + if (likely(PSI_server != NULL)) + PSI_server->register_file(category, info, count); +#endif +} + static inline char * inline_mysql_file_fgets( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE const char *src_file, uint src_line, #endif char *str, int size, MYSQL_FILE *file) { char *result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE struct PSI_file_locker *locker= NULL; PSI_file_locker_state state; if (likely(PSI_server && file->m_psi)) @@ -518,7 +543,7 @@ inline_mysql_file_fgets( } #endif result= fgets(str, size, file->m_file); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE if (likely(locker != NULL)) PSI_server->end_file_wait(locker, result ? strlen(result) : 0); #endif @@ -527,13 +552,13 @@ inline_mysql_file_fgets( static inline int inline_mysql_file_fgetc( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE const char *src_file, uint src_line, #endif MYSQL_FILE *file) { int result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE struct PSI_file_locker *locker= NULL; PSI_file_locker_state state; if (likely(PSI_server && file->m_psi)) @@ -545,7 +570,7 @@ inline_mysql_file_fgetc( } #endif result= fgetc(file->m_file); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE if (likely(locker != NULL)) PSI_server->end_file_wait(locker, (size_t) 1); #endif @@ -554,13 +579,13 @@ inline_mysql_file_fgetc( static inline int inline_mysql_file_fputs( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE const char *src_file, uint src_line, #endif const char *str, MYSQL_FILE *file) { int result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE struct PSI_file_locker *locker= NULL; PSI_file_locker_state state; size_t bytes= 0; @@ -576,7 +601,7 @@ inline_mysql_file_fputs( } #endif result= fputs(str, file->m_file); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE if (likely(locker != NULL)) PSI_server->end_file_wait(locker, bytes); #endif @@ -585,13 +610,13 @@ inline_mysql_file_fputs( static inline int inline_mysql_file_fputc( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE const char *src_file, uint src_line, #endif char c, MYSQL_FILE *file) { int result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE struct PSI_file_locker *locker= NULL; PSI_file_locker_state state; if (likely(PSI_server && file->m_psi)) @@ -603,7 +628,7 @@ inline_mysql_file_fputc( } #endif result= fputc(c, file->m_file); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE if (likely(locker != NULL)) PSI_server->end_file_wait(locker, (size_t) 1); #endif @@ -618,7 +643,7 @@ inline_mysql_file_fprintf(MYSQL_FILE *file, const char *format, ...) */ int result; va_list args; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE struct PSI_file_locker *locker= NULL; PSI_file_locker_state state; if (likely(PSI_server && file->m_psi)) @@ -632,7 +657,7 @@ inline_mysql_file_fprintf(MYSQL_FILE *file, const char *format, ...) va_start(args, format); result= vfprintf(file->m_file, format, args); va_end(args); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE if (likely(locker != NULL)) PSI_server->end_file_wait(locker, (size_t) result); #endif @@ -641,13 +666,13 @@ inline_mysql_file_fprintf(MYSQL_FILE *file, const char *format, ...) static inline int inline_mysql_file_vfprintf( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE const char *src_file, uint src_line, #endif MYSQL_FILE *file, const char *format, va_list args) { int result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE struct PSI_file_locker *locker= NULL; PSI_file_locker_state state; if (likely(PSI_server && file->m_psi)) @@ -659,7 +684,7 @@ inline_mysql_file_vfprintf( } #endif result= vfprintf(file->m_file, format, args); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE if (likely(locker != NULL)) PSI_server->end_file_wait(locker, (size_t) result); #endif @@ -668,13 +693,13 @@ inline_mysql_file_vfprintf( static inline int inline_mysql_file_fflush( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE const char *src_file, uint src_line, #endif MYSQL_FILE *file) { int result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE struct PSI_file_locker *locker= NULL; PSI_file_locker_state state; if (likely(PSI_server && file->m_psi)) @@ -686,7 +711,7 @@ inline_mysql_file_fflush( } #endif result= fflush(file->m_file); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE if (likely(locker != NULL)) PSI_server->end_file_wait(locker, (size_t) 0); #endif @@ -701,13 +726,13 @@ static inline int inline_mysql_file_feof(MYSQL_FILE *file) static inline int inline_mysql_file_fstat( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE const char *src_file, uint src_line, #endif int filenr, MY_STAT *stat_area, myf flags) { int result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE struct PSI_file_locker *locker= NULL; PSI_file_locker_state state; if (likely(PSI_server != NULL)) @@ -719,7 +744,7 @@ inline_mysql_file_fstat( } #endif result= my_fstat(filenr, stat_area, flags); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE if (likely(locker != NULL)) PSI_server->end_file_wait(locker, (size_t) 0); #endif @@ -728,13 +753,13 @@ inline_mysql_file_fstat( static inline MY_STAT * inline_mysql_file_stat( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE PSI_file_key key, const char *src_file, uint src_line, #endif const char *path, MY_STAT *stat_area, myf flags) { MY_STAT *result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE struct PSI_file_locker *locker= NULL; PSI_file_locker_state state; if (likely(PSI_server != NULL)) @@ -747,7 +772,7 @@ inline_mysql_file_stat( } #endif result= my_stat(path, stat_area, flags); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE if (likely(locker != NULL)) PSI_server->end_file_wait(locker, (size_t) 0); #endif @@ -756,13 +781,13 @@ inline_mysql_file_stat( static inline int inline_mysql_file_chsize( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE const char *src_file, uint src_line, #endif File file, my_off_t newlength, int filler, myf flags) { int result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE struct PSI_file_locker *locker= NULL; PSI_file_locker_state state; if (likely(PSI_server != NULL)) @@ -775,7 +800,7 @@ inline_mysql_file_chsize( } #endif result= my_chsize(file, newlength, filler, flags); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE if (likely(locker != NULL)) PSI_server->end_file_wait(locker, (size_t) newlength); #endif @@ -784,7 +809,7 @@ inline_mysql_file_chsize( static inline MYSQL_FILE* inline_mysql_file_fopen( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE PSI_file_key key, const char *src_file, uint src_line, #endif const char *filename, int flags, myf myFlags) @@ -795,7 +820,7 @@ inline_mysql_file_fopen( { that->m_psi= NULL; { -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE struct PSI_file_locker *locker= NULL; PSI_file_locker_state state; if (likely(PSI_server != NULL)) @@ -808,7 +833,7 @@ inline_mysql_file_fopen( } #endif that->m_file= my_fopen(filename, flags, myFlags); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE if (likely(locker != NULL)) PSI_server->end_file_open_wait(locker); #endif @@ -824,7 +849,7 @@ inline_mysql_file_fopen( static inline int inline_mysql_file_fclose( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE const char *src_file, uint src_line, #endif MYSQL_FILE *file, myf flags) @@ -832,7 +857,7 @@ inline_mysql_file_fclose( int result= 0; if (likely(file != NULL)) { -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE struct PSI_file_locker *locker= NULL; PSI_file_locker_state state; DBUG_ASSERT(file != NULL); @@ -845,7 +870,7 @@ inline_mysql_file_fclose( } #endif result= my_fclose(file->m_file, flags); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE if (likely(locker != NULL)) PSI_server->end_file_wait(locker, (size_t) 0); #endif @@ -856,13 +881,13 @@ inline_mysql_file_fclose( static inline size_t inline_mysql_file_fread( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE const char *src_file, uint src_line, #endif MYSQL_FILE *file, uchar *buffer, size_t count, myf flags) { size_t result= 0; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE struct PSI_file_locker *locker= NULL; PSI_file_locker_state state; if (likely(PSI_server && file->m_psi)) @@ -874,7 +899,7 @@ inline_mysql_file_fread( } #endif result= my_fread(file->m_file, buffer, count, flags); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE if (likely(locker != NULL)) { size_t bytes_read; @@ -890,13 +915,13 @@ inline_mysql_file_fread( static inline size_t inline_mysql_file_fwrite( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE const char *src_file, uint src_line, #endif MYSQL_FILE *file, const uchar *buffer, size_t count, myf flags) { size_t result= 0; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE struct PSI_file_locker *locker= NULL; PSI_file_locker_state state; if (likely(PSI_server && file->m_psi)) @@ -908,7 +933,7 @@ inline_mysql_file_fwrite( } #endif result= my_fwrite(file->m_file, buffer, count, flags); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE if (likely(locker != NULL)) { size_t bytes_written; @@ -924,13 +949,13 @@ inline_mysql_file_fwrite( static inline my_off_t inline_mysql_file_fseek( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE const char *src_file, uint src_line, #endif MYSQL_FILE *file, my_off_t pos, int whence, myf flags) { my_off_t result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE struct PSI_file_locker *locker= NULL; PSI_file_locker_state state; if (likely(PSI_server && file->m_psi)) @@ -942,7 +967,7 @@ inline_mysql_file_fseek( } #endif result= my_fseek(file->m_file, pos, whence, flags); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE if (likely(locker != NULL)) PSI_server->end_file_wait(locker, (size_t) 0); #endif @@ -951,13 +976,13 @@ inline_mysql_file_fseek( static inline my_off_t inline_mysql_file_ftell( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE const char *src_file, uint src_line, #endif MYSQL_FILE *file, myf flags) { my_off_t result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE struct PSI_file_locker *locker= NULL; PSI_file_locker_state state; if (likely(PSI_server && file->m_psi)) @@ -969,7 +994,7 @@ inline_mysql_file_ftell( } #endif result= my_ftell(file->m_file, flags); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE if (likely(locker != NULL)) PSI_server->end_file_wait(locker, (size_t) 0); #endif @@ -978,13 +1003,13 @@ inline_mysql_file_ftell( static inline File inline_mysql_file_create( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE PSI_file_key key, const char *src_file, uint src_line, #endif const char *filename, int create_flags, int access_flags, myf myFlags) { File file; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE struct PSI_file_locker *locker= NULL; PSI_file_locker_state state; if (likely(PSI_server != NULL)) @@ -996,7 +1021,7 @@ inline_mysql_file_create( } #endif file= my_create(filename, create_flags, access_flags, myFlags); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE if (likely(locker != NULL)) PSI_server->end_file_open_wait_and_bind_to_descriptor(locker, file); #endif @@ -1005,7 +1030,7 @@ inline_mysql_file_create( static inline File inline_mysql_file_create_temp( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE PSI_file_key key, #endif char *to, const char *dir, const char *pfx, int mode, myf myFlags) @@ -1017,7 +1042,7 @@ inline_mysql_file_create_temp( before the create_temp_file call. */ file= create_temp_file(to, dir, pfx, mode, myFlags); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE if (likely(PSI_server != NULL)) PSI_server->create_file(key, to, file); #endif @@ -1026,13 +1051,13 @@ inline_mysql_file_create_temp( static inline File inline_mysql_file_open( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE PSI_file_key key, const char *src_file, uint src_line, #endif const char *filename, int flags, myf myFlags) { File file; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE struct PSI_file_locker *locker= NULL; PSI_file_locker_state state; if (likely(PSI_server != NULL)) @@ -1044,7 +1069,7 @@ inline_mysql_file_open( } #endif file= my_open(filename, flags, myFlags); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE if (likely(locker != NULL)) PSI_server->end_file_open_wait_and_bind_to_descriptor(locker, file); #endif @@ -1053,13 +1078,13 @@ inline_mysql_file_open( static inline int inline_mysql_file_close( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE const char *src_file, uint src_line, #endif File file, myf flags) { int result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE struct PSI_file_locker *locker= NULL; PSI_file_locker_state state; if (likely(PSI_server != NULL)) @@ -1071,7 +1096,7 @@ inline_mysql_file_close( } #endif result= my_close(file, flags); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE if (likely(locker != NULL)) PSI_server->end_file_wait(locker, (size_t) 0); #endif @@ -1080,13 +1105,13 @@ inline_mysql_file_close( static inline size_t inline_mysql_file_read( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE const char *src_file, uint src_line, #endif File file, uchar *buffer, size_t count, myf flags) { size_t result= 0; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE struct PSI_file_locker *locker= NULL; PSI_file_locker_state state; if (likely(PSI_server != NULL)) @@ -1098,7 +1123,7 @@ inline_mysql_file_read( } #endif result= my_read(file, buffer, count, flags); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE if (likely(locker != NULL)) { size_t bytes_read; @@ -1114,13 +1139,13 @@ inline_mysql_file_read( static inline size_t inline_mysql_file_write( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE const char *src_file, uint src_line, #endif File file, const uchar *buffer, size_t count, myf flags) { size_t result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE struct PSI_file_locker *locker= NULL; PSI_file_locker_state state; if (likely(PSI_server != NULL)) @@ -1132,7 +1157,7 @@ inline_mysql_file_write( } #endif result= my_write(file, buffer, count, flags); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE if (likely(locker != NULL)) { size_t bytes_written; @@ -1148,13 +1173,13 @@ inline_mysql_file_write( static inline size_t inline_mysql_file_pread( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE const char *src_file, uint src_line, #endif File file, uchar *buffer, size_t count, my_off_t offset, myf flags) { size_t result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE struct PSI_file_locker *locker= NULL; PSI_file_locker_state state; if (likely(PSI_server != NULL)) @@ -1165,7 +1190,7 @@ inline_mysql_file_pread( } #endif result= my_pread(file, buffer, count, offset, flags); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE if (likely(locker != NULL)) { size_t bytes_read; @@ -1181,13 +1206,13 @@ inline_mysql_file_pread( static inline size_t inline_mysql_file_pwrite( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE const char *src_file, uint src_line, #endif File file, const uchar *buffer, size_t count, my_off_t offset, myf flags) { size_t result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE struct PSI_file_locker *locker= NULL; PSI_file_locker_state state; if (likely(PSI_server != NULL)) @@ -1199,7 +1224,7 @@ inline_mysql_file_pwrite( } #endif result= my_pwrite(file, buffer, count, offset, flags); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE if (likely(locker != NULL)) { size_t bytes_written; @@ -1215,13 +1240,13 @@ inline_mysql_file_pwrite( static inline my_off_t inline_mysql_file_seek( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE const char *src_file, uint src_line, #endif File file, my_off_t pos, int whence, myf flags) { my_off_t result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE struct PSI_file_locker *locker= NULL; PSI_file_locker_state state; if (likely(PSI_server != NULL)) @@ -1232,7 +1257,7 @@ inline_mysql_file_seek( } #endif result= my_seek(file, pos, whence, flags); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE if (likely(locker != NULL)) PSI_server->end_file_wait(locker, (size_t) 0); #endif @@ -1241,13 +1266,13 @@ inline_mysql_file_seek( static inline my_off_t inline_mysql_file_tell( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE const char *src_file, uint src_line, #endif File file, myf flags) { my_off_t result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE struct PSI_file_locker *locker= NULL; PSI_file_locker_state state; if (likely(PSI_server != NULL)) @@ -1258,7 +1283,7 @@ inline_mysql_file_tell( } #endif result= my_tell(file, flags); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE if (likely(locker != NULL)) PSI_server->end_file_wait(locker, (size_t) 0); #endif @@ -1267,13 +1292,13 @@ inline_mysql_file_tell( static inline int inline_mysql_file_delete( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE PSI_file_key key, const char *src_file, uint src_line, #endif const char *name, myf flags) { int result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE struct PSI_file_locker *locker= NULL; PSI_file_locker_state state; if (likely(PSI_server != NULL)) @@ -1285,7 +1310,7 @@ inline_mysql_file_delete( } #endif result= my_delete(name, flags); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE if (likely(locker != NULL)) PSI_server->end_file_wait(locker, (size_t) 0); #endif @@ -1294,13 +1319,13 @@ inline_mysql_file_delete( static inline int inline_mysql_file_rename( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE PSI_file_key key, const char *src_file, uint src_line, #endif const char *from, const char *to, myf flags) { int result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE struct PSI_file_locker *locker= NULL; PSI_file_locker_state state; if (likely(PSI_server != NULL)) @@ -1312,7 +1337,7 @@ inline_mysql_file_rename( } #endif result= my_rename(from, to, flags); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE if (likely(locker != NULL)) PSI_server->end_file_wait(locker, (size_t) 0); #endif @@ -1321,14 +1346,14 @@ inline_mysql_file_rename( static inline File inline_mysql_file_create_with_symlink( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE PSI_file_key key, const char *src_file, uint src_line, #endif const char *linkname, const char *filename, int create_flags, int access_flags, myf flags) { File file; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE struct PSI_file_locker *locker= NULL; PSI_file_locker_state state; if (likely(PSI_server != NULL)) @@ -1341,7 +1366,7 @@ inline_mysql_file_create_with_symlink( #endif file= my_create_with_symlink(linkname, filename, create_flags, access_flags, flags); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE if (likely(locker != NULL)) PSI_server->end_file_open_wait_and_bind_to_descriptor(locker, file); #endif @@ -1350,13 +1375,13 @@ inline_mysql_file_create_with_symlink( static inline int inline_mysql_file_delete_with_symlink( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE PSI_file_key key, const char *src_file, uint src_line, #endif const char *name, myf flags) { int result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE struct PSI_file_locker *locker= NULL; PSI_file_locker_state state; if (likely(PSI_server != NULL)) @@ -1368,7 +1393,7 @@ inline_mysql_file_delete_with_symlink( } #endif result= my_delete_with_symlink(name, flags); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE if (likely(locker != NULL)) PSI_server->end_file_wait(locker, (size_t) 0); #endif @@ -1377,13 +1402,13 @@ inline_mysql_file_delete_with_symlink( static inline int inline_mysql_file_rename_with_symlink( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE PSI_file_key key, const char *src_file, uint src_line, #endif const char *from, const char *to, myf flags) { int result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE struct PSI_file_locker *locker= NULL; PSI_file_locker_state state; if (likely(PSI_server != NULL)) @@ -1395,7 +1420,7 @@ inline_mysql_file_rename_with_symlink( } #endif result= my_rename_with_symlink(from, to, flags); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE if (likely(locker != NULL)) PSI_server->end_file_wait(locker, (size_t) 0); #endif @@ -1404,13 +1429,13 @@ inline_mysql_file_rename_with_symlink( static inline int inline_mysql_file_sync( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE const char *src_file, uint src_line, #endif File fd, myf flags) { int result= 0; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE struct PSI_file_locker *locker= NULL; PSI_file_locker_state state; if (likely(PSI_server != NULL)) @@ -1421,7 +1446,7 @@ inline_mysql_file_sync( } #endif result= my_sync(fd, flags); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_FILE_INTERFACE if (likely(locker != NULL)) PSI_server->end_file_wait(locker, (size_t) 0); #endif diff --git a/include/mysql/psi/mysql_stage.h b/include/mysql/psi/mysql_stage.h index 5a1012360a6..d6eb0e95524 100644 --- a/include/mysql/psi/mysql_stage.h +++ b/include/mysql/psi/mysql_stage.h @@ -29,7 +29,19 @@ @{ */ -#ifdef HAVE_PSI_INTERFACE +/** + @def mysql_stage_register(P1, P2, P3) + Stage registration. +*/ +#ifdef HAVE_PSI_STAGE_INTERFACE +#define mysql_stage_register(P1, P2, P3) \ + inline_mysql_stage_register(P1, P2, P3) +#else +#define mysql_stage_register(P1, P2, P3) \ + do {} while (0) +#endif + +#ifdef HAVE_PSI_STAGE_INTERFACE #define MYSQL_SET_STAGE(K, F, L) \ inline_mysql_set_stage(K, F, L) #else @@ -37,7 +49,16 @@ do {} while (0) #endif -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_STAGE_INTERFACE +static inline void inline_mysql_stage_register( + const char *category, PSI_stage_info **info, int count) +{ + if (likely(PSI_server != NULL)) + PSI_server->register_stage(category, info, count); +} +#endif + +#ifdef HAVE_PSI_STAGE_INTERFACE static inline void inline_mysql_set_stage(PSI_stage_key key, const char *src_file, int src_line) diff --git a/include/mysql/psi/mysql_statement.h b/include/mysql/psi/mysql_statement.h index 1672b59856f..7fcab8758b4 100644 --- a/include/mysql/psi/mysql_statement.h +++ b/include/mysql/psi/mysql_statement.h @@ -29,7 +29,19 @@ @{ */ -#ifdef HAVE_PSI_INTERFACE +/** + @def mysql_statement_register(P1, P2, P3) + Statement registration. +*/ +#ifdef HAVE_PSI_STATEMENT_INTERFACE +#define mysql_statement_register(P1, P2, P3) \ + inline_mysql_statement_register(P1, P2, P3) +#else +#define mysql_statement_register(P1, P2, P3) \ + do {} while (0) +#endif + +#ifdef HAVE_PSI_STATEMENT_INTERFACE #define MYSQL_START_STATEMENT(STATE, K, DB, DB_LEN) \ inline_mysql_start_statement(STATE, K, DB, DB_LEN, __FILE__, __LINE__) #else @@ -37,7 +49,7 @@ NULL #endif -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_STATEMENT_INTERFACE #define MYSQL_REFINE_STATEMENT(LOCKER, K) \ inline_mysql_refine_statement(LOCKER, K) #else @@ -45,7 +57,7 @@ NULL #endif -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_STATEMENT_INTERFACE #define MYSQL_SET_STATEMENT_TEXT(LOCKER, P1, P2) \ inline_mysql_set_statement_text(LOCKER, P1, P2) #else @@ -53,7 +65,7 @@ do {} while (0) #endif -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_STATEMENT_INTERFACE #define MYSQL_SET_STATEMENT_LOCK_TIME(LOCKER, P1) \ inline_mysql_set_statement_lock_time(LOCKER, P1) #else @@ -61,7 +73,7 @@ do {} while (0) #endif -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_STATEMENT_INTERFACE #define MYSQL_SET_STATEMENT_ROWS_SENT(LOCKER, P1) \ inline_mysql_set_statement_rows_sent(LOCKER, P1) #else @@ -69,7 +81,7 @@ do {} while (0) #endif -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_STATEMENT_INTERFACE #define MYSQL_SET_STATEMENT_ROWS_EXAMINED(LOCKER, P1) \ inline_mysql_set_statement_rows_examined(LOCKER, P1) #else @@ -77,7 +89,7 @@ do {} while (0) #endif -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_STATEMENT_INTERFACE #define MYSQL_END_STATEMENT(LOCKER, DA) \ inline_mysql_end_statement(LOCKER, DA) #else @@ -85,7 +97,14 @@ do {} while (0) #endif -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_STATEMENT_INTERFACE +static inline void inline_mysql_statement_register( + const char *category, PSI_statement_info *info, int count) +{ + if (likely(PSI_server != NULL)) + PSI_server->register_statement(category, info, count); +} + static inline struct PSI_statement_locker * inline_mysql_start_statement(PSI_statement_locker_state *state, PSI_statement_key key, diff --git a/include/mysql/psi/mysql_table.h b/include/mysql/psi/mysql_table.h index 41e5c86017e..e816fff11d6 100644 --- a/include/mysql/psi/mysql_table.h +++ b/include/mysql/psi/mysql_table.h @@ -41,7 +41,7 @@ @sa MYSQL_START_TABLE_LOCK_WAIT. @sa MYSQL_END_TABLE_LOCK_WAIT. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_TABLE_INTERFACE #define MYSQL_TABLE_WAIT_VARIABLES(LOCKER, STATE) \ struct PSI_table_locker* LOCKER; \ PSI_table_locker_state STATE; @@ -61,7 +61,7 @@ @param FLAGS per table operation flags. @sa MYSQL_END_TABLE_WAIT. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_TABLE_INTERFACE #define MYSQL_START_TABLE_IO_WAIT(LOCKER, STATE, PSI, OP, INDEX, FLAGS) \ LOCKER= inline_mysql_start_table_io_wait(STATE, PSI, \ OP, INDEX, __FILE__, __LINE__) @@ -77,7 +77,7 @@ @param LOCKER the locker @sa MYSQL_START_TABLE_IO_WAIT. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_TABLE_INTERFACE #define MYSQL_END_TABLE_IO_WAIT(LOCKER) \ inline_mysql_end_table_io_wait(LOCKER) #else @@ -85,7 +85,7 @@ do {} while (0) #endif -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_TABLE_INTERFACE /** Instrumentation calls for MYSQL_START_TABLE_IO_WAIT. @sa MYSQL_END_TABLE_IO_WAIT. @@ -130,7 +130,7 @@ inline_mysql_end_table_io_wait(struct PSI_table_locker *locker) @param FLAGS per table operation flags. @sa MYSQL_END_TABLE_LOCK_WAIT. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_TABLE_INTERFACE #define MYSQL_START_TABLE_LOCK_WAIT(LOCKER, STATE, PSI, OP, FLAGS) \ LOCKER= inline_mysql_start_table_lock_wait(STATE, PSI, \ OP, FLAGS, __FILE__, __LINE__) @@ -146,7 +146,7 @@ inline_mysql_end_table_io_wait(struct PSI_table_locker *locker) @param LOCKER the locker @sa MYSQL_START_TABLE_LOCK_WAIT. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_TABLE_INTERFACE #define MYSQL_END_TABLE_LOCK_WAIT(LOCKER) \ inline_mysql_end_table_lock_wait(LOCKER) #else @@ -154,7 +154,7 @@ inline_mysql_end_table_io_wait(struct PSI_table_locker *locker) do {} while (0) #endif -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_TABLE_INTERFACE /** Instrumentation calls for MYSQL_START_TABLE_LOCK_WAIT. @sa MYSQL_END_TABLE_LOCK_WAIT. diff --git a/include/mysql/psi/mysql_thread.h b/include/mysql/psi/mysql_thread.h index 5b8ea3dc5dc..85d0f9a2c2f 100644 --- a/include/mysql/psi/mysql_thread.h +++ b/include/mysql/psi/mysql_thread.h @@ -221,6 +221,13 @@ typedef struct st_mysql_cond mysql_cond_t; #define mysql_prlock_assert_not_write_owner(M) \ rw_pr_lock_assert_not_write_owner(&(M)->m_prlock) +/** + @def mysql_mutex_register(P1, P2, P3) + Mutex registration. +*/ +#define mysql_mutex_register(P1, P2, P3) \ + inline_mysql_mutex_register(P1, P2, P3) + /** @def mysql_mutex_init(K, M, A) Instrumented mutex_init. @@ -230,7 +237,7 @@ typedef struct st_mysql_cond mysql_cond_t; @param A Mutex attributes */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_MUTEX_INTERFACE #ifdef SAFE_MUTEX #define mysql_mutex_init(K, M, A) \ inline_mysql_mutex_init(K, M, A, __FILE__, __LINE__) @@ -269,7 +276,7 @@ typedef struct st_mysql_cond mysql_cond_t; @param M The mutex to lock */ -#if defined(SAFE_MUTEX) || defined (HAVE_PSI_INTERFACE) +#if defined(SAFE_MUTEX) || defined (HAVE_PSI_MUTEX_INTERFACE) #define mysql_mutex_lock(M) \ inline_mysql_mutex_lock(M, __FILE__, __LINE__) #else @@ -284,7 +291,7 @@ typedef struct st_mysql_cond mysql_cond_t; for @c pthread_mutex_trylock. */ -#if defined(SAFE_MUTEX) || defined (HAVE_PSI_INTERFACE) +#if defined(SAFE_MUTEX) || defined (HAVE_PSI_MUTEX_INTERFACE) #define mysql_mutex_trylock(M) \ inline_mysql_mutex_trylock(M, __FILE__, __LINE__) #else @@ -305,6 +312,13 @@ typedef struct st_mysql_cond mysql_cond_t; inline_mysql_mutex_unlock(M) #endif +/** + @def mysql_rwlock_register(P1, P2, P3) + Rwlock registration. +*/ +#define mysql_rwlock_register(P1, P2, P3) \ + inline_mysql_rwlock_register(P1, P2, P3) + /** @def mysql_rwlock_init(K, RW) Instrumented rwlock_init. @@ -313,7 +327,7 @@ typedef struct st_mysql_cond mysql_cond_t; @param K The PSI_rwlock_key for this instrumented rwlock @param RW The rwlock to initialize */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE #define mysql_rwlock_init(K, RW) inline_mysql_rwlock_init(K, RW) #else #define mysql_rwlock_init(K, RW) inline_mysql_rwlock_init(RW) @@ -326,7 +340,7 @@ typedef struct st_mysql_cond mysql_cond_t; @param K The PSI_rwlock_key for this instrumented prlock @param RW The prlock to initialize */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE #define mysql_prlock_init(K, RW) inline_mysql_prlock_init(K, RW) #else #define mysql_prlock_init(K, RW) inline_mysql_prlock_init(RW) @@ -354,7 +368,7 @@ typedef struct st_mysql_cond mysql_cond_t; @c mysql_rwlock_rdlock is a drop-in replacement for @c pthread_rwlock_rdlock. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE #define mysql_rwlock_rdlock(RW) \ inline_mysql_rwlock_rdlock(RW, __FILE__, __LINE__) #else @@ -368,7 +382,7 @@ typedef struct st_mysql_cond mysql_cond_t; @c mysql_prlock_rdlock is a drop-in replacement for @c rw_pr_rdlock. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE #define mysql_prlock_rdlock(RW) \ inline_mysql_prlock_rdlock(RW, __FILE__, __LINE__) #else @@ -382,7 +396,7 @@ typedef struct st_mysql_cond mysql_cond_t; @c mysql_rwlock_wrlock is a drop-in replacement for @c pthread_rwlock_wrlock. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE #define mysql_rwlock_wrlock(RW) \ inline_mysql_rwlock_wrlock(RW, __FILE__, __LINE__) #else @@ -396,7 +410,7 @@ typedef struct st_mysql_cond mysql_cond_t; @c mysql_prlock_wrlock is a drop-in replacement for @c rw_pr_wrlock. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE #define mysql_prlock_wrlock(RW) \ inline_mysql_prlock_wrlock(RW, __FILE__, __LINE__) #else @@ -410,7 +424,7 @@ typedef struct st_mysql_cond mysql_cond_t; @c mysql_rwlock_tryrdlock is a drop-in replacement for @c pthread_rwlock_tryrdlock. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE #define mysql_rwlock_tryrdlock(RW) \ inline_mysql_rwlock_tryrdlock(RW, __FILE__, __LINE__) #else @@ -424,7 +438,7 @@ typedef struct st_mysql_cond mysql_cond_t; @c mysql_rwlock_trywrlock is a drop-in replacement for @c pthread_rwlock_trywrlock. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE #define mysql_rwlock_trywrlock(RW) \ inline_mysql_rwlock_trywrlock(RW, __FILE__, __LINE__) #else @@ -448,6 +462,13 @@ typedef struct st_mysql_cond mysql_cond_t; */ #define mysql_prlock_unlock(RW) inline_mysql_prlock_unlock(RW) +/** + @def mysql_cond_register(P1, P2, P3) + Cond registration. +*/ +#define mysql_cond_register(P1, P2, P3) \ + inline_mysql_cond_register(P1, P2, P3) + /** @def mysql_cond_init(K, C, A) Instrumented cond_init. @@ -456,7 +477,7 @@ typedef struct st_mysql_cond mysql_cond_t; @param K The PSI_cond_key for this instrumented cond @param A Condition attributes */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_COND_INTERFACE #define mysql_cond_init(K, C, A) inline_mysql_cond_init(K, C, A) #else #define mysql_cond_init(K, C, A) inline_mysql_cond_init(C, A) @@ -474,7 +495,7 @@ typedef struct st_mysql_cond mysql_cond_t; Instrumented cond_wait. @c mysql_cond_wait is a drop-in replacement for @c pthread_cond_wait. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_COND_INTERFACE #define mysql_cond_wait(C, M) \ inline_mysql_cond_wait(C, M, __FILE__, __LINE__) #else @@ -488,7 +509,7 @@ typedef struct st_mysql_cond mysql_cond_t; @c mysql_cond_timedwait is a drop-in replacement for @c pthread_cond_timedwait. */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_COND_INTERFACE #define mysql_cond_timedwait(C, M, W) \ inline_mysql_cond_timedwait(C, M, W, __FILE__, __LINE__) #else @@ -511,6 +532,12 @@ typedef struct st_mysql_cond mysql_cond_t; */ #define mysql_cond_broadcast(C) inline_mysql_cond_broadcast(C) +/** + @def mysql_thread_register(P1, P2, P3) + Thread registration. +*/ +#define mysql_thread_register(P1, P2, P3) \ + inline_mysql_thread_register(P1, P2, P3) /** @def mysql_thread_create(K, P1, P2, P3, P4) @@ -529,7 +556,7 @@ typedef struct st_mysql_cond mysql_cond_t; @param P3 pthread_create parameter 3 @param P4 pthread_create parameter 4 */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_THREAD_INTERFACE #define mysql_thread_create(K, P1, P2, P3, P4) \ inline_mysql_thread_create(K, P1, P2, P3, P4) #else @@ -542,14 +569,32 @@ typedef struct st_mysql_cond mysql_cond_t; Set the thread indentifier for the instrumentation. @param I The thread identifier */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_THREAD_INTERFACE #define mysql_thread_set_psi_id(I) inline_mysql_thread_set_psi_id(I) #else #define mysql_thread_set_psi_id(I) do {} while (0) #endif +static inline void inline_mysql_mutex_register( +#ifdef HAVE_PSI_MUTEX_INTERFACE + const char *category, + PSI_mutex_info *info, + int count +#else + const char *category __attribute__ ((unused)), + PSI_mutex_info *info __attribute__ ((unused)), + int count __attribute__ ((unused)) +#endif +) +{ +#ifdef HAVE_PSI_MUTEX_INTERFACE + if (likely(PSI_server != NULL)) + PSI_server->register_mutex(category, info, count); +#endif +} + static inline int inline_mysql_mutex_init( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_MUTEX_INTERFACE PSI_mutex_key key, #endif mysql_mutex_t *that, @@ -559,7 +604,7 @@ static inline int inline_mysql_mutex_init( #endif ) { -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_MUTEX_INTERFACE that->m_psi= PSI_server ? PSI_server->init_mutex(key, &that->m_mutex) : NULL; #else @@ -579,7 +624,7 @@ static inline int inline_mysql_mutex_destroy( #endif ) { -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_MUTEX_INTERFACE if (likely(PSI_server && that->m_psi)) { PSI_server->destroy_mutex(that->m_psi); @@ -595,13 +640,13 @@ static inline int inline_mysql_mutex_destroy( static inline int inline_mysql_mutex_lock( mysql_mutex_t *that -#if defined(SAFE_MUTEX) || defined (HAVE_PSI_INTERFACE) +#if defined(SAFE_MUTEX) || defined (HAVE_PSI_MUTEX_INTERFACE) , const char *src_file, uint src_line #endif ) { int result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_MUTEX_INTERFACE struct PSI_mutex_locker *locker= NULL; PSI_mutex_locker_state state; if (likely(PSI_server && that->m_psi)) @@ -616,7 +661,7 @@ static inline int inline_mysql_mutex_lock( #else result= pthread_mutex_lock(&that->m_mutex); #endif -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_MUTEX_INTERFACE if (likely(locker != NULL)) PSI_server->end_mutex_wait(locker, result); #endif @@ -625,13 +670,13 @@ static inline int inline_mysql_mutex_lock( static inline int inline_mysql_mutex_trylock( mysql_mutex_t *that -#if defined(SAFE_MUTEX) || defined (HAVE_PSI_INTERFACE) +#if defined(SAFE_MUTEX) || defined (HAVE_PSI_MUTEX_INTERFACE) , const char *src_file, uint src_line #endif ) { int result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_MUTEX_INTERFACE struct PSI_mutex_locker *locker= NULL; PSI_mutex_locker_state state; if (likely(PSI_server && that->m_psi)) @@ -646,7 +691,7 @@ static inline int inline_mysql_mutex_trylock( #else result= pthread_mutex_trylock(&that->m_mutex); #endif -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_MUTEX_INTERFACE if (likely(locker != NULL)) PSI_server->end_mutex_wait(locker, result); #endif @@ -661,7 +706,7 @@ static inline int inline_mysql_mutex_unlock( ) { int result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_MUTEX_INTERFACE if (likely(PSI_server && that->m_psi)) PSI_server->unlock_mutex(that->m_psi); #endif @@ -673,13 +718,31 @@ static inline int inline_mysql_mutex_unlock( return result; } +static inline void inline_mysql_rwlock_register( +#ifdef HAVE_PSI_RWLOCK_INTERFACE + const char *category, + PSI_rwlock_info *info, + int count +#else + const char *category __attribute__ ((unused)), + PSI_rwlock_info *info __attribute__ ((unused)), + int count __attribute__ ((unused)) +#endif +) +{ +#ifdef HAVE_PSI_RWLOCK_INTERFACE + if (likely(PSI_server != NULL)) + PSI_server->register_rwlock(category, info, count); +#endif +} + static inline int inline_mysql_rwlock_init( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE PSI_rwlock_key key, #endif mysql_rwlock_t *that) { -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE that->m_psi= (PSI_server ? PSI_server->init_rwlock(key, &that->m_rwlock) : NULL); #else @@ -693,12 +756,12 @@ static inline int inline_mysql_rwlock_init( #ifndef DISABLE_MYSQL_PRLOCK_H static inline int inline_mysql_prlock_init( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE PSI_rwlock_key key, #endif mysql_prlock_t *that) { -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE that->m_psi= (PSI_server ? PSI_server->init_rwlock(key, &that->m_prlock) : NULL); #else @@ -711,7 +774,7 @@ static inline int inline_mysql_prlock_init( static inline int inline_mysql_rwlock_destroy( mysql_rwlock_t *that) { -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE if (likely(PSI_server && that->m_psi)) { PSI_server->destroy_rwlock(that->m_psi); @@ -725,7 +788,7 @@ static inline int inline_mysql_rwlock_destroy( static inline int inline_mysql_prlock_destroy( mysql_prlock_t *that) { -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE if (likely(PSI_server && that->m_psi)) { PSI_server->destroy_rwlock(that->m_psi); @@ -738,13 +801,13 @@ static inline int inline_mysql_prlock_destroy( static inline int inline_mysql_rwlock_rdlock( mysql_rwlock_t *that -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE , const char *src_file, uint src_line #endif ) { int result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE struct PSI_rwlock_locker *locker= NULL; PSI_rwlock_locker_state state; if (likely(PSI_server && that->m_psi)) @@ -756,7 +819,7 @@ static inline int inline_mysql_rwlock_rdlock( } #endif result= rw_rdlock(&that->m_rwlock); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE if (likely(locker != NULL)) PSI_server->end_rwlock_rdwait(locker, result); #endif @@ -766,13 +829,13 @@ static inline int inline_mysql_rwlock_rdlock( #ifndef DISABLE_MYSQL_PRLOCK_H static inline int inline_mysql_prlock_rdlock( mysql_prlock_t *that -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE , const char *src_file, uint src_line #endif ) { int result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE struct PSI_rwlock_locker *locker= NULL; PSI_rwlock_locker_state state; if (likely(PSI_server && that->m_psi)) @@ -784,7 +847,7 @@ static inline int inline_mysql_prlock_rdlock( } #endif result= rw_pr_rdlock(&that->m_prlock); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE if (likely(locker != NULL)) PSI_server->end_rwlock_rdwait(locker, result); #endif @@ -794,13 +857,13 @@ static inline int inline_mysql_prlock_rdlock( static inline int inline_mysql_rwlock_wrlock( mysql_rwlock_t *that -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE , const char *src_file, uint src_line #endif ) { int result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE struct PSI_rwlock_locker *locker= NULL; PSI_rwlock_locker_state state; if (likely(PSI_server && that->m_psi)) @@ -812,7 +875,7 @@ static inline int inline_mysql_rwlock_wrlock( } #endif result= rw_wrlock(&that->m_rwlock); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE if (likely(locker != NULL)) PSI_server->end_rwlock_wrwait(locker, result); #endif @@ -822,13 +885,13 @@ static inline int inline_mysql_rwlock_wrlock( #ifndef DISABLE_MYSQL_PRLOCK_H static inline int inline_mysql_prlock_wrlock( mysql_prlock_t *that -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE , const char *src_file, uint src_line #endif ) { int result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE struct PSI_rwlock_locker *locker= NULL; PSI_rwlock_locker_state state; if (likely(PSI_server && that->m_psi)) @@ -840,7 +903,7 @@ static inline int inline_mysql_prlock_wrlock( } #endif result= rw_pr_wrlock(&that->m_prlock); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE if (likely(locker != NULL)) PSI_server->end_rwlock_wrwait(locker, result); #endif @@ -850,13 +913,13 @@ static inline int inline_mysql_prlock_wrlock( static inline int inline_mysql_rwlock_tryrdlock( mysql_rwlock_t *that -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE , const char *src_file, uint src_line #endif ) { int result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE struct PSI_rwlock_locker *locker= NULL; PSI_rwlock_locker_state state; if (likely(PSI_server && that->m_psi)) @@ -868,7 +931,7 @@ static inline int inline_mysql_rwlock_tryrdlock( } #endif result= rw_tryrdlock(&that->m_rwlock); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE if (likely(locker != NULL)) PSI_server->end_rwlock_rdwait(locker, result); #endif @@ -877,13 +940,13 @@ static inline int inline_mysql_rwlock_tryrdlock( static inline int inline_mysql_rwlock_trywrlock( mysql_rwlock_t *that -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE , const char *src_file, uint src_line #endif ) { int result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE struct PSI_rwlock_locker *locker= NULL; PSI_rwlock_locker_state state; if (likely(PSI_server && that->m_psi)) @@ -895,7 +958,7 @@ static inline int inline_mysql_rwlock_trywrlock( } #endif result= rw_trywrlock(&that->m_rwlock); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE if (likely(locker != NULL)) PSI_server->end_rwlock_wrwait(locker, result); #endif @@ -906,7 +969,7 @@ static inline int inline_mysql_rwlock_unlock( mysql_rwlock_t *that) { int result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE if (likely(PSI_server && that->m_psi)) PSI_server->unlock_rwlock(that->m_psi); #endif @@ -919,7 +982,7 @@ static inline int inline_mysql_prlock_unlock( mysql_prlock_t *that) { int result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_RWLOCK_INTERFACE if (likely(PSI_server && that->m_psi)) PSI_server->unlock_rwlock(that->m_psi); #endif @@ -928,14 +991,32 @@ static inline int inline_mysql_prlock_unlock( } #endif +static inline void inline_mysql_cond_register( +#ifdef HAVE_PSI_COND_INTERFACE + const char *category, + PSI_cond_info *info, + int count +#else + const char *category __attribute__ ((unused)), + PSI_cond_info *info __attribute__ ((unused)), + int count __attribute__ ((unused)) +#endif +) +{ +#ifdef HAVE_PSI_COND_INTERFACE + if (likely(PSI_server != NULL)) + PSI_server->register_cond(category, info, count); +#endif +} + static inline int inline_mysql_cond_init( -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_COND_INTERFACE PSI_cond_key key, #endif mysql_cond_t *that, const pthread_condattr_t *attr) { -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_COND_INTERFACE that->m_psi= (PSI_server ? PSI_server->init_cond(key, &that->m_cond) : NULL); #else @@ -947,7 +1028,7 @@ static inline int inline_mysql_cond_init( static inline int inline_mysql_cond_destroy( mysql_cond_t *that) { -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_COND_INTERFACE if (likely(PSI_server && that->m_psi)) { PSI_server->destroy_cond(that->m_psi); @@ -960,13 +1041,13 @@ static inline int inline_mysql_cond_destroy( static inline int inline_mysql_cond_wait( mysql_cond_t *that, mysql_mutex_t *mutex -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_COND_INTERFACE , const char *src_file, uint src_line #endif ) { int result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_COND_INTERFACE struct PSI_cond_locker *locker= NULL; PSI_cond_locker_state state; if (likely(PSI_server && that->m_psi)) @@ -978,7 +1059,7 @@ static inline int inline_mysql_cond_wait( } #endif result= pthread_cond_wait(&that->m_cond, &mutex->m_mutex); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_COND_INTERFACE if (likely(locker != NULL)) PSI_server->end_cond_wait(locker, result); #endif @@ -989,13 +1070,13 @@ static inline int inline_mysql_cond_timedwait( mysql_cond_t *that, mysql_mutex_t *mutex, struct timespec *abstime -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_COND_INTERFACE , const char *src_file, uint src_line #endif ) { int result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_COND_INTERFACE struct PSI_cond_locker *locker= NULL; PSI_cond_locker_state state; if (likely(PSI_server && that->m_psi)) @@ -1007,7 +1088,7 @@ static inline int inline_mysql_cond_timedwait( } #endif result= pthread_cond_timedwait(&that->m_cond, &mutex->m_mutex, abstime); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_COND_INTERFACE if (likely(locker != NULL)) PSI_server->end_cond_wait(locker, result); #endif @@ -1018,7 +1099,7 @@ static inline int inline_mysql_cond_signal( mysql_cond_t *that) { int result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_COND_INTERFACE if (likely(PSI_server && that->m_psi)) PSI_server->signal_cond(that->m_psi); #endif @@ -1030,7 +1111,7 @@ static inline int inline_mysql_cond_broadcast( mysql_cond_t *that) { int result; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_COND_INTERFACE if (likely(PSI_server && that->m_psi)) PSI_server->broadcast_cond(that->m_psi); #endif @@ -1038,7 +1119,25 @@ static inline int inline_mysql_cond_broadcast( return result; } -#ifdef HAVE_PSI_INTERFACE +static inline void inline_mysql_thread_register( +#ifdef HAVE_PSI_THREAD__INTERFACE + const char *category, + PSI_thread_info *info, + int count +#else + const char *category __attribute__ ((unused)), + PSI_thread_info *info __attribute__ ((unused)), + int count __attribute__ ((unused)) +#endif +) +{ +#ifdef HAVE_PSI_THREAD_INTERFACE + if (likely(PSI_server != NULL)) + PSI_server->register_thread(category, info, count); +#endif +} + +#ifdef HAVE_PSI_THREAD_INTERFACE static inline int inline_mysql_thread_create( PSI_thread_key key, pthread_t *thread, const pthread_attr_t *attr, diff --git a/include/mysql/psi/psi.h b/include/mysql/psi/psi.h index bd7559586b6..5f7a1a14678 100644 --- a/include/mysql/psi/psi.h +++ b/include/mysql/psi/psi.h @@ -115,6 +115,90 @@ struct PSI_bootstrap #ifdef HAVE_PSI_INTERFACE +/** + @def DISABLE_PSI_MUTEX + Compiling option to disable the mutex instrumentation. + This option is mostly intended to be used during development, + when doing special builds with only a subset of the performance schema instrumentation, + for code analysis / profiling / performance tuning of a specific instrumentation alone. + For this reason, DISABLE_PSI_MUTEX is not advertised in the cmake general options. + To disable mutexes, add -DDISABLE_PSI_MUTEX to CFLAGS. + @sa DISABLE_PSI_RWLOCK + @sa DISABLE_PSI_COND + @sa DISABLE_PSI_FILE + @sa DISABLE_PSI_TABLE + @sa DISABLE_PSI_STAGE + @sa DISABLE_PSI_STATEMENT +*/ + +#ifndef DISABLE_PSI_MUTEX +#define HAVE_PSI_MUTEX_INTERFACE +#endif + +/** + @def DISABLE_PSI_RWLOCK + Compiling option to disable the rwlock instrumentation. + @sa DISABLE_PSI_MUTEX +*/ + +#ifndef DISABLE_PSI_RWLOCK +#define HAVE_PSI_RWLOCK_INTERFACE +#endif + +/** + @def DISABLE_PSI_COND + Compiling option to disable the cond instrumentation. + @sa DISABLE_PSI_MUTEX +*/ + +#ifndef DISABLE_PSI_COND +#define HAVE_PSI_COND_INTERFACE +#endif + +/** + @def DISABLE_PSI_FILE + Compiling option to disable the file instrumentation. + @sa DISABLE_PSI_MUTEX +*/ + +#ifndef DISABLE_PSI_FILE +#define HAVE_PSI_FILE_INTERFACE +#endif + +/* No flag to disable the thread instrumentation. */ + +#define HAVE_PSI_THREAD_INTERFACE + +/** + @def DISABLE_PSI_TABLE + Compiling option to disable the table instrumentation. + @sa DISABLE_PSI_MUTEX +*/ + +#ifndef DISABLE_PSI_TABLE +#define HAVE_PSI_TABLE_INTERFACE +#endif + +/** + @def DISABLE_PSI_STAGE + Compiling option to disable the stage instrumentation. + @sa DISABLE_PSI_MUTEX +*/ + +#ifndef DISABLE_PSI_STAGE +#define HAVE_PSI_STAGE_INTERFACE +#endif + +/** + @def DISABLE_PSI_STATEMENT + Compiling option to disable the statement instrumentation. + @sa DISABLE_PSI_MUTEX +*/ + +#ifndef DISABLE_PSI_STATEMENT +#define HAVE_PSI_STATEMENT_INTERFACE +#endif + /** @def PSI_VERSION_1 Performance Schema Interface number for version 1. diff --git a/mysys/my_init.c b/mysys/my_init.c index 2f1e79a8747..20813a9e906 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -543,22 +543,19 @@ void my_init_mysys_psi_keys() const char* category= "mysys"; int count; - if (PSI_server == NULL) - return; - count= sizeof(all_mysys_mutexes)/sizeof(all_mysys_mutexes[0]); - PSI_server->register_mutex(category, all_mysys_mutexes, count); + mysql_mutex_register(category, all_mysys_mutexes, count); count= sizeof(all_mysys_conds)/sizeof(all_mysys_conds[0]); - PSI_server->register_cond(category, all_mysys_conds, count); + mysql_cond_register(category, all_mysys_conds, count); #ifdef USE_ALARM_THREAD count= sizeof(all_mysys_threads)/sizeof(all_mysys_threads[0]); - PSI_server->register_thread(category, all_mysys_threads, count); + mysql_thread_register(category, all_mysys_threads, count); #endif /* USE_ALARM_THREAD */ count= sizeof(all_mysys_files)/sizeof(all_mysys_files[0]); - PSI_server->register_file(category, all_mysys_files, count); + mysql_file_register(category, all_mysys_files, count); } #endif /* HAVE_PSI_INTERFACE */ diff --git a/plugin/semisync/semisync_master_plugin.cc b/plugin/semisync/semisync_master_plugin.cc index a55ba184a17..4b90d7c37c8 100644 --- a/plugin/semisync/semisync_master_plugin.cc +++ b/plugin/semisync/semisync_master_plugin.cc @@ -359,14 +359,11 @@ static void init_semisync_psi_keys(void) const char* category= "semisync"; int count; - if (PSI_server == NULL) - return; - count= array_elements(all_semisync_mutexes); - PSI_server->register_mutex(category, all_semisync_mutexes, count); + mysql_mutex_register(category, all_semisync_mutexes, count); count= array_elements(all_semisync_conds); - PSI_server->register_cond(category, all_semisync_conds, count); + mysql_cond_register(category, all_semisync_conds, count); } #endif /* HAVE_PSI_INTERFACE */ diff --git a/sql/debug_sync.cc b/sql/debug_sync.cc index 4803c500d96..e0b311f1d54 100644 --- a/sql/debug_sync.cc +++ b/sql/debug_sync.cc @@ -453,14 +453,11 @@ static void init_debug_sync_psi_keys(void) const char* category= "sql"; int count; - if (PSI_server == NULL) - return; - count= array_elements(all_debug_sync_mutexes); - PSI_server->register_mutex(category, all_debug_sync_mutexes, count); + mysql_mutex_register(category, all_debug_sync_mutexes, count); count= array_elements(all_debug_sync_conds); - PSI_server->register_cond(category, all_debug_sync_conds, count); + mysql_cond_register(category, all_debug_sync_conds, count); } #endif /* HAVE_PSI_INTERFACE */ diff --git a/sql/events.cc b/sql/events.cc index 6ea79f7ad52..d0da2ba0cf9 100644 --- a/sql/events.cc +++ b/sql/events.cc @@ -945,17 +945,14 @@ static void init_events_psi_keys(void) const char* category= "sql"; int count; - if (PSI_server == NULL) - return; - count= array_elements(all_events_mutexes); - PSI_server->register_mutex(category, all_events_mutexes, count); + mysql_mutex_register(category, all_events_mutexes, count); count= array_elements(all_events_conds); - PSI_server->register_cond(category, all_events_conds, count); + mysql_cond_register(category, all_events_conds, count); count= array_elements(all_events_threads); - PSI_server->register_thread(category, all_events_threads, count); + mysql_thread_register(category, all_events_threads, count); } #endif /* HAVE_PSI_INTERFACE */ diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 6433e30d6ff..43db1e7985d 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -7532,20 +7532,17 @@ void init_ndbcluster_psi_keys() const char* category= "ndbcluster"; int count; - if (PSI_server == NULL) - return; - count= array_elements(all_ndbcluster_mutexes); - PSI_server->register_mutex(category, all_ndbcluster_mutexes, count); + mysql_mutex_register(category, all_ndbcluster_mutexes, count); count= array_elements(all_ndbcluster_conds); - PSI_server->register_cond(category, all_ndbcluster_conds, count); + mysql_cond_register(category, all_ndbcluster_conds, count); count= array_elements(all_ndbcluster_threads); - PSI_server->register_thread(category, all_ndbcluster_threads, count); + mysql_thread_register(category, all_ndbcluster_threads, count); count= array_elements(all_ndbcluster_files); - PSI_server->register_file(category, all_ndbcluster_files, count); + mysql_file_register(category, all_ndbcluster_files, count); } #endif /* HAVE_PSI_INTERFACE */ diff --git a/sql/handler.cc b/sql/handler.cc index d9ee0e8be11..0bf74a3538e 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -2080,7 +2080,7 @@ int ha_delete_table(THD *thd, handlerton *table_type, const char *path, } delete file; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_TABLE_INTERFACE if (likely((error == 0) && (PSI_server != NULL))) PSI_server->drop_table_share(db, strlen(db), alias, strlen(alias)); #endif @@ -2173,7 +2173,7 @@ int handler::ha_open(TABLE *table_arg, const char *name, int mode, { DBUG_ASSERT(m_psi == NULL); DBUG_ASSERT(table_share != NULL); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_TABLE_INTERFACE if (likely(PSI_server != NULL)) { PSI_table_share *share_psi= ha_table_share_psi(table_share); @@ -2202,7 +2202,7 @@ int handler::ha_open(TABLE *table_arg, const char *name, int mode, int handler::ha_close(void) { -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_TABLE_INTERFACE if (likely(PSI_server && m_psi)) { PSI_server->close_table(m_psi); @@ -3894,7 +3894,7 @@ int ha_create_table(THD *thd, const char *path, if (open_table_def(thd, &share, 0)) goto err; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_TABLE_INTERFACE if (likely(PSI_server != NULL)) { my_bool temp= (create_info->options & HA_LEX_CREATE_TMP_TABLE ? TRUE : FALSE); @@ -3973,7 +3973,7 @@ int ha_create_table_from_engine(THD* thd, const char *db, const char *name) DBUG_RETURN(3); } -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_TABLE_INTERFACE /* Table discovery is not instrumented. Once discovered, the table will be opened normally, diff --git a/sql/item_func.cc b/sql/item_func.cc index 4d358b9f37b..51362c64922 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -3661,14 +3661,10 @@ static PSI_mutex_info all_user_mutexes[]= static void init_user_lock_psi_keys(void) { - const char* category= "sql"; int count; - if (PSI_server == NULL) - return; - count= array_elements(all_user_mutexes); - PSI_server->register_mutex(category, all_user_mutexes, count); + mysql_mutex_register("sql", all_user_mutexes, count); } #endif diff --git a/sql/mdl.cc b/sql/mdl.cc index 959f788186b..3da1f32dee2 100644 --- a/sql/mdl.cc +++ b/sql/mdl.cc @@ -51,20 +51,16 @@ static PSI_cond_info all_mdl_conds[]= */ static void init_mdl_psi_keys(void) { - const char *category= "sql"; int count; - if (PSI_server == NULL) - return; - count= array_elements(all_mdl_mutexes); - PSI_server->register_mutex(category, all_mdl_mutexes, count); + mysql_mutex_register("sql", all_mdl_mutexes, count); count= array_elements(all_mdl_rwlocks); - PSI_server->register_rwlock(category, all_mdl_rwlocks, count); + mysql_rwlock_register("sql", all_mdl_rwlocks, count); count= array_elements(all_mdl_conds); - PSI_server->register_cond(category, all_mdl_conds, count); + mysql_cond_register("sql", all_mdl_conds, count); } #endif /* HAVE_PSI_INTERFACE */ diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 15be6faf06b..f954d42ef74 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2073,7 +2073,7 @@ static bool cache_thread() DBUG_PRINT("info", ("Adding thread to cache")); cached_thread_count++; -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_THREAD_INTERFACE /* Delete the instrumentation for the job that just completed, before parking this pthread in the cache (blocked on COND_thread_cache). @@ -2095,7 +2095,7 @@ static bool cache_thread() thd->thread_stack= (char*) &thd; // For store_globals (void) thd->store_globals(); -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_THREAD_INTERFACE /* Create new instrumentation for the new THD job, and attach it to this running pthread. @@ -2734,7 +2734,7 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused))) if (!abort_loop) { abort_loop=1; // mark abort for threads -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_THREAD_INTERFACE /* Delete the instrumentation for the signal thread */ if (likely(PSI_server != NULL)) PSI_server->delete_current_thread(); @@ -4939,7 +4939,7 @@ int mysqld_main(int argc, char **argv) #endif #endif /* __WIN__ */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_THREAD_INTERFACE /* Disable the main thread instrumentation, to avoid recording events during the shutdown. @@ -8513,35 +8513,34 @@ void init_server_psi_keys(void) const char* category= "sql"; int count; - if (PSI_server == NULL) - return; - count= array_elements(all_server_mutexes); - PSI_server->register_mutex(category, all_server_mutexes, count); + mysql_mutex_register(category, all_server_mutexes, count); count= array_elements(all_server_rwlocks); - PSI_server->register_rwlock(category, all_server_rwlocks, count); + mysql_rwlock_register(category, all_server_rwlocks, count); count= array_elements(all_server_conds); - PSI_server->register_cond(category, all_server_conds, count); + mysql_cond_register(category, all_server_conds, count); count= array_elements(all_server_threads); - PSI_server->register_thread(category, all_server_threads, count); + mysql_thread_register(category, all_server_threads, count); count= array_elements(all_server_files); - PSI_server->register_file(category, all_server_files, count); + mysql_file_register(category, all_server_files, count); count= array_elements(all_server_stages); - PSI_server->register_stage(category, all_server_stages, count); + mysql_stage_register(category, all_server_stages, count); +#ifdef HAVE_PSI_STATEMENT_INTERFACE init_sql_statement_info(); count= array_elements(sql_statement_info); - PSI_server->register_statement(category, sql_statement_info, count); + mysql_statement_register(category, sql_statement_info, count); category= "com"; init_com_statement_info(); count= array_elements(com_statement_info); - PSI_server->register_statement(category, com_statement_info, count); + mysql_statement_register(category, com_statement_info, count); +#endif } #endif /* HAVE_PSI_INTERFACE */ diff --git a/sql/rpl_master.cc b/sql/rpl_master.cc index 60b62e6ff1a..476f2776079 100644 --- a/sql/rpl_master.cc +++ b/sql/rpl_master.cc @@ -75,14 +75,10 @@ static PSI_mutex_info all_slave_list_mutexes[]= static void init_all_slave_list_mutexes(void) { - const char* category= "sql"; int count; - if (PSI_server == NULL) - return; - count= array_elements(all_slave_list_mutexes); - PSI_server->register_mutex(category, all_slave_list_mutexes, count); + mysql_mutex_register("sql", all_slave_list_mutexes, count); } #endif /* HAVE_PSI_INTERFACE */ diff --git a/sql/rpl_slave.cc b/sql/rpl_slave.cc index 3f8244d9260..31574728e32 100644 --- a/sql/rpl_slave.cc +++ b/sql/rpl_slave.cc @@ -245,11 +245,8 @@ static void init_slave_psi_keys(void) const char* category= "sql"; int count; - if (PSI_server == NULL) - return; - count= array_elements(all_slave_threads); - PSI_server->register_thread(category, all_slave_threads, count); + mysql_thread_register(category, all_slave_threads, count); } #endif /* HAVE_PSI_INTERFACE */ diff --git a/sql/sp_cache.cc b/sql/sp_cache.cc index d4478497998..6d64909bdb2 100644 --- a/sql/sp_cache.cc +++ b/sql/sp_cache.cc @@ -75,11 +75,8 @@ static void init_sp_cache_psi_keys(void) const char* category= "sql"; int count; - if (PSI_server == NULL) - return; - count= array_elements(all_sp_cache_mutexes); - PSI_server->register_mutex(category, all_sp_cache_mutexes, count); + mysql_mutex_register(category, all_sp_cache_mutexes, count); } #endif diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 408eb93759e..7f7bef6f1ae 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -9464,8 +9464,8 @@ acl_authenticate(THD *thd, uint connect_errors, uint com_change_user_pkt_len) thd->net.skip_big_packet= TRUE; #endif -#ifdef HAVE_PSI_INTERFACE - if (PSI_server) +#ifdef HAVE_PSI_THREAD_INTERFACE + if (likely(PSI_server != NULL)) { PSI_server->set_thread_user_host(thd->main_security_ctx.user, strlen(thd->main_security_ctx.user), diff --git a/sql/sql_audit.cc b/sql/sql_audit.cc index aa0a72e43b8..39663b1bfeb 100644 --- a/sql/sql_audit.cc +++ b/sql/sql_audit.cc @@ -290,11 +290,8 @@ static void init_audit_psi_keys(void) const char* category= "sql"; int count; - if (PSI_server == NULL) - return; - count= array_elements(all_audit_mutexes); - PSI_server->register_mutex(category, all_audit_mutexes, count); + mysql_mutex_register(category, all_audit_mutexes, count); } #endif /* HAVE_PSI_INTERFACE */ diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 0f5e1766c79..25f6130e786 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -116,11 +116,8 @@ static void init_tdc_psi_keys(void) const char *category= "sql"; int count; - if (PSI_server == NULL) - return; - count= array_elements(all_tdc_mutexes); - PSI_server->register_mutex(category, all_tdc_mutexes, count); + mysql_mutex_register(category, all_tdc_mutexes, count); } #endif /* HAVE_PSI_INTERFACE */ @@ -549,7 +546,7 @@ TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key, } share->ref_count++; // Mark in use -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_TABLE_INTERFACE if (likely(PSI_server != NULL)) share->m_psi= PSI_server->get_table_share(false, share); #endif @@ -5896,7 +5893,7 @@ TABLE *open_table_uncached(THD *thd, const char *path, const char *db, DBUG_RETURN(0); } -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_TABLE_INTERFACE if (likely(PSI_server != NULL)) share->m_psi= PSI_server->get_table_share(true, share); #endif diff --git a/sql/sql_class.cc b/sql/sql_class.cc index f30805b87a7..eb830918f1e 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -260,8 +260,8 @@ const char *set_thd_proc_info(void *thd_arg, const char *info, thd->profiling.status_change(info, calling_function, basename, calling_line); #endif thd->proc_info= info; -#ifdef HAVE_PSI_INTERFACE - if (PSI_server) +#ifdef HAVE_PSI_THREAD_INTERFACE + if (likely(PSI_server != NULL)) PSI_server->set_thread_state(info); #endif return old_info; @@ -3540,8 +3540,8 @@ void THD::inc_examined_row_count(ha_rows count) void THD::inc_status_created_tmp_disk_tables() { status_var_increment(status_var.created_tmp_disk_tables); -#ifdef HAVE_PSI_INTERFACE - if (PSI_server && m_statement_psi) +#ifdef HAVE_PSI_STATEMENT_INTERFACE + if (likely(PSI_server && m_statement_psi)) PSI_server->inc_statement_created_tmp_disk_tables(m_statement_psi, 1); #endif } @@ -3549,8 +3549,8 @@ void THD::inc_status_created_tmp_disk_tables() void THD::inc_status_created_tmp_tables() { status_var_increment(status_var.created_tmp_tables); -#ifdef HAVE_PSI_INTERFACE - if (PSI_server && m_statement_psi) +#ifdef HAVE_PSI_STATEMENT_INTERFACE + if (likely(PSI_server && m_statement_psi)) PSI_server->inc_statement_created_tmp_tables(m_statement_psi, 1); #endif } @@ -3558,8 +3558,8 @@ void THD::inc_status_created_tmp_tables() void THD::inc_status_select_full_join() { status_var_increment(status_var.select_full_join_count); -#ifdef HAVE_PSI_INTERFACE - if (PSI_server && m_statement_psi) +#ifdef HAVE_PSI_STATEMENT_INTERFACE + if (likely(PSI_server && m_statement_psi)) PSI_server->inc_statement_select_full_join(m_statement_psi, 1); #endif } @@ -3567,8 +3567,8 @@ void THD::inc_status_select_full_join() void THD::inc_status_select_full_range_join() { status_var_increment(status_var.select_full_range_join_count); -#ifdef HAVE_PSI_INTERFACE - if (PSI_server && m_statement_psi) +#ifdef HAVE_PSI_STATEMENT_INTERFACE + if (likely(PSI_server && m_statement_psi)) PSI_server->inc_statement_select_full_range_join(m_statement_psi, 1); #endif } @@ -3576,8 +3576,8 @@ void THD::inc_status_select_full_range_join() void THD::inc_status_select_range() { status_var_increment(status_var.select_range_count); -#ifdef HAVE_PSI_INTERFACE - if (PSI_server && m_statement_psi) +#ifdef HAVE_PSI_STATEMENT_INTERFACE + if (likely(PSI_server && m_statement_psi)) PSI_server->inc_statement_select_range(m_statement_psi, 1); #endif } @@ -3585,8 +3585,8 @@ void THD::inc_status_select_range() void THD::inc_status_select_range_check() { status_var_increment(status_var.select_range_check_count); -#ifdef HAVE_PSI_INTERFACE - if (PSI_server && m_statement_psi) +#ifdef HAVE_PSI_STATEMENT_INTERFACE + if (likely(PSI_server && m_statement_psi)) PSI_server->inc_statement_select_range_check(m_statement_psi, 1); #endif } @@ -3594,8 +3594,8 @@ void THD::inc_status_select_range_check() void THD::inc_status_select_scan() { status_var_increment(status_var.select_scan_count); -#ifdef HAVE_PSI_INTERFACE - if (PSI_server && m_statement_psi) +#ifdef HAVE_PSI_STATEMENT_INTERFACE + if (likely(PSI_server && m_statement_psi)) PSI_server->inc_statement_select_scan(m_statement_psi, 1); #endif } @@ -3603,8 +3603,8 @@ void THD::inc_status_select_scan() void THD::inc_status_sort_merge_passes() { status_var_increment(status_var.filesort_merge_passes); -#ifdef HAVE_PSI_INTERFACE - if (PSI_server && m_statement_psi) +#ifdef HAVE_PSI_STATEMENT_INTERFACE + if (likely(PSI_server && m_statement_psi)) PSI_server->inc_statement_sort_merge_passes(m_statement_psi, 1); #endif } @@ -3612,8 +3612,8 @@ void THD::inc_status_sort_merge_passes() void THD::inc_status_sort_range() { status_var_increment(status_var.filesort_range_count); -#ifdef HAVE_PSI_INTERFACE - if (PSI_server && m_statement_psi) +#ifdef HAVE_PSI_STATEMENT_INTERFACE + if (likely(PSI_server && m_statement_psi)) PSI_server->inc_statement_sort_range(m_statement_psi, 1); #endif } @@ -3621,8 +3621,8 @@ void THD::inc_status_sort_range() void THD::inc_status_sort_rows(ha_rows count) { statistic_add(status_var.filesort_rows, count, &LOCK_status); -#ifdef HAVE_PSI_INTERFACE - if (PSI_server && m_statement_psi) +#ifdef HAVE_PSI_STATEMENT_INTERFACE + if (likely(PSI_server && m_statement_psi)) PSI_server->inc_statement_sort_rows(m_statement_psi, count); #endif } @@ -3630,8 +3630,8 @@ void THD::inc_status_sort_rows(ha_rows count) void THD::inc_status_sort_scan() { status_var_increment(status_var.filesort_scan_count); -#ifdef HAVE_PSI_INTERFACE - if (PSI_server && m_statement_psi) +#ifdef HAVE_PSI_STATEMENT_INTERFACE + if (likely(PSI_server && m_statement_psi)) PSI_server->inc_statement_sort_scan(m_statement_psi, 1); #endif } @@ -3639,8 +3639,8 @@ void THD::inc_status_sort_scan() void THD::set_status_no_index_used() { server_status|= SERVER_QUERY_NO_INDEX_USED; -#ifdef HAVE_PSI_INTERFACE - if (PSI_server && m_statement_psi) +#ifdef HAVE_PSI_STATEMENT_INTERFACE + if (likely(PSI_server && m_statement_psi)) PSI_server->set_statement_no_index_used(m_statement_psi); #endif } @@ -3648,8 +3648,8 @@ void THD::set_status_no_index_used() void THD::set_status_no_good_index_used() { server_status|= SERVER_QUERY_NO_GOOD_INDEX_USED; -#ifdef HAVE_PSI_INTERFACE - if (PSI_server && m_statement_psi) +#ifdef HAVE_PSI_STATEMENT_INTERFACE + if (likely(PSI_server && m_statement_psi)) PSI_server->set_statement_no_good_index_used(m_statement_psi); #endif } @@ -3657,8 +3657,8 @@ void THD::set_status_no_good_index_used() void THD::set_command(enum enum_server_command command) { m_command= command; -#ifdef HAVE_PSI_INTERFACE - if (PSI_server) +#ifdef HAVE_PSI_THREAD_INTERFACE + if (likely(PSI_server != NULL)) PSI_server->set_thread_command(m_command); #endif } @@ -3672,8 +3672,8 @@ void THD::set_query(const CSET_STRING &string_arg) set_query_inner(string_arg); mysql_mutex_unlock(&LOCK_thd_data); -#ifdef HAVE_PSI_INTERFACE - if (PSI_server) +#ifdef HAVE_PSI_THREAD_INTERFACE + if (likely(PSI_server != NULL)) PSI_server->set_thread_info(query(), query_length()); #endif } @@ -3808,11 +3808,8 @@ static void init_xid_psi_keys(void) const char* category= "sql"; int count; - if (PSI_server == NULL) - return; - count= array_elements(all_xid_mutexes); - PSI_server->register_mutex(category, all_xid_mutexes, count); + mysql_mutex_register(category, all_xid_mutexes, count); } #endif /* HAVE_PSI_INTERFACE */ diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 3c7c456bea3..62ef2716ab0 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -128,11 +128,8 @@ static void init_database_names_psi_keys(void) const char* category= "sql"; int count; - if (PSI_server == NULL) - return; - count= array_elements(all_database_names_rwlocks); - PSI_server->register_rwlock(category, all_database_names_rwlocks, count); + mysql_rwlock_register(category, all_database_names_rwlocks, count); } #endif diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 4abb8c6ba88..1823c6ddd86 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -911,7 +911,7 @@ static my_bool deny_updates_if_read_only_option(THD *thd, bool dispatch_command(enum enum_server_command command, THD *thd, char* packet, uint packet_length) { -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_STATEMENT_INTERFACE PSI_statement_locker_state state; #endif diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index ee26379b3a9..31762d38e14 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -1185,11 +1185,8 @@ static void init_plugin_psi_keys(void) const char* category= "sql"; int count; - if (PSI_server == NULL) - return; - count= array_elements(all_plugin_mutexes); - PSI_server->register_mutex(category, all_plugin_mutexes, count); + mysql_mutex_register(category, all_plugin_mutexes, count); } #endif /* HAVE_PSI_INTERFACE */ diff --git a/sql/sql_servers.cc b/sql/sql_servers.cc index e6764c92e82..4cff99582b6 100644 --- a/sql/sql_servers.cc +++ b/sql/sql_servers.cc @@ -108,11 +108,8 @@ static void init_servers_cache_psi_keys(void) const char* category= "sql"; int count; - if (PSI_server == NULL) - return; - count= array_elements(all_servers_cache_rwlocks); - PSI_server->register_rwlock(category, all_servers_cache_rwlocks, count); + mysql_rwlock_register(category, all_servers_cache_rwlocks, count); } #endif /* HAVE_PSI_INTERFACE */ diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index cafe2fb904e..8bf9341a6f4 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -115,11 +115,8 @@ static void init_udf_psi_keys(void) const char* category= "sql"; int count; - if (PSI_server == NULL) - return; - count= array_elements(all_udf_rwlocks); - PSI_server->register_rwlock(category, all_udf_rwlocks, count); + mysql_rwlock_register(category, all_udf_rwlocks, count); } #endif diff --git a/sql/table.cc b/sql/table.cc index d00ebb8e93e..493c6fc4642 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -470,7 +470,7 @@ void TABLE_SHARE::destroy() } #endif /* WITH_PARTITION_STORAGE_ENGINE */ -#ifdef HAVE_PSI_INTERFACE +#ifdef HAVE_PSI_TABLE_INTERFACE if (likely(PSI_server && m_psi)) PSI_server->release_table_share(m_psi); #endif diff --git a/sql/tztime.cc b/sql/tztime.cc index c8cf60ff508..fdf490a2407 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -1549,11 +1549,8 @@ static void init_tz_psi_keys(void) const char* category= "sql"; int count; - if (PSI_server == NULL) - return; - count= array_elements(all_tz_mutexes); - PSI_server->register_mutex(category, all_tz_mutexes, count); + mysql_mutex_register(category, all_tz_mutexes, count); } #endif /* HAVE_PSI_INTERFACE */ diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index e7cd4751482..ca07fd1f8df 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -157,11 +157,8 @@ static void init_archive_psi_keys(void) const char* category= "archive"; int count; - if (PSI_server == NULL) - return; - count= array_elements(all_archive_mutexes); - PSI_server->register_mutex(category, all_archive_mutexes, count); + mysql_mutex_register(category, all_archive_mutexes, count); } #endif /* HAVE_PSI_INTERFACE */ diff --git a/storage/blackhole/ha_blackhole.cc b/storage/blackhole/ha_blackhole.cc index 277eebb0faa..6d5511ee3f0 100644 --- a/storage/blackhole/ha_blackhole.cc +++ b/storage/blackhole/ha_blackhole.cc @@ -389,11 +389,8 @@ void init_blackhole_psi_keys() const char* category= "blackhole"; int count; - if (PSI_server == NULL) - return; - count= array_elements(all_blackhole_mutexes); - PSI_server->register_mutex(category, all_blackhole_mutexes, count); + mysql_mutex_register(category, all_blackhole_mutexes, count); } #endif diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc index 8752ed87f62..a876769ab5b 100644 --- a/storage/csv/ha_tina.cc +++ b/storage/csv/ha_tina.cc @@ -129,14 +129,11 @@ static void init_tina_psi_keys(void) const char* category= "csv"; int count; - if (PSI_server == NULL) - return; - count= array_elements(all_tina_mutexes); - PSI_server->register_mutex(category, all_tina_mutexes, count); + mysql_mutex_register(category, all_tina_mutexes, count); count= array_elements(all_tina_files); - PSI_server->register_file(category, all_tina_files, count); + mysql_file_register(category, all_tina_files, count); } #endif /* HAVE_PSI_INTERFACE */ diff --git a/storage/example/ha_example.cc b/storage/example/ha_example.cc index 9fde35a8588..69a6811a4d0 100644 --- a/storage/example/ha_example.cc +++ b/storage/example/ha_example.cc @@ -136,11 +136,8 @@ static void init_example_psi_keys() const char* category= "example"; int count; - if (PSI_server == NULL) - return; - count= array_elements(all_example_mutexes); - PSI_server->register_mutex(category, all_example_mutexes, count); + mysql_mutex_register(category, all_example_mutexes, count); } #endif diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc index 8f7bacb24fe..bf235174150 100644 --- a/storage/federated/ha_federated.cc +++ b/storage/federated/ha_federated.cc @@ -441,11 +441,8 @@ static void init_federated_psi_keys(void) const char* category= "federated"; int count; - if (PSI_server == NULL) - return; - count= array_elements(all_federated_mutexes); - PSI_server->register_mutex(category, all_federated_mutexes, count); + mysql_mutex_register(category, all_federated_mutexes, count); } #endif /* HAVE_PSI_INTERFACE */ diff --git a/storage/heap/hp_static.c b/storage/heap/hp_static.c index a58ecb8b754..9cbc1e16879 100644 --- a/storage/heap/hp_static.c +++ b/storage/heap/hp_static.c @@ -41,11 +41,8 @@ void init_heap_psi_keys() const char* category= "memory"; int count; - if (PSI_server == NULL) - return; - count= array_elements(all_heap_mutexes); - PSI_server->register_mutex(category, all_heap_mutexes, count); + mysql_mutex_register(category, all_heap_mutexes, count); } #endif /* HAVE_PSI_INTERFACE */ diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index b998b5af735..593d4052a19 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -2665,35 +2665,35 @@ innobase_init( count = array_elements(all_pthread_mutexes); - PSI_server->register_mutex( + mysql_mutex_register( "innodb", all_pthread_mutexes, count); # ifdef UNIV_PFS_MUTEX count = array_elements(all_innodb_mutexes); - PSI_server->register_mutex("innodb", + mysql_mutex_register("innodb", all_innodb_mutexes, count); # endif /* UNIV_PFS_MUTEX */ # ifdef UNIV_PFS_RWLOCK count = array_elements(all_innodb_rwlocks); - PSI_server->register_rwlock("innodb", + mysql_rwlock_register("innodb", all_innodb_rwlocks, count); # endif /* UNIV_PFS_MUTEX */ # ifdef UNIV_PFS_THREAD count = array_elements(all_innodb_threads); - PSI_server->register_thread("innodb", + mysql_thread_register("innodb", all_innodb_threads, count); # endif /* UNIV_PFS_THREAD */ # ifdef UNIV_PFS_IO count = array_elements(all_innodb_files); - PSI_server->register_file("innodb", + mysql_file_register("innodb", all_innodb_files, count); # endif /* UNIV_PFS_IO */ count = array_elements(all_innodb_conds); - PSI_server->register_cond("innodb", + mysql_cond_register("innodb", all_innodb_conds, count); } #endif /* HAVE_PSI_INTERFACE */ diff --git a/storage/myisam/mi_static.c b/storage/myisam/mi_static.c index 711287ca16f..69756127400 100644 --- a/storage/myisam/mi_static.c +++ b/storage/myisam/mi_static.c @@ -118,23 +118,20 @@ void init_myisam_psi_keys() const char* category= "myisam"; int count; - if (PSI_server == NULL) - return; - count= array_elements(all_myisam_mutexes); - PSI_server->register_mutex(category, all_myisam_mutexes, count); + mysql_mutex_register(category, all_myisam_mutexes, count); count= array_elements(all_myisam_rwlocks); - PSI_server->register_rwlock(category, all_myisam_rwlocks, count); + mysql_rwlock_register(category, all_myisam_rwlocks, count); count= array_elements(all_myisam_conds); - PSI_server->register_cond(category, all_myisam_conds, count); + mysql_cond_register(category, all_myisam_conds, count); count= array_elements(all_myisam_files); - PSI_server->register_file(category, all_myisam_files, count); + mysql_file_register(category, all_myisam_files, count); count= array_elements(all_myisam_threads); - PSI_server->register_thread(category, all_myisam_threads, count); + mysql_thread_register(category, all_myisam_threads, count); } #endif /* HAVE_PSI_INTERFACE */ diff --git a/storage/myisammrg/myrg_static.c b/storage/myisammrg/myrg_static.c index b518a3d84c8..94ff5fc5780 100644 --- a/storage/myisammrg/myrg_static.c +++ b/storage/myisammrg/myrg_static.c @@ -48,14 +48,11 @@ void init_myisammrg_psi_keys() const char* category= "myisammrg"; int count; - if (PSI_server == NULL) - return; - count= array_elements(all_myisammrg_mutexes); - PSI_server->register_mutex(category, all_myisammrg_mutexes, count); + mysql_mutex_register(category, all_myisammrg_mutexes, count); count= array_elements(all_myisammrg_files); - PSI_server->register_file(category, all_myisammrg_files, count); + mysql_file_register(category, all_myisammrg_files, count); } #endif /* HAVE_PSI_INTERFACE */