1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Optimize performance schema likely/unlikely

Performance schema likely/unlikely assume that performance schema
is enabled by default, which causes a performance degradation for
default installations that doesn't have performance schema enabled.

Fixed by changing the likely/unlikely in PS to assume it's
not enabled. This can be changed by compiling with
-DPSI_ON_BY_DEFAULT

Other changes:
- Added psi_likely/psi_unlikely that is depending on
  PSI_ON_BY_DEFAULT. psi_likely() is assumed to be true
  if PS is enabled.
- Added likely/unlikely to some PS interface code.
- Moved pfs_enabled to mysys (was initialized but not used before)
- Added "if (pfs_likely(pfs_enabled))" around calls to PS to avoid
  an extra call if PS is not enabled.
- Moved checking flag_global_instrumention before other flags
  to speed up the case when PS is not enabled.
This commit is contained in:
Michael Widenius
2018-04-17 00:08:03 +03:00
committed by Monty
parent 9d6dc39ad9
commit 70c1110a29
14 changed files with 486 additions and 401 deletions

View File

@@ -529,10 +529,11 @@ inline_mysql_file_fgets(
{ {
char *result; char *result;
#ifdef HAVE_PSI_FILE_INTERFACE #ifdef HAVE_PSI_FILE_INTERFACE
if (psi_likely(pfs_enabled))
{
struct PSI_file_locker *locker; struct PSI_file_locker *locker;
PSI_file_locker_state state; PSI_file_locker_state state;
locker= PSI_FILE_CALL(get_thread_file_stream_locker) locker= PSI_FILE_CALL(get_thread_file_stream_locker) (&state, file->m_psi, PSI_FILE_READ);
(&state, file->m_psi, PSI_FILE_READ);
if (likely(locker != NULL)) if (likely(locker != NULL))
{ {
PSI_FILE_CALL(start_file_wait)(locker, (size_t) size, src_file, src_line); PSI_FILE_CALL(start_file_wait)(locker, (size_t) size, src_file, src_line);
@@ -540,6 +541,7 @@ inline_mysql_file_fgets(
PSI_FILE_CALL(end_file_wait)(locker, result ? strlen(result) : 0); PSI_FILE_CALL(end_file_wait)(locker, result ? strlen(result) : 0);
return result; return result;
} }
}
#endif #endif
result= fgets(str, size, file->m_file); result= fgets(str, size, file->m_file);
@@ -555,10 +557,11 @@ inline_mysql_file_fgetc(
{ {
int result; int result;
#ifdef HAVE_PSI_FILE_INTERFACE #ifdef HAVE_PSI_FILE_INTERFACE
if (psi_likely(pfs_enabled))
{
struct PSI_file_locker *locker; struct PSI_file_locker *locker;
PSI_file_locker_state state; PSI_file_locker_state state;
locker= PSI_FILE_CALL(get_thread_file_stream_locker) locker= PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi, PSI_FILE_READ);
(&state, file->m_psi, PSI_FILE_READ);
if (likely(locker != NULL)) if (likely(locker != NULL))
{ {
PSI_FILE_CALL(start_file_wait)(locker, (size_t) 1, src_file, src_line); PSI_FILE_CALL(start_file_wait)(locker, (size_t) 1, src_file, src_line);
@@ -566,6 +569,7 @@ inline_mysql_file_fgetc(
PSI_FILE_CALL(end_file_wait)(locker, (size_t) 1); PSI_FILE_CALL(end_file_wait)(locker, (size_t) 1);
return result; return result;
} }
}
#endif #endif
result= fgetc(file->m_file); result= fgetc(file->m_file);
@@ -581,11 +585,12 @@ inline_mysql_file_fputs(
{ {
int result; int result;
#ifdef HAVE_PSI_FILE_INTERFACE #ifdef HAVE_PSI_FILE_INTERFACE
if (psi_likely(pfs_enabled))
{
struct PSI_file_locker *locker; struct PSI_file_locker *locker;
PSI_file_locker_state state; PSI_file_locker_state state;
size_t bytes; size_t bytes;
locker= PSI_FILE_CALL(get_thread_file_stream_locker) locker= PSI_FILE_CALL(get_thread_file_stream_locker) (&state, file->m_psi, PSI_FILE_WRITE);
(&state, file->m_psi, PSI_FILE_WRITE);
if (likely(locker != NULL)) if (likely(locker != NULL))
{ {
bytes= str ? strlen(str) : 0; bytes= str ? strlen(str) : 0;
@@ -594,6 +599,7 @@ inline_mysql_file_fputs(
PSI_FILE_CALL(end_file_wait)(locker, bytes); PSI_FILE_CALL(end_file_wait)(locker, bytes);
return result; return result;
} }
}
#endif #endif
result= fputs(str, file->m_file); result= fputs(str, file->m_file);
@@ -609,10 +615,11 @@ inline_mysql_file_fputc(
{ {
int result; int result;
#ifdef HAVE_PSI_FILE_INTERFACE #ifdef HAVE_PSI_FILE_INTERFACE
if (psi_likely(pfs_enabled))
{
struct PSI_file_locker *locker; struct PSI_file_locker *locker;
PSI_file_locker_state state; PSI_file_locker_state state;
locker= PSI_FILE_CALL(get_thread_file_stream_locker) locker= PSI_FILE_CALL(get_thread_file_stream_locker) (&state, file->m_psi, PSI_FILE_WRITE);
(&state, file->m_psi, PSI_FILE_WRITE);
if (likely(locker != NULL)) if (likely(locker != NULL))
{ {
PSI_FILE_CALL(start_file_wait)(locker, (size_t) 1, src_file, src_line); PSI_FILE_CALL(start_file_wait)(locker, (size_t) 1, src_file, src_line);
@@ -620,6 +627,7 @@ inline_mysql_file_fputc(
PSI_FILE_CALL(end_file_wait)(locker, (size_t) 1); PSI_FILE_CALL(end_file_wait)(locker, (size_t) 1);
return result; return result;
} }
}
#endif #endif
result= fputc(c, file->m_file); result= fputc(c, file->m_file);
@@ -635,10 +643,11 @@ inline_mysql_file_fprintf(MYSQL_FILE *file, const char *format, ...)
int result; int result;
va_list args; va_list args;
#ifdef HAVE_PSI_FILE_INTERFACE #ifdef HAVE_PSI_FILE_INTERFACE
if (psi_likely(pfs_enabled))
{
struct PSI_file_locker *locker; struct PSI_file_locker *locker;
PSI_file_locker_state state; PSI_file_locker_state state;
locker= PSI_FILE_CALL(get_thread_file_stream_locker) locker= PSI_FILE_CALL(get_thread_file_stream_locker) (&state, file->m_psi, PSI_FILE_WRITE);
(&state, file->m_psi, PSI_FILE_WRITE);
if (likely(locker != NULL)) if (likely(locker != NULL))
{ {
PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, __FILE__, __LINE__); PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, __FILE__, __LINE__);
@@ -648,6 +657,7 @@ inline_mysql_file_fprintf(MYSQL_FILE *file, const char *format, ...)
PSI_FILE_CALL(end_file_wait)(locker, (size_t) result); PSI_FILE_CALL(end_file_wait)(locker, (size_t) result);
return result; return result;
} }
}
#endif #endif
va_start(args, format); va_start(args, format);
@@ -665,10 +675,11 @@ inline_mysql_file_vfprintf(
{ {
int result; int result;
#ifdef HAVE_PSI_FILE_INTERFACE #ifdef HAVE_PSI_FILE_INTERFACE
if (psi_likely(pfs_enabled))
{
struct PSI_file_locker *locker; struct PSI_file_locker *locker;
PSI_file_locker_state state; PSI_file_locker_state state;
locker= PSI_FILE_CALL(get_thread_file_stream_locker) locker= PSI_FILE_CALL(get_thread_file_stream_locker) (&state, file->m_psi, PSI_FILE_WRITE);
(&state, file->m_psi, PSI_FILE_WRITE);
if (likely(locker != NULL)) if (likely(locker != NULL))
{ {
PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line); PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
@@ -676,6 +687,7 @@ inline_mysql_file_vfprintf(
PSI_FILE_CALL(end_file_wait)(locker, (size_t) result); PSI_FILE_CALL(end_file_wait)(locker, (size_t) result);
return result; return result;
} }
}
#endif #endif
result= vfprintf(file->m_file, format, args); result= vfprintf(file->m_file, format, args);
@@ -691,10 +703,11 @@ inline_mysql_file_fflush(
{ {
int result; int result;
#ifdef HAVE_PSI_FILE_INTERFACE #ifdef HAVE_PSI_FILE_INTERFACE
if (psi_likely(pfs_enabled))
{
struct PSI_file_locker *locker; struct PSI_file_locker *locker;
PSI_file_locker_state state; PSI_file_locker_state state;
locker= PSI_FILE_CALL(get_thread_file_stream_locker) locker= PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi, PSI_FILE_FLUSH);
(&state, file->m_psi, PSI_FILE_FLUSH);
if (likely(locker != NULL)) if (likely(locker != NULL))
{ {
PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line); PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
@@ -702,6 +715,7 @@ inline_mysql_file_fflush(
PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0); PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
return result; return result;
} }
}
#endif #endif
result= fflush(file->m_file); result= fflush(file->m_file);
@@ -723,10 +737,11 @@ inline_mysql_file_fstat(
{ {
int result; int result;
#ifdef HAVE_PSI_FILE_INTERFACE #ifdef HAVE_PSI_FILE_INTERFACE
if (psi_likely(pfs_enabled))
{
struct PSI_file_locker *locker; struct PSI_file_locker *locker;
PSI_file_locker_state state; PSI_file_locker_state state;
locker= PSI_FILE_CALL(get_thread_file_descriptor_locker) locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, filenr, PSI_FILE_FSTAT);
(&state, filenr, PSI_FILE_FSTAT);
if (likely(locker != NULL)) if (likely(locker != NULL))
{ {
PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line); PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
@@ -734,6 +749,7 @@ inline_mysql_file_fstat(
PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0); PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
return result; return result;
} }
}
#endif #endif
result= my_fstat(filenr, stat_area, flags); result= my_fstat(filenr, stat_area, flags);
@@ -749,10 +765,11 @@ inline_mysql_file_stat(
{ {
MY_STAT *result; MY_STAT *result;
#ifdef HAVE_PSI_FILE_INTERFACE #ifdef HAVE_PSI_FILE_INTERFACE
if (psi_likely(pfs_enabled))
{
struct PSI_file_locker *locker; struct PSI_file_locker *locker;
PSI_file_locker_state state; PSI_file_locker_state state;
locker= PSI_FILE_CALL(get_thread_file_name_locker) locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_STAT, path, &locker);
(&state, key, PSI_FILE_STAT, path, &locker);
if (likely(locker != NULL)) if (likely(locker != NULL))
{ {
PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line); PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
@@ -760,6 +777,7 @@ inline_mysql_file_stat(
PSI_FILE_CALL(end_file_open_wait)(locker, result); PSI_FILE_CALL(end_file_open_wait)(locker, result);
return result; return result;
} }
}
#endif #endif
result= my_stat(path, stat_area, flags); result= my_stat(path, stat_area, flags);
@@ -775,10 +793,11 @@ inline_mysql_file_chsize(
{ {
int result; int result;
#ifdef HAVE_PSI_FILE_INTERFACE #ifdef HAVE_PSI_FILE_INTERFACE
if (psi_likely(pfs_enabled))
{
struct PSI_file_locker *locker; struct PSI_file_locker *locker;
PSI_file_locker_state state; PSI_file_locker_state state;
locker= PSI_FILE_CALL(get_thread_file_descriptor_locker) locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_CHSIZE);
(&state, file, PSI_FILE_CHSIZE);
if (likely(locker != NULL)) if (likely(locker != NULL))
{ {
PSI_FILE_CALL(start_file_wait)(locker, (size_t) newlength, src_file, PSI_FILE_CALL(start_file_wait)(locker, (size_t) newlength, src_file,
@@ -787,6 +806,7 @@ inline_mysql_file_chsize(
PSI_FILE_CALL(end_file_wait)(locker, (size_t) newlength); PSI_FILE_CALL(end_file_wait)(locker, (size_t) newlength);
return result; return result;
} }
}
#endif #endif
result= my_chsize(file, newlength, filler, flags); result= my_chsize(file, newlength, filler, flags);
@@ -805,14 +825,15 @@ inline_mysql_file_fopen(
if (likely(that != NULL)) if (likely(that != NULL))
{ {
#ifdef HAVE_PSI_FILE_INTERFACE #ifdef HAVE_PSI_FILE_INTERFACE
if (psi_likely(pfs_enabled))
{
struct PSI_file_locker *locker; struct PSI_file_locker *locker;
PSI_file_locker_state state; PSI_file_locker_state state;
locker= PSI_FILE_CALL(get_thread_file_name_locker) locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_STREAM_OPEN,
(&state, key, PSI_FILE_STREAM_OPEN, filename, that); filename, that);
if (likely(locker != NULL)) if (likely(locker != NULL))
{ {
PSI_FILE_CALL(start_file_open_wait) PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
(locker, src_file, src_line);
that->m_file= my_fopen(filename, flags, myFlags); that->m_file= my_fopen(filename, flags, myFlags);
that->m_psi= PSI_FILE_CALL(end_file_open_wait)(locker, that->m_file); that->m_psi= PSI_FILE_CALL(end_file_open_wait)(locker, that->m_file);
if (unlikely(that->m_file == NULL)) if (unlikely(that->m_file == NULL))
@@ -822,6 +843,7 @@ inline_mysql_file_fopen(
} }
return that; return that;
} }
}
#endif #endif
that->m_psi= NULL; that->m_psi= NULL;
@@ -846,10 +868,12 @@ inline_mysql_file_fclose(
if (likely(file != NULL)) if (likely(file != NULL))
{ {
#ifdef HAVE_PSI_FILE_INTERFACE #ifdef HAVE_PSI_FILE_INTERFACE
if (psi_likely(pfs_enabled))
{
struct PSI_file_locker *locker; struct PSI_file_locker *locker;
PSI_file_locker_state state; PSI_file_locker_state state;
locker= PSI_FILE_CALL(get_thread_file_stream_locker) locker= PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
(&state, file->m_psi, PSI_FILE_STREAM_CLOSE); PSI_FILE_STREAM_CLOSE);
if (likely(locker != NULL)) if (likely(locker != NULL))
{ {
PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line); PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
@@ -858,6 +882,7 @@ inline_mysql_file_fclose(
my_free(file); my_free(file);
return result; return result;
} }
}
#endif #endif
result= my_fclose(file->m_file, flags); result= my_fclose(file->m_file, flags);
@@ -875,11 +900,12 @@ inline_mysql_file_fread(
{ {
size_t result; size_t result;
#ifdef HAVE_PSI_FILE_INTERFACE #ifdef HAVE_PSI_FILE_INTERFACE
if (psi_likely(pfs_enabled))
{
struct PSI_file_locker *locker; struct PSI_file_locker *locker;
PSI_file_locker_state state; PSI_file_locker_state state;
size_t bytes_read; size_t bytes_read;
locker= PSI_FILE_CALL(get_thread_file_stream_locker) locker= PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi, PSI_FILE_READ);
(&state, file->m_psi, PSI_FILE_READ);
if (likely(locker != NULL)) if (likely(locker != NULL))
{ {
PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line); PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
@@ -891,6 +917,7 @@ inline_mysql_file_fread(
PSI_FILE_CALL(end_file_wait)(locker, bytes_read); PSI_FILE_CALL(end_file_wait)(locker, bytes_read);
return result; return result;
} }
}
#endif #endif
result= my_fread(file->m_file, buffer, count, flags); result= my_fread(file->m_file, buffer, count, flags);
@@ -906,11 +933,12 @@ inline_mysql_file_fwrite(
{ {
size_t result; size_t result;
#ifdef HAVE_PSI_FILE_INTERFACE #ifdef HAVE_PSI_FILE_INTERFACE
if (psi_likely(pfs_enabled))
{
struct PSI_file_locker *locker; struct PSI_file_locker *locker;
PSI_file_locker_state state; PSI_file_locker_state state;
size_t bytes_written; size_t bytes_written;
locker= PSI_FILE_CALL(get_thread_file_stream_locker) locker= PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi, PSI_FILE_WRITE);
(&state, file->m_psi, PSI_FILE_WRITE);
if (likely(locker != NULL)) if (likely(locker != NULL))
{ {
PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line); PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
@@ -922,6 +950,7 @@ inline_mysql_file_fwrite(
PSI_FILE_CALL(end_file_wait)(locker, bytes_written); PSI_FILE_CALL(end_file_wait)(locker, bytes_written);
return result; return result;
} }
}
#endif #endif
result= my_fwrite(file->m_file, buffer, count, flags); result= my_fwrite(file->m_file, buffer, count, flags);
@@ -937,10 +966,11 @@ inline_mysql_file_fseek(
{ {
my_off_t result; my_off_t result;
#ifdef HAVE_PSI_FILE_INTERFACE #ifdef HAVE_PSI_FILE_INTERFACE
if (psi_likely(pfs_enabled))
{
struct PSI_file_locker *locker; struct PSI_file_locker *locker;
PSI_file_locker_state state; PSI_file_locker_state state;
locker= PSI_FILE_CALL(get_thread_file_stream_locker) locker= PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi, PSI_FILE_SEEK);
(&state, file->m_psi, PSI_FILE_SEEK);
if (likely(locker != NULL)) if (likely(locker != NULL))
{ {
PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line); PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
@@ -948,6 +978,7 @@ inline_mysql_file_fseek(
PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0); PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
return result; return result;
} }
}
#endif #endif
result= my_fseek(file->m_file, pos, whence, flags); result= my_fseek(file->m_file, pos, whence, flags);
@@ -963,10 +994,11 @@ inline_mysql_file_ftell(
{ {
my_off_t result; my_off_t result;
#ifdef HAVE_PSI_FILE_INTERFACE #ifdef HAVE_PSI_FILE_INTERFACE
if (psi_likely(pfs_enabled))
{
struct PSI_file_locker *locker; struct PSI_file_locker *locker;
PSI_file_locker_state state; PSI_file_locker_state state;
locker= PSI_FILE_CALL(get_thread_file_stream_locker) locker= PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi, PSI_FILE_TELL);
(&state, file->m_psi, PSI_FILE_TELL);
if (likely(locker != NULL)) if (likely(locker != NULL))
{ {
PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line); PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
@@ -974,6 +1006,7 @@ inline_mysql_file_ftell(
PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0); PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
return result; return result;
} }
}
#endif #endif
result= my_ftell(file->m_file, flags); result= my_ftell(file->m_file, flags);
@@ -989,10 +1022,12 @@ inline_mysql_file_create(
{ {
File file; File file;
#ifdef HAVE_PSI_FILE_INTERFACE #ifdef HAVE_PSI_FILE_INTERFACE
if (psi_likely(pfs_enabled))
{
struct PSI_file_locker *locker; struct PSI_file_locker *locker;
PSI_file_locker_state state; PSI_file_locker_state state;
locker= PSI_FILE_CALL(get_thread_file_name_locker) locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_CREATE, filename,
(&state, key, PSI_FILE_CREATE, filename, &locker); &locker);
if (likely(locker != NULL)) if (likely(locker != NULL))
{ {
PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line); PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
@@ -1000,6 +1035,7 @@ inline_mysql_file_create(
PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file); PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file);
return file; return file;
} }
}
#endif #endif
file= my_create(filename, create_flags, access_flags, myFlags); file= my_create(filename, create_flags, access_flags, myFlags);
@@ -1035,10 +1071,12 @@ inline_mysql_file_open(
{ {
File file; File file;
#ifdef HAVE_PSI_FILE_INTERFACE #ifdef HAVE_PSI_FILE_INTERFACE
if (psi_likely(pfs_enabled))
{
struct PSI_file_locker *locker; struct PSI_file_locker *locker;
PSI_file_locker_state state; PSI_file_locker_state state;
locker= PSI_FILE_CALL(get_thread_file_name_locker) locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_OPEN, filename,
(&state, key, PSI_FILE_OPEN, filename, &locker); &locker);
if (likely(locker != NULL)) if (likely(locker != NULL))
{ {
PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line); PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
@@ -1046,6 +1084,7 @@ inline_mysql_file_open(
PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file); PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file);
return file; return file;
} }
}
#endif #endif
file= my_open(filename, flags, myFlags); file= my_open(filename, flags, myFlags);
@@ -1061,10 +1100,11 @@ inline_mysql_file_close(
{ {
int result; int result;
#ifdef HAVE_PSI_FILE_INTERFACE #ifdef HAVE_PSI_FILE_INTERFACE
if (psi_likely(pfs_enabled))
{
struct PSI_file_locker *locker; struct PSI_file_locker *locker;
PSI_file_locker_state state; PSI_file_locker_state state;
locker= PSI_FILE_CALL(get_thread_file_descriptor_locker) locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_CLOSE);
(&state, file, PSI_FILE_CLOSE);
if (likely(locker != NULL)) if (likely(locker != NULL))
{ {
PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line); PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
@@ -1072,6 +1112,7 @@ inline_mysql_file_close(
PSI_FILE_CALL(end_file_close_wait)(locker, result); PSI_FILE_CALL(end_file_close_wait)(locker, result);
return result; return result;
} }
}
#endif #endif
result= my_close(file, flags); result= my_close(file, flags);
@@ -1087,11 +1128,12 @@ inline_mysql_file_read(
{ {
size_t result; size_t result;
#ifdef HAVE_PSI_FILE_INTERFACE #ifdef HAVE_PSI_FILE_INTERFACE
if (psi_likely(pfs_enabled))
{
struct PSI_file_locker *locker; struct PSI_file_locker *locker;
PSI_file_locker_state state; PSI_file_locker_state state;
size_t bytes_read; size_t bytes_read;
locker= PSI_FILE_CALL(get_thread_file_descriptor_locker) locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_READ);
(&state, file, PSI_FILE_READ);
if (likely(locker != NULL)) if (likely(locker != NULL))
{ {
PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line); PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
@@ -1103,6 +1145,7 @@ inline_mysql_file_read(
PSI_FILE_CALL(end_file_wait)(locker, bytes_read); PSI_FILE_CALL(end_file_wait)(locker, bytes_read);
return result; return result;
} }
}
#endif #endif
result= my_read(file, buffer, count, flags); result= my_read(file, buffer, count, flags);
@@ -1118,11 +1161,12 @@ inline_mysql_file_write(
{ {
size_t result; size_t result;
#ifdef HAVE_PSI_FILE_INTERFACE #ifdef HAVE_PSI_FILE_INTERFACE
if (psi_likely(pfs_enabled))
{
struct PSI_file_locker *locker; struct PSI_file_locker *locker;
PSI_file_locker_state state; PSI_file_locker_state state;
size_t bytes_written; size_t bytes_written;
locker= PSI_FILE_CALL(get_thread_file_descriptor_locker) locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_WRITE);
(&state, file, PSI_FILE_WRITE);
if (likely(locker != NULL)) if (likely(locker != NULL))
{ {
PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line); PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
@@ -1134,6 +1178,7 @@ inline_mysql_file_write(
PSI_FILE_CALL(end_file_wait)(locker, bytes_written); PSI_FILE_CALL(end_file_wait)(locker, bytes_written);
return result; return result;
} }
}
#endif #endif
result= my_write(file, buffer, count, flags); result= my_write(file, buffer, count, flags);
@@ -1149,11 +1194,12 @@ inline_mysql_file_pread(
{ {
size_t result; size_t result;
#ifdef HAVE_PSI_FILE_INTERFACE #ifdef HAVE_PSI_FILE_INTERFACE
if (psi_likely(pfs_enabled))
{
struct PSI_file_locker *locker; struct PSI_file_locker *locker;
PSI_file_locker_state state; PSI_file_locker_state state;
size_t bytes_read; size_t bytes_read;
locker= PSI_FILE_CALL(get_thread_file_descriptor_locker) locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_READ);
(&state, file, PSI_FILE_READ);
if (likely(locker != NULL)) if (likely(locker != NULL))
{ {
PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line); PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
@@ -1165,6 +1211,7 @@ inline_mysql_file_pread(
PSI_FILE_CALL(end_file_wait)(locker, bytes_read); PSI_FILE_CALL(end_file_wait)(locker, bytes_read);
return result; return result;
} }
}
#endif #endif
result= my_pread(file, buffer, count, offset, flags); result= my_pread(file, buffer, count, offset, flags);
@@ -1180,11 +1227,12 @@ inline_mysql_file_pwrite(
{ {
size_t result; size_t result;
#ifdef HAVE_PSI_FILE_INTERFACE #ifdef HAVE_PSI_FILE_INTERFACE
if (psi_likely(pfs_enabled))
{
struct PSI_file_locker *locker; struct PSI_file_locker *locker;
PSI_file_locker_state state; PSI_file_locker_state state;
size_t bytes_written; size_t bytes_written;
locker= PSI_FILE_CALL(get_thread_file_descriptor_locker) locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_WRITE);
(&state, file, PSI_FILE_WRITE);
if (likely(locker != NULL)) if (likely(locker != NULL))
{ {
PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line); PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
@@ -1196,6 +1244,7 @@ inline_mysql_file_pwrite(
PSI_FILE_CALL(end_file_wait)(locker, bytes_written); PSI_FILE_CALL(end_file_wait)(locker, bytes_written);
return result; return result;
} }
}
#endif #endif
result= my_pwrite(file, buffer, count, offset, flags); result= my_pwrite(file, buffer, count, offset, flags);
@@ -1211,10 +1260,11 @@ inline_mysql_file_seek(
{ {
my_off_t result; my_off_t result;
#ifdef HAVE_PSI_FILE_INTERFACE #ifdef HAVE_PSI_FILE_INTERFACE
if (psi_likely(pfs_enabled))
{
struct PSI_file_locker *locker; struct PSI_file_locker *locker;
PSI_file_locker_state state; PSI_file_locker_state state;
locker= PSI_FILE_CALL(get_thread_file_descriptor_locker) locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_SEEK);
(&state, file, PSI_FILE_SEEK);
if (likely(locker != NULL)) if (likely(locker != NULL))
{ {
PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line); PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
@@ -1222,6 +1272,7 @@ inline_mysql_file_seek(
PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0); PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
return result; return result;
} }
}
#endif #endif
result= my_seek(file, pos, whence, flags); result= my_seek(file, pos, whence, flags);
@@ -1237,10 +1288,11 @@ inline_mysql_file_tell(
{ {
my_off_t result; my_off_t result;
#ifdef HAVE_PSI_FILE_INTERFACE #ifdef HAVE_PSI_FILE_INTERFACE
if (psi_likely(pfs_enabled))
{
struct PSI_file_locker *locker; struct PSI_file_locker *locker;
PSI_file_locker_state state; PSI_file_locker_state state;
locker= PSI_FILE_CALL(get_thread_file_descriptor_locker) locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_TELL);
(&state, file, PSI_FILE_TELL);
if (likely(locker != NULL)) if (likely(locker != NULL))
{ {
PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line); PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
@@ -1248,6 +1300,7 @@ inline_mysql_file_tell(
PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0); PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
return result; return result;
} }
}
#endif #endif
result= my_tell(file, flags); result= my_tell(file, flags);
@@ -1263,10 +1316,11 @@ inline_mysql_file_delete(
{ {
int result; int result;
#ifdef HAVE_PSI_FILE_INTERFACE #ifdef HAVE_PSI_FILE_INTERFACE
if (psi_likely(pfs_enabled))
{
struct PSI_file_locker *locker; struct PSI_file_locker *locker;
PSI_file_locker_state state; PSI_file_locker_state state;
locker= PSI_FILE_CALL(get_thread_file_name_locker) locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_DELETE, name, &locker);
(&state, key, PSI_FILE_DELETE, name, &locker);
if (likely(locker != NULL)) if (likely(locker != NULL))
{ {
PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line); PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
@@ -1274,6 +1328,7 @@ inline_mysql_file_delete(
PSI_FILE_CALL(end_file_close_wait)(locker, result); PSI_FILE_CALL(end_file_close_wait)(locker, result);
return result; return result;
} }
}
#endif #endif
result= my_delete(name, flags); result= my_delete(name, flags);
@@ -1289,10 +1344,11 @@ inline_mysql_file_rename(
{ {
int result; int result;
#ifdef HAVE_PSI_FILE_INTERFACE #ifdef HAVE_PSI_FILE_INTERFACE
if (psi_likely(pfs_enabled))
{
struct PSI_file_locker *locker; struct PSI_file_locker *locker;
PSI_file_locker_state state; PSI_file_locker_state state;
locker= PSI_FILE_CALL(get_thread_file_name_locker) locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_RENAME, to, &locker);
(&state, key, PSI_FILE_RENAME, to, &locker);
if (likely(locker != NULL)) if (likely(locker != NULL))
{ {
PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line); PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
@@ -1300,6 +1356,7 @@ inline_mysql_file_rename(
PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0); PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
return result; return result;
} }
}
#endif #endif
result= my_rename(from, to, flags); result= my_rename(from, to, flags);
@@ -1317,10 +1374,12 @@ inline_mysql_file_create_with_symlink(
{ {
File file; File file;
#ifdef HAVE_PSI_FILE_INTERFACE #ifdef HAVE_PSI_FILE_INTERFACE
if (psi_likely(pfs_enabled))
{
struct PSI_file_locker *locker; struct PSI_file_locker *locker;
PSI_file_locker_state state; PSI_file_locker_state state;
locker= PSI_FILE_CALL(get_thread_file_name_locker) locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_CREATE, filename,
(&state, key, PSI_FILE_CREATE, filename, &locker); &locker);
if (likely(locker != NULL)) if (likely(locker != NULL))
{ {
PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line); PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
@@ -1329,6 +1388,7 @@ inline_mysql_file_create_with_symlink(
PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file); PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file);
return file; return file;
} }
}
#endif #endif
file= my_create_with_symlink(linkname, filename, create_flags, access_flags, file= my_create_with_symlink(linkname, filename, create_flags, access_flags,
@@ -1348,10 +1408,12 @@ inline_mysql_file_delete_with_symlink(
char buf[FN_REFLEN]; char buf[FN_REFLEN];
char *fullname= fn_format(buf, name, "", ext, MY_UNPACK_FILENAME | MY_APPEND_EXT); char *fullname= fn_format(buf, name, "", ext, MY_UNPACK_FILENAME | MY_APPEND_EXT);
#ifdef HAVE_PSI_FILE_INTERFACE #ifdef HAVE_PSI_FILE_INTERFACE
if (psi_likely(pfs_enabled))
{
struct PSI_file_locker *locker; struct PSI_file_locker *locker;
PSI_file_locker_state state; PSI_file_locker_state state;
locker= PSI_FILE_CALL(get_thread_file_name_locker) locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_DELETE, fullname,
(&state, key, PSI_FILE_DELETE, fullname, &locker); &locker);
if (likely(locker != NULL)) if (likely(locker != NULL))
{ {
PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line); PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
@@ -1359,6 +1421,7 @@ inline_mysql_file_delete_with_symlink(
PSI_FILE_CALL(end_file_close_wait)(locker, result); PSI_FILE_CALL(end_file_close_wait)(locker, result);
return result; return result;
} }
}
#endif #endif
result= my_handler_delete_with_symlink(fullname, flags); result= my_handler_delete_with_symlink(fullname, flags);
@@ -1375,10 +1438,11 @@ inline_mysql_file_rename_with_symlink(
{ {
int result; int result;
#ifdef HAVE_PSI_FILE_INTERFACE #ifdef HAVE_PSI_FILE_INTERFACE
if (psi_likely(pfs_enabled))
{
struct PSI_file_locker *locker; struct PSI_file_locker *locker;
PSI_file_locker_state state; PSI_file_locker_state state;
locker= PSI_FILE_CALL(get_thread_file_name_locker) locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_RENAME, to, &locker);
(&state, key, PSI_FILE_RENAME, to, &locker);
if (likely(locker != NULL)) if (likely(locker != NULL))
{ {
PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line); PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
@@ -1386,6 +1450,7 @@ inline_mysql_file_rename_with_symlink(
PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0); PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
return result; return result;
} }
}
#endif #endif
result= my_rename_with_symlink(from, to, flags); result= my_rename_with_symlink(from, to, flags);
@@ -1401,10 +1466,11 @@ inline_mysql_file_sync(
{ {
int result= 0; int result= 0;
#ifdef HAVE_PSI_FILE_INTERFACE #ifdef HAVE_PSI_FILE_INTERFACE
if (psi_likely(pfs_enabled))
{
struct PSI_file_locker *locker; struct PSI_file_locker *locker;
PSI_file_locker_state state; PSI_file_locker_state state;
locker= PSI_FILE_CALL(get_thread_file_descriptor_locker) locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, fd, PSI_FILE_SYNC);
(&state, fd, PSI_FILE_SYNC);
if (likely(locker != NULL)) if (likely(locker != NULL))
{ {
PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line); PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
@@ -1412,6 +1478,7 @@ inline_mysql_file_sync(
PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0); PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
return result; return result;
} }
}
#endif #endif
result= my_sync(fd, flags); result= my_sync(fd, flags);

View File

@@ -82,7 +82,7 @@ inline_mysql_start_idle_wait(PSI_idle_locker_state *state,
static inline void static inline void
inline_mysql_end_idle_wait(struct PSI_idle_locker *locker) inline_mysql_end_idle_wait(struct PSI_idle_locker *locker)
{ {
if (likely(locker != NULL)) if (psi_likely(locker != NULL))
PSI_IDLE_CALL(end_idle_wait)(locker); PSI_IDLE_CALL(end_idle_wait)(locker);
} }
#endif #endif

View File

@@ -245,7 +245,7 @@ inline_mysql_start_socket_wait(PSI_socket_locker_state *state,
const char *src_file, uint src_line) const char *src_file, uint src_line)
{ {
struct PSI_socket_locker *locker; struct PSI_socket_locker *locker;
if (mysql_socket.m_psi != NULL) if (psi_likely(mysql_socket.m_psi != NULL))
{ {
locker= PSI_SOCKET_CALL(start_socket_wait) locker= PSI_SOCKET_CALL(start_socket_wait)
(state, mysql_socket.m_psi, op, byte_count, src_file, src_line); (state, mysql_socket.m_psi, op, byte_count, src_file, src_line);
@@ -262,7 +262,7 @@ inline_mysql_start_socket_wait(PSI_socket_locker_state *state,
static inline void static inline void
inline_mysql_end_socket_wait(struct PSI_socket_locker *locker, size_t byte_count) inline_mysql_end_socket_wait(struct PSI_socket_locker *locker, size_t byte_count)
{ {
if (locker != NULL) if (psi_likely(locker != NULL))
PSI_SOCKET_CALL(end_socket_wait)(locker, byte_count); PSI_SOCKET_CALL(end_socket_wait)(locker, byte_count);
} }
@@ -577,7 +577,7 @@ inline_mysql_socket_bind
int result; int result;
#ifdef HAVE_PSI_SOCKET_INTERFACE #ifdef HAVE_PSI_SOCKET_INTERFACE
if (mysql_socket.m_psi != NULL) if (psi_likely(mysql_socket.m_psi != NULL))
{ {
/* Instrumentation start */ /* Instrumentation start */
PSI_socket_locker_state state; PSI_socket_locker_state state;
@@ -617,7 +617,7 @@ inline_mysql_socket_getsockname
int result; int result;
#ifdef HAVE_PSI_SOCKET_INTERFACE #ifdef HAVE_PSI_SOCKET_INTERFACE
if (mysql_socket.m_psi != NULL) if (psi_likely(mysql_socket.m_psi != NULL))
{ {
/* Instrumentation start */ /* Instrumentation start */
PSI_socket_locker *locker; PSI_socket_locker *locker;
@@ -655,7 +655,7 @@ inline_mysql_socket_connect
int result; int result;
#ifdef HAVE_PSI_SOCKET_INTERFACE #ifdef HAVE_PSI_SOCKET_INTERFACE
if (mysql_socket.m_psi != NULL) if (psi_likely(mysql_socket.m_psi != NULL))
{ {
/* Instrumentation start */ /* Instrumentation start */
PSI_socket_locker *locker; PSI_socket_locker *locker;
@@ -693,7 +693,7 @@ inline_mysql_socket_getpeername
int result; int result;
#ifdef HAVE_PSI_SOCKET_INTERFACE #ifdef HAVE_PSI_SOCKET_INTERFACE
if (mysql_socket.m_psi != NULL) if (psi_likely(mysql_socket.m_psi != NULL))
{ {
/* Instrumentation start */ /* Instrumentation start */
PSI_socket_locker *locker; PSI_socket_locker *locker;
@@ -731,7 +731,7 @@ inline_mysql_socket_send
ssize_t result; ssize_t result;
#ifdef HAVE_PSI_SOCKET_INTERFACE #ifdef HAVE_PSI_SOCKET_INTERFACE
if (mysql_socket.m_psi != NULL) if (psi_likely(mysql_socket.m_psi != NULL))
{ {
/* Instrumentation start */ /* Instrumentation start */
PSI_socket_locker *locker; PSI_socket_locker *locker;
@@ -772,7 +772,7 @@ inline_mysql_socket_recv
ssize_t result; ssize_t result;
#ifdef HAVE_PSI_SOCKET_INTERFACE #ifdef HAVE_PSI_SOCKET_INTERFACE
if (mysql_socket.m_psi != NULL) if (psi_likely(mysql_socket.m_psi != NULL))
{ {
/* Instrumentation start */ /* Instrumentation start */
PSI_socket_locker *locker; PSI_socket_locker *locker;
@@ -813,7 +813,7 @@ inline_mysql_socket_sendto
ssize_t result; ssize_t result;
#ifdef HAVE_PSI_SOCKET_INTERFACE #ifdef HAVE_PSI_SOCKET_INTERFACE
if (mysql_socket.m_psi != NULL) if (psi_likely(mysql_socket.m_psi != NULL))
{ {
/* Instrumentation start */ /* Instrumentation start */
PSI_socket_locker *locker; PSI_socket_locker *locker;
@@ -855,7 +855,7 @@ inline_mysql_socket_recvfrom
ssize_t result; ssize_t result;
#ifdef HAVE_PSI_SOCKET_INTERFACE #ifdef HAVE_PSI_SOCKET_INTERFACE
if (mysql_socket.m_psi != NULL) if (psi_likely(mysql_socket.m_psi != NULL))
{ {
/* Instrumentation start */ /* Instrumentation start */
PSI_socket_locker *locker; PSI_socket_locker *locker;
@@ -896,7 +896,7 @@ inline_mysql_socket_getsockopt
int result; int result;
#ifdef HAVE_PSI_SOCKET_INTERFACE #ifdef HAVE_PSI_SOCKET_INTERFACE
if (mysql_socket.m_psi != NULL) if (psi_likely(mysql_socket.m_psi != NULL))
{ {
/* Instrumentation start */ /* Instrumentation start */
PSI_socket_locker *locker; PSI_socket_locker *locker;
@@ -935,7 +935,7 @@ inline_mysql_socket_setsockopt
int result; int result;
#ifdef HAVE_PSI_SOCKET_INTERFACE #ifdef HAVE_PSI_SOCKET_INTERFACE
if (mysql_socket.m_psi) if (psi_likely(mysql_socket.m_psi))
{ {
/* Instrumentation start */ /* Instrumentation start */
PSI_socket_locker *locker; PSI_socket_locker *locker;
@@ -973,7 +973,7 @@ inline_mysql_socket_listen
int result; int result;
#ifdef HAVE_PSI_SOCKET_INTERFACE #ifdef HAVE_PSI_SOCKET_INTERFACE
if (mysql_socket.m_psi != NULL) if (psi_likely(mysql_socket.m_psi != NULL))
{ {
/* Instrumentation start */ /* Instrumentation start */
PSI_socket_locker *locker; PSI_socket_locker *locker;
@@ -1087,7 +1087,7 @@ inline_mysql_socket_close
int result; int result;
#ifdef HAVE_PSI_SOCKET_INTERFACE #ifdef HAVE_PSI_SOCKET_INTERFACE
if (mysql_socket.m_psi != NULL) if (psi_likely(mysql_socket.m_psi != NULL))
{ {
/* Instrumentation start */ /* Instrumentation start */
PSI_socket_locker *locker; PSI_socket_locker *locker;
@@ -1142,7 +1142,7 @@ inline_mysql_socket_shutdown
/* Instrumentation start */ /* Instrumentation start */
#ifdef HAVE_PSI_SOCKET_INTERFACE #ifdef HAVE_PSI_SOCKET_INTERFACE
if (mysql_socket.m_psi != NULL) if (psi_likely(mysql_socket.m_psi != NULL))
{ {
PSI_socket_locker *locker; PSI_socket_locker *locker;
PSI_socket_locker_state state; PSI_socket_locker_state state;

View File

@@ -127,7 +127,7 @@ inline_mysql_digest_start(PSI_statement_locker *locker)
{ {
PSI_digest_locker* digest_locker= NULL; PSI_digest_locker* digest_locker= NULL;
if (likely(locker != NULL)) if (psi_likely(locker != NULL))
digest_locker= PSI_DIGEST_CALL(digest_start)(locker); digest_locker= PSI_DIGEST_CALL(digest_start)(locker);
return digest_locker; return digest_locker;
} }
@@ -137,7 +137,7 @@ inline_mysql_digest_start(PSI_statement_locker *locker)
static inline void static inline void
inline_mysql_digest_end(PSI_digest_locker *locker, const sql_digest_storage *digest) inline_mysql_digest_end(PSI_digest_locker *locker, const sql_digest_storage *digest)
{ {
if (likely(locker != NULL)) if (psi_likely(locker != NULL))
PSI_DIGEST_CALL(digest_end)(locker, digest); PSI_DIGEST_CALL(digest_end)(locker, digest);
} }
#endif #endif
@@ -151,7 +151,7 @@ inline_mysql_start_statement(PSI_statement_locker_state *state,
{ {
PSI_statement_locker *locker; PSI_statement_locker *locker;
locker= PSI_STATEMENT_CALL(get_thread_statement_locker)(state, key, charset); locker= PSI_STATEMENT_CALL(get_thread_statement_locker)(state, key, charset);
if (likely(locker != NULL)) if (psi_likely(locker != NULL))
PSI_STATEMENT_CALL(start_statement)(locker, db, (uint)db_len, src_file, src_line); PSI_STATEMENT_CALL(start_statement)(locker, db, (uint)db_len, src_file, src_line);
return locker; return locker;
} }
@@ -160,7 +160,7 @@ static inline struct PSI_statement_locker *
inline_mysql_refine_statement(PSI_statement_locker *locker, inline_mysql_refine_statement(PSI_statement_locker *locker,
PSI_statement_key key) PSI_statement_key key)
{ {
if (likely(locker != NULL)) if (psi_likely(locker != NULL))
{ {
locker= PSI_STATEMENT_CALL(refine_statement)(locker, key); locker= PSI_STATEMENT_CALL(refine_statement)(locker, key);
} }
@@ -171,7 +171,7 @@ static inline void
inline_mysql_set_statement_text(PSI_statement_locker *locker, inline_mysql_set_statement_text(PSI_statement_locker *locker,
const char *text, uint text_len) const char *text, uint text_len)
{ {
if (likely(locker != NULL)) if (psi_likely(locker != NULL))
{ {
PSI_STATEMENT_CALL(set_statement_text)(locker, text, text_len); PSI_STATEMENT_CALL(set_statement_text)(locker, text, text_len);
} }
@@ -181,7 +181,7 @@ static inline void
inline_mysql_set_statement_lock_time(PSI_statement_locker *locker, inline_mysql_set_statement_lock_time(PSI_statement_locker *locker,
ulonglong count) ulonglong count)
{ {
if (likely(locker != NULL)) if (psi_likely(locker != NULL))
{ {
PSI_STATEMENT_CALL(set_statement_lock_time)(locker, count); PSI_STATEMENT_CALL(set_statement_lock_time)(locker, count);
} }
@@ -191,7 +191,7 @@ static inline void
inline_mysql_set_statement_rows_sent(PSI_statement_locker *locker, inline_mysql_set_statement_rows_sent(PSI_statement_locker *locker,
ulonglong count) ulonglong count)
{ {
if (likely(locker != NULL)) if (psi_likely(locker != NULL))
{ {
PSI_STATEMENT_CALL(set_statement_rows_sent)(locker, count); PSI_STATEMENT_CALL(set_statement_rows_sent)(locker, count);
} }
@@ -201,7 +201,7 @@ static inline void
inline_mysql_set_statement_rows_examined(PSI_statement_locker *locker, inline_mysql_set_statement_rows_examined(PSI_statement_locker *locker,
ulonglong count) ulonglong count)
{ {
if (likely(locker != NULL)) if (psi_likely(locker != NULL))
{ {
PSI_STATEMENT_CALL(set_statement_rows_examined)(locker, count); PSI_STATEMENT_CALL(set_statement_rows_examined)(locker, count);
} }
@@ -212,7 +212,7 @@ inline_mysql_end_statement(struct PSI_statement_locker *locker,
Diagnostics_area *stmt_da) Diagnostics_area *stmt_da)
{ {
PSI_STAGE_CALL(end_stage)(); PSI_STAGE_CALL(end_stage)();
if (likely(locker != NULL)) if (psi_likely(locker != NULL))
PSI_STATEMENT_CALL(end_statement)(locker, stmt_da); PSI_STATEMENT_CALL(end_statement)(locker, stmt_da);
} }
#endif #endif

View File

@@ -87,7 +87,7 @@
#ifdef HAVE_PSI_TABLE_INTERFACE #ifdef HAVE_PSI_TABLE_INTERFACE
#define MYSQL_TABLE_IO_WAIT(PSI, OP, INDEX, FLAGS, PAYLOAD) \ #define MYSQL_TABLE_IO_WAIT(PSI, OP, INDEX, FLAGS, PAYLOAD) \
{ \ { \
if (PSI != NULL) \ if (psi_likely(PSI != NULL)) \
{ \ { \
PSI_table_locker *locker; \ PSI_table_locker *locker; \
PSI_table_locker_state state; \ PSI_table_locker_state state; \
@@ -120,7 +120,7 @@
#ifdef HAVE_PSI_TABLE_INTERFACE #ifdef HAVE_PSI_TABLE_INTERFACE
#define MYSQL_TABLE_LOCK_WAIT(PSI, OP, FLAGS, PAYLOAD) \ #define MYSQL_TABLE_LOCK_WAIT(PSI, OP, FLAGS, PAYLOAD) \
{ \ { \
if (PSI != NULL) \ if (psi_likely(PSI != NULL)) \
{ \ { \
PSI_table_locker *locker; \ PSI_table_locker *locker; \
PSI_table_locker_state state; \ PSI_table_locker_state state; \
@@ -186,7 +186,7 @@ inline_mysql_start_table_lock_wait(PSI_table_locker_state *state,
enum PSI_table_lock_operation op, enum PSI_table_lock_operation op,
ulong flags, const char *src_file, uint src_line) ulong flags, const char *src_file, uint src_line)
{ {
if (psi != NULL) if (psi_likely(psi != NULL))
{ {
struct PSI_table_locker *locker; struct PSI_table_locker *locker;
locker= PSI_TABLE_CALL(start_table_lock_wait) locker= PSI_TABLE_CALL(start_table_lock_wait)
@@ -203,7 +203,7 @@ inline_mysql_start_table_lock_wait(PSI_table_locker_state *state,
static inline void static inline void
inline_mysql_end_table_lock_wait(struct PSI_table_locker *locker) inline_mysql_end_table_lock_wait(struct PSI_table_locker *locker)
{ {
if (locker != NULL) if (psi_likely(locker != NULL))
PSI_TABLE_CALL(end_table_lock_wait)(locker); PSI_TABLE_CALL(end_table_lock_wait)(locker);
} }
#endif #endif

View File

@@ -682,7 +682,7 @@ static inline int inline_mysql_mutex_lock(
int result; int result;
#ifdef HAVE_PSI_MUTEX_INTERFACE #ifdef HAVE_PSI_MUTEX_INTERFACE
if (that->m_psi != NULL) if (psi_likely(that->m_psi != NULL))
{ {
/* Instrumentation start */ /* Instrumentation start */
PSI_mutex_locker *locker; PSI_mutex_locker *locker;
@@ -725,7 +725,7 @@ static inline int inline_mysql_mutex_trylock(
int result; int result;
#ifdef HAVE_PSI_MUTEX_INTERFACE #ifdef HAVE_PSI_MUTEX_INTERFACE
if (that->m_psi != NULL) if (psi_likely(that->m_psi != NULL))
{ {
/* Instrumentation start */ /* Instrumentation start */
PSI_mutex_locker *locker; PSI_mutex_locker *locker;
@@ -768,7 +768,7 @@ static inline int inline_mysql_mutex_unlock(
int result; int result;
#ifdef HAVE_PSI_MUTEX_INTERFACE #ifdef HAVE_PSI_MUTEX_INTERFACE
if (that->m_psi != NULL) if (psi_likely(that->m_psi != NULL))
PSI_MUTEX_CALL(unlock_mutex)(that->m_psi); PSI_MUTEX_CALL(unlock_mutex)(that->m_psi);
#endif #endif
@@ -835,7 +835,7 @@ static inline int inline_mysql_rwlock_destroy(
mysql_rwlock_t *that) mysql_rwlock_t *that)
{ {
#ifdef HAVE_PSI_RWLOCK_INTERFACE #ifdef HAVE_PSI_RWLOCK_INTERFACE
if (that->m_psi != NULL) if (psi_likely(that->m_psi != NULL))
{ {
PSI_RWLOCK_CALL(destroy_rwlock)(that->m_psi); PSI_RWLOCK_CALL(destroy_rwlock)(that->m_psi);
that->m_psi= NULL; that->m_psi= NULL;
@@ -849,7 +849,7 @@ static inline int inline_mysql_prlock_destroy(
mysql_prlock_t *that) mysql_prlock_t *that)
{ {
#ifdef HAVE_PSI_RWLOCK_INTERFACE #ifdef HAVE_PSI_RWLOCK_INTERFACE
if (that->m_psi != NULL) if (psi_likely(that->m_psi != NULL))
{ {
PSI_RWLOCK_CALL(destroy_rwlock)(that->m_psi); PSI_RWLOCK_CALL(destroy_rwlock)(that->m_psi);
that->m_psi= NULL; that->m_psi= NULL;
@@ -869,7 +869,7 @@ static inline int inline_mysql_rwlock_rdlock(
int result; int result;
#ifdef HAVE_PSI_RWLOCK_INTERFACE #ifdef HAVE_PSI_RWLOCK_INTERFACE
if (that->m_psi != NULL) if (psi_likely(that->m_psi != NULL))
{ {
/* Instrumentation start */ /* Instrumentation start */
PSI_rwlock_locker *locker; PSI_rwlock_locker *locker;
@@ -905,7 +905,7 @@ static inline int inline_mysql_prlock_rdlock(
int result; int result;
#ifdef HAVE_PSI_RWLOCK_INTERFACE #ifdef HAVE_PSI_RWLOCK_INTERFACE
if (that->m_psi != NULL) if (psi_likely(that->m_psi != NULL))
{ {
/* Instrumentation start */ /* Instrumentation start */
PSI_rwlock_locker *locker; PSI_rwlock_locker *locker;
@@ -941,7 +941,7 @@ static inline int inline_mysql_rwlock_wrlock(
int result; int result;
#ifdef HAVE_PSI_RWLOCK_INTERFACE #ifdef HAVE_PSI_RWLOCK_INTERFACE
if (that->m_psi != NULL) if (psi_likely(that->m_psi != NULL))
{ {
/* Instrumentation start */ /* Instrumentation start */
PSI_rwlock_locker *locker; PSI_rwlock_locker *locker;
@@ -977,7 +977,7 @@ static inline int inline_mysql_prlock_wrlock(
int result; int result;
#ifdef HAVE_PSI_RWLOCK_INTERFACE #ifdef HAVE_PSI_RWLOCK_INTERFACE
if (that->m_psi != NULL) if (psi_likely(that->m_psi != NULL))
{ {
/* Instrumentation start */ /* Instrumentation start */
PSI_rwlock_locker *locker; PSI_rwlock_locker *locker;
@@ -1013,7 +1013,7 @@ static inline int inline_mysql_rwlock_tryrdlock(
int result; int result;
#ifdef HAVE_PSI_RWLOCK_INTERFACE #ifdef HAVE_PSI_RWLOCK_INTERFACE
if (that->m_psi != NULL) if (psi_likely(that->m_psi != NULL))
{ {
/* Instrumentation start */ /* Instrumentation start */
PSI_rwlock_locker *locker; PSI_rwlock_locker *locker;
@@ -1048,7 +1048,7 @@ static inline int inline_mysql_rwlock_trywrlock(
int result; int result;
#ifdef HAVE_PSI_RWLOCK_INTERFACE #ifdef HAVE_PSI_RWLOCK_INTERFACE
if (that->m_psi != NULL) if (psi_likely(that->m_psi != NULL))
{ {
/* Instrumentation start */ /* Instrumentation start */
PSI_rwlock_locker *locker; PSI_rwlock_locker *locker;
@@ -1078,7 +1078,7 @@ static inline int inline_mysql_rwlock_unlock(
{ {
int result; int result;
#ifdef HAVE_PSI_RWLOCK_INTERFACE #ifdef HAVE_PSI_RWLOCK_INTERFACE
if (that->m_psi != NULL) if (psi_likely(that->m_psi != NULL))
PSI_RWLOCK_CALL(unlock_rwlock)(that->m_psi); PSI_RWLOCK_CALL(unlock_rwlock)(that->m_psi);
#endif #endif
result= rw_unlock(&that->m_rwlock); result= rw_unlock(&that->m_rwlock);
@@ -1091,7 +1091,7 @@ static inline int inline_mysql_prlock_unlock(
{ {
int result; int result;
#ifdef HAVE_PSI_RWLOCK_INTERFACE #ifdef HAVE_PSI_RWLOCK_INTERFACE
if (that->m_psi != NULL) if (psi_likely(that->m_psi != NULL))
PSI_RWLOCK_CALL(unlock_rwlock)(that->m_psi); PSI_RWLOCK_CALL(unlock_rwlock)(that->m_psi);
#endif #endif
result= rw_pr_unlock(&that->m_prlock); result= rw_pr_unlock(&that->m_prlock);
@@ -1135,7 +1135,7 @@ static inline int inline_mysql_cond_destroy(
mysql_cond_t *that) mysql_cond_t *that)
{ {
#ifdef HAVE_PSI_COND_INTERFACE #ifdef HAVE_PSI_COND_INTERFACE
if (that->m_psi != NULL) if (psi_likely(that->m_psi != NULL))
{ {
PSI_COND_CALL(destroy_cond)(that->m_psi); PSI_COND_CALL(destroy_cond)(that->m_psi);
that->m_psi= NULL; that->m_psi= NULL;
@@ -1155,7 +1155,7 @@ static inline int inline_mysql_cond_wait(
int result; int result;
#ifdef HAVE_PSI_COND_INTERFACE #ifdef HAVE_PSI_COND_INTERFACE
if (that->m_psi != NULL) if (psi_likely(that->m_psi != NULL))
{ {
/* Instrumentation start */ /* Instrumentation start */
PSI_cond_locker *locker; PSI_cond_locker *locker;
@@ -1192,7 +1192,7 @@ static inline int inline_mysql_cond_timedwait(
int result; int result;
#ifdef HAVE_PSI_COND_INTERFACE #ifdef HAVE_PSI_COND_INTERFACE
if (that->m_psi != NULL) if (psi_likely(that->m_psi != NULL))
{ {
/* Instrumentation start */ /* Instrumentation start */
PSI_cond_locker *locker; PSI_cond_locker *locker;
@@ -1204,7 +1204,7 @@ static inline int inline_mysql_cond_timedwait(
result= my_cond_timedwait(&that->m_cond, &mutex->m_mutex, abstime); result= my_cond_timedwait(&that->m_cond, &mutex->m_mutex, abstime);
/* Instrumentation end */ /* Instrumentation end */
if (locker != NULL) if (psi_likely(locker != NULL))
PSI_COND_CALL(end_cond_wait)(locker, result); PSI_COND_CALL(end_cond_wait)(locker, result);
return result; return result;
@@ -1222,7 +1222,7 @@ static inline int inline_mysql_cond_signal(
{ {
int result; int result;
#ifdef HAVE_PSI_COND_INTERFACE #ifdef HAVE_PSI_COND_INTERFACE
if (that->m_psi != NULL) if (psi_likely(that->m_psi != NULL))
PSI_COND_CALL(signal_cond)(that->m_psi); PSI_COND_CALL(signal_cond)(that->m_psi);
#endif #endif
result= pthread_cond_signal(&that->m_cond); result= pthread_cond_signal(&that->m_cond);
@@ -1234,7 +1234,7 @@ static inline int inline_mysql_cond_broadcast(
{ {
int result; int result;
#ifdef HAVE_PSI_COND_INTERFACE #ifdef HAVE_PSI_COND_INTERFACE
if (that->m_psi != NULL) if (psi_likely(that->m_psi != NULL))
PSI_COND_CALL(broadcast_cond)(that->m_psi); PSI_COND_CALL(broadcast_cond)(that->m_psi);
#endif #endif
result= pthread_cond_broadcast(&that->m_cond); result= pthread_cond_broadcast(&that->m_cond);

View File

@@ -40,6 +40,21 @@
#error "You must include my_global.h in the code for the build to be correct." #error "You must include my_global.h in the code for the build to be correct."
#endif #endif
/*
If PSI_ON_BY_DFAULT is defined, assume PSI will be enabled by default and
optimize jumps testing for PSI this case. If not, optimize the binary for
that PSI is not enabled
*/
#ifdef PSI_ON_BY_DEFAULT
#define psi_likely(A) likely(A)
#define psi_unlikely(A) unlikely(A)
#else
#define psi_likely(A) unlikely(A)
#define psi_unlikely(A) likely(A)
#endif
C_MODE_START C_MODE_START
struct TABLE_SHARE; struct TABLE_SHARE;
@@ -2346,6 +2361,7 @@ typedef struct PSI_stage_info_none PSI_stage_info;
#endif /* HAVE_PSI_INTERFACE */ #endif /* HAVE_PSI_INTERFACE */
extern MYSQL_PLUGIN_IMPORT my_bool pfs_enabled;
extern MYSQL_PLUGIN_IMPORT PSI *PSI_server; extern MYSQL_PLUGIN_IMPORT PSI *PSI_server;
/* /*

View File

@@ -616,5 +616,6 @@ typedef struct PSI_file_locker_state_v1 PSI_file_locker_state;
typedef struct PSI_table_locker_state_v1 PSI_table_locker_state; typedef struct PSI_table_locker_state_v1 PSI_table_locker_state;
typedef struct PSI_statement_locker_state_v1 PSI_statement_locker_state; typedef struct PSI_statement_locker_state_v1 PSI_statement_locker_state;
typedef struct PSI_socket_locker_state_v1 PSI_socket_locker_state; typedef struct PSI_socket_locker_state_v1 PSI_socket_locker_state;
extern MYSQL_PLUGIN_IMPORT my_bool pfs_enabled;
extern MYSQL_PLUGIN_IMPORT PSI *PSI_server; extern MYSQL_PLUGIN_IMPORT PSI *PSI_server;
C_MODE_END C_MODE_END

View File

@@ -209,5 +209,6 @@ typedef struct PSI_file_locker_state_v2 PSI_file_locker_state;
typedef struct PSI_table_locker_state_v2 PSI_table_locker_state; typedef struct PSI_table_locker_state_v2 PSI_table_locker_state;
typedef struct PSI_statement_locker_state_v2 PSI_statement_locker_state; typedef struct PSI_statement_locker_state_v2 PSI_statement_locker_state;
typedef struct PSI_socket_locker_state_v2 PSI_socket_locker_state; typedef struct PSI_socket_locker_state_v2 PSI_socket_locker_state;
extern MYSQL_PLUGIN_IMPORT my_bool pfs_enabled;
extern MYSQL_PLUGIN_IMPORT PSI *PSI_server; extern MYSQL_PLUGIN_IMPORT PSI *PSI_server;
C_MODE_END C_MODE_END

View File

@@ -227,7 +227,7 @@ int logger_printf(LOGGER_HANDLE *log, const char *fmt, ...)
void logger_init_mutexes() void logger_init_mutexes()
{ {
#ifdef HAVE_PSI_INTERFACE #ifdef HAVE_PSI_INTERFACE
if (PSI_server) if (unlikely(PSI_server))
PSI_server->register_mutex("sql_logger", mutex_list, 1); PSI_server->register_mutex("sql_logger", mutex_list, 1);
#endif #endif
} }

View File

@@ -121,14 +121,14 @@ static LIKELY_ENTRY *my_likely_find(const char *file_name, uint line)
{ {
char key[80], *pos; char key[80], *pos;
LIKELY_ENTRY *entry; LIKELY_ENTRY *entry;
uint length; size_t length;
if (!likely_inited) if (!likely_inited)
return 0; return 0;
pos= strnmov(key, file_name, sizeof(key)-4); pos= strnmov(key, file_name, sizeof(key)-4);
int3store(pos+1, line); int3store(pos+1, line);
length= (pos-key)+4; length= (size_t) (pos-key)+4;
pthread_mutex_lock(&likely_mutex); pthread_mutex_lock(&likely_mutex);
if (!(entry= (LIKELY_ENTRY*) my_hash_search(&likely_hash, (uchar*) key, if (!(entry= (LIKELY_ENTRY*) my_hash_search(&likely_hash, (uchar*) key,

View File

@@ -763,6 +763,13 @@ struct PSI_bootstrap *PSI_hook= NULL;
PSI *PSI_server= & PSI_noop; PSI *PSI_server= & PSI_noop;
/**
Global performance schema flag.
Indicate if the performance schema is enabled.
This flag is set at startup, and never changes.
*/
my_bool pfs_enabled= FALSE;
void set_psi_server(PSI *psi) void set_psi_server(PSI *psi)
{ {
PSI_server= psi; PSI_server= psi;

View File

@@ -1615,6 +1615,14 @@ open_table_v1(PSI_table_share *share, const void *identity)
{ {
PFS_table_share *pfs_table_share= reinterpret_cast<PFS_table_share*> (share); PFS_table_share *pfs_table_share= reinterpret_cast<PFS_table_share*> (share);
/*
When the performance schema is off, do not instrument anything.
Table handles have short life cycle, instrumentation will happen
again if needed during the next open().
*/
if (psi_unlikely(! flag_global_instrumentation))
return NULL;
if (unlikely(pfs_table_share == NULL)) if (unlikely(pfs_table_share == NULL))
return NULL; return NULL;
@@ -1626,14 +1634,6 @@ open_table_v1(PSI_table_share *share, const void *identity)
if (! global_table_io_class.m_enabled && ! global_table_lock_class.m_enabled) if (! global_table_io_class.m_enabled && ! global_table_lock_class.m_enabled)
return NULL; return NULL;
/*
When the performance schema is off, do not instrument anything.
Table handles have short life cycle, instrumentation will happen
again if needed during the next open().
*/
if (! flag_global_instrumentation)
return NULL;
PFS_thread *thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS); PFS_thread *thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
if (unlikely(thread == NULL)) if (unlikely(thread == NULL))
return NULL; return NULL;
@@ -1668,6 +1668,12 @@ rebind_table_v1(PSI_table_share *share, const void *identity, PSI_table *table)
PFS_thread *thread; PFS_thread *thread;
DBUG_ASSERT(pfs->m_thread_owner == NULL); DBUG_ASSERT(pfs->m_thread_owner == NULL);
if (psi_unlikely(! flag_global_instrumentation))
{
destroy_table(pfs);
return NULL;
}
/* The table handle was already instrumented, reuse it for this thread. */ /* The table handle was already instrumented, reuse it for this thread. */
thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS); thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
@@ -1683,16 +1689,13 @@ rebind_table_v1(PSI_table_share *share, const void *identity, PSI_table *table)
return NULL; return NULL;
} }
if (unlikely(! flag_global_instrumentation))
{
destroy_table(pfs);
return NULL;
}
pfs->m_thread_owner= thread; pfs->m_thread_owner= thread;
return table; return table;
} }
if (psi_unlikely(! flag_global_instrumentation))
return NULL;
/* See open_table_v1() */ /* See open_table_v1() */
PFS_table_share *pfs_table_share= reinterpret_cast<PFS_table_share*> (share); PFS_table_share *pfs_table_share= reinterpret_cast<PFS_table_share*> (share);
@@ -1706,9 +1709,6 @@ rebind_table_v1(PSI_table_share *share, const void *identity, PSI_table *table)
if (! global_table_io_class.m_enabled && ! global_table_lock_class.m_enabled) if (! global_table_io_class.m_enabled && ! global_table_lock_class.m_enabled)
return NULL; return NULL;
if (! flag_global_instrumentation)
return NULL;
PFS_thread *thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS); PFS_thread *thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
if (unlikely(thread == NULL)) if (unlikely(thread == NULL))
return NULL; return NULL;
@@ -1760,7 +1760,7 @@ static void destroy_socket_v1(PSI_socket *socket)
*/ */
static void create_file_v1(PSI_file_key key, const char *name, File file) static void create_file_v1(PSI_file_key key, const char *name, File file)
{ {
if (! flag_global_instrumentation) if (psi_unlikely(! flag_global_instrumentation))
return; return;
int index= (int) file; int index= (int) file;
if (unlikely(index < 0)) if (unlikely(index < 0))
@@ -2783,7 +2783,7 @@ get_thread_file_name_locker_v1(PSI_file_locker_state *state,
DBUG_ASSERT(static_cast<uint> (op) < array_elements(file_operation_map)); DBUG_ASSERT(static_cast<uint> (op) < array_elements(file_operation_map));
DBUG_ASSERT(state != NULL); DBUG_ASSERT(state != NULL);
if (! flag_global_instrumentation) if (psi_unlikely(! flag_global_instrumentation))
return NULL; return NULL;
PFS_file_class *klass= find_file_class(key); PFS_file_class *klass= find_file_class(key);
if (unlikely(klass == NULL)) if (unlikely(klass == NULL))
@@ -3316,7 +3316,7 @@ start_idle_wait_v1(PSI_idle_locker_state* state, const char *src_file, uint src_
{ {
DBUG_ASSERT(state != NULL); DBUG_ASSERT(state != NULL);
if (!flag_global_instrumentation) if (psi_unlikely(! flag_global_instrumentation))
return NULL; return NULL;
if (!global_idle_class.m_enabled) if (!global_idle_class.m_enabled)
@@ -4253,7 +4253,7 @@ static void start_stage_v1(PSI_stage_key key, const char *src_file, int src_line
/* Always update column threads.processlist_state. */ /* Always update column threads.processlist_state. */
pfs_thread->m_stage= key; pfs_thread->m_stage= key;
if (! flag_global_instrumentation) if (psi_unlikely(! flag_global_instrumentation))
return; return;
if (flag_thread_instrumentation && ! pfs_thread->m_enabled) if (flag_thread_instrumentation && ! pfs_thread->m_enabled)
@@ -4353,7 +4353,7 @@ static void end_stage_v1()
pfs_thread->m_stage= 0; pfs_thread->m_stage= 0;
if (! flag_global_instrumentation) if (psi_unlikely(! flag_global_instrumentation))
return; return;
if (flag_thread_instrumentation && ! pfs_thread->m_enabled) if (flag_thread_instrumentation && ! pfs_thread->m_enabled)
@@ -4412,7 +4412,7 @@ get_thread_statement_locker_v1(PSI_statement_locker_state *state,
DBUG_ASSERT(state != NULL); DBUG_ASSERT(state != NULL);
DBUG_ASSERT(charset != NULL); DBUG_ASSERT(charset != NULL);
if (! flag_global_instrumentation) if (psi_unlikely(! flag_global_instrumentation))
return NULL; return NULL;
PFS_statement_class *klass= find_statement_class(key); PFS_statement_class *klass= find_statement_class(key);
if (unlikely(klass == NULL)) if (unlikely(klass == NULL))

View File

@@ -40,13 +40,6 @@
@{ @{
*/ */
/**
Global performance schema flag.
Indicate if the performance schema is enabled.
This flag is set at startup, and never changes.
*/
my_bool pfs_enabled= TRUE;
/** /**
PFS_INSTRUMENT option settings array and associated state variable to PFS_INSTRUMENT option settings array and associated state variable to
serialize access during shutdown. serialize access during shutdown.