diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/hash.h | 2 | ||||
-rw-r--r-- | include/heap.h | 2 | ||||
-rw-r--r-- | include/m_ctype.h | 2 | ||||
-rw-r--r-- | include/maria.h | 2 | ||||
-rw-r--r-- | include/my_base.h | 2 | ||||
-rw-r--r-- | include/my_dir.h | 2 | ||||
-rw-r--r-- | include/my_global.h | 50 | ||||
-rw-r--r-- | include/my_sys.h | 21 | ||||
-rw-r--r-- | include/my_time.h | 3 | ||||
-rw-r--r-- | include/myisam.h | 13 | ||||
-rw-r--r-- | include/mysql/psi/mysql_file.h | 707 | ||||
-rw-r--r-- | include/mysql/psi/mysql_idle.h | 2 | ||||
-rw-r--r-- | include/mysql/psi/mysql_socket.h | 30 | ||||
-rw-r--r-- | include/mysql/psi/mysql_statement.h | 18 | ||||
-rw-r--r-- | include/mysql/psi/mysql_table.h | 8 | ||||
-rw-r--r-- | include/mysql/psi/mysql_thread.h | 38 | ||||
-rw-r--r-- | include/mysql/psi/psi.h | 16 | ||||
-rw-r--r-- | include/mysql/psi/psi_abi_v1.h.pp | 1 | ||||
-rw-r--r-- | include/mysql/psi/psi_abi_v2.h.pp | 1 |
19 files changed, 510 insertions, 410 deletions
diff --git a/include/hash.h b/include/hash.h index 75ad0b6d9a0..068700aaec6 100644 --- a/include/hash.h +++ b/include/hash.h @@ -72,7 +72,7 @@ my_bool my_hash_init2(HASH *hash, uint growth_size, CHARSET_INFO *charset, uint flags); void my_hash_free(HASH *tree); void my_hash_reset(HASH *hash); -uchar *my_hash_element(HASH *hash, ulong idx); +uchar *my_hash_element(HASH *hash, size_t idx); uchar *my_hash_search(const HASH *info, const uchar *key, size_t length); uchar *my_hash_search_using_hash_value(const HASH *info, my_hash_value_type hash_value, diff --git a/include/heap.h b/include/heap.h index e92f649b87b..2bbbc635238 100644 --- a/include/heap.h +++ b/include/heap.h @@ -217,7 +217,7 @@ extern int heap_write(HP_INFO *info,const uchar *buff); extern int heap_update(HP_INFO *info,const uchar *old,const uchar *newdata); extern int heap_rrnd(HP_INFO *info,uchar *buf,uchar *pos); extern int heap_scan_init(HP_INFO *info); -extern int heap_scan(register HP_INFO *info, uchar *record); +extern int heap_scan(HP_INFO *info, uchar *record); extern int heap_delete(HP_INFO *info,const uchar *buff); extern int heap_info(HP_INFO *info,HEAPINFO *x,int flag); extern int heap_create(const char *name, diff --git a/include/m_ctype.h b/include/m_ctype.h index 8302c85c0e7..fc51ebd3c8b 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -1093,7 +1093,7 @@ my_well_formed_length(CHARSET_INFO *cs, const char *b, const char *e, MY_STRCOPY_STATUS status; (void) cs->cset->well_formed_char_length(cs, b, e, nchars, &status); *error= status.m_well_formed_error_pos == NULL ? 0 : 1; - return status.m_source_end_pos - b; + return (size_t) (status.m_source_end_pos - b); } diff --git a/include/maria.h b/include/maria.h index f88ad610213..5bdd166287e 100644 --- a/include/maria.h +++ b/include/maria.h @@ -366,7 +366,7 @@ int maria_sort_index(HA_CHECK *param, MARIA_HA *info, char * name); int maria_zerofill(HA_CHECK *param, MARIA_HA *info, const char *name); int maria_repair_by_sort(HA_CHECK *param, MARIA_HA *info, const char *name, my_bool rep_quick); -int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info, +int maria_repair_parallel(HA_CHECK *param, MARIA_HA *info, const char *name, my_bool rep_quick); int maria_change_to_newfile(const char *filename, const char *old_ext, const char *new_ext, time_t backup_time, diff --git a/include/my_base.h b/include/my_base.h index 63a9710c306..c36072c0bfa 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -647,7 +647,7 @@ typedef ulong ha_rows; #define HA_POS_ERROR (~ (ha_rows) 0) #define HA_OFFSET_ERROR (~ (my_off_t) 0) -#if SYSTEM_SIZEOF_OFF_T == 4 +#if SIZEOF_OFF_T == 4 #define MAX_FILE_SIZE INT_MAX32 #else #define MAX_FILE_SIZE LONGLONG_MAX diff --git a/include/my_dir.h b/include/my_dir.h index af4e640c96a..a4024516c91 100644 --- a/include/my_dir.h +++ b/include/my_dir.h @@ -76,7 +76,7 @@ typedef struct my_stat #else -#if(_MSC_VER) +#if defined(_MSC_VER) #define MY_STAT struct _stati64 /* 64 bit file size */ #else #define MY_STAT struct stat /* Original struct has what we need */ diff --git a/include/my_global.h b/include/my_global.h index b32389d061f..0769feca94a 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -189,15 +189,6 @@ #define __builtin_expect(x, expected_value) (x) #endif -/** - The semantics of builtin_expect() are that - 1) its two arguments are long - 2) it's likely that they are == - Those of our likely(x) are that x can be bool/int/longlong/pointer. -*/ -#define likely(x) __builtin_expect(((x) != 0),1) -#define unlikely(x) __builtin_expect(((x) != 0),0) - /* Fix problem with S_ISLNK() on Linux */ #if defined(TARGET_OS_LINUX) || defined(__GLIBC__) #undef _GNU_SOURCE @@ -384,6 +375,36 @@ C_MODE_END #include <crypt.h> #endif +/* Add checking if we are using likely/unlikely wrong */ +#ifdef CHECK_UNLIKELY +C_MODE_START +extern void init_my_likely(), end_my_likely(FILE *); +extern int my_likely_ok(const char *file_name, uint line); +extern int my_likely_fail(const char *file_name, uint line); +C_MODE_END + +#define likely(A) ((A) ? (my_likely_ok(__FILE__, __LINE__),1) : (my_likely_fail(__FILE__, __LINE__), 0)) +#define unlikely(A) ((A) ? (my_likely_fail(__FILE__, __LINE__),1) : (my_likely_ok(__FILE__, __LINE__), 0)) +/* + These macros should be used when the check fails often when running benchmarks but + we know for sure that the check is correct in a production environment +*/ +#define checked_likely(A) (A) +#define checked_unlikely(A) (A) +#else +/** + The semantics of builtin_expect() are that + 1) its two arguments are long + 2) it's likely that they are == + Those of our likely(x) are that x can be bool/int/longlong/pointer. +*/ + +#define likely(x) __builtin_expect(((x) != 0),1) +#define unlikely(x) __builtin_expect(((x) != 0),0) +#define checked_likely(x) likely(x) +#define checked_unlikely(x) unlikely(x) +#endif /* CHECK_UNLIKELY */ + /* A lot of our programs uses asserts, so better to always include it This also fixes a problem when people uses DBUG_ASSERT without including @@ -579,8 +600,8 @@ typedef SOCKET_SIZE_TYPE size_socket; #endif #endif /* O_SHARE */ -#ifndef O_TEMPORARY -#define O_TEMPORARY 0 +#ifndef O_SEQUENTIAL +#define O_SEQUENTIAL 0 #endif #ifndef O_SHORT_LIVED #define O_SHORT_LIVED 0 @@ -710,7 +731,7 @@ typedef SOCKET_SIZE_TYPE size_socket; #define closesocket(A) close(A) #endif -#if (_MSC_VER) +#if defined(_MSC_VER) #if !defined(_WIN64) inline double my_ulonglong2double(unsigned long long value) { @@ -1166,7 +1187,7 @@ typedef struct { const char *dli_fname, dli_fbase; } Dl_info; /* Provide __func__ macro definition for platforms that miss it. */ #if !defined (__func__) -#if __STDC_VERSION__ < 199901L +#if defined(__STDC_VERSION__) && __STDC_VERSION__ < 199901L # if __GNUC__ >= 2 # define __func__ __FUNCTION__ # else @@ -1258,7 +1279,7 @@ static inline double rint(double x) CMake using getconf */ #if !defined(CPU_LEVEL1_DCACHE_LINESIZE) || CPU_LEVEL1_DCACHE_LINESIZE == 0 - #if CPU_LEVEL1_DCACHE_LINESIZE == 0 + #if defined(CPU_LEVEL1_DCACHE_LINESIZE) && CPU_LEVEL1_DCACHE_LINESIZE == 0 #undef CPU_LEVEL1_DCACHE_LINESIZE #endif @@ -1279,5 +1300,4 @@ static inline double rint(double x) #else #define NOT_FIXED_DEC FLOATING_POINT_DECIMALS #endif - #endif /* my_global_h */ diff --git a/include/my_sys.h b/include/my_sys.h index 068733cd1fd..13ab7b12320 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -67,6 +67,7 @@ typedef struct my_aio_result { #define MY_WAIT_IF_FULL 32U /* Wait and try again if disk full error */ #define MY_IGNORE_BADFD 32U /* my_sync(): ignore 'bad descriptor' errors */ #define MY_ENCRYPT 64U /* Encrypt IO_CACHE temporary files */ +#define MY_TEMPORARY 64U /* create_temp_file(): delete file at once */ #define MY_NOSYMLINKS 512U /* my_open(): don't follow symlinks */ #define MY_FULL_IO 512U /* my_read(): loop until I/O is complete */ #define MY_DONT_CHECK_FILESIZE 128U /* Option to init_io_cache() */ @@ -573,21 +574,21 @@ static inline my_bool my_b_write_byte(IO_CACHE *info, uchar chr) static inline size_t my_b_fill(IO_CACHE *info) { info->read_pos= info->read_end; - return _my_b_read(info,0,0) ? 0 : info->read_end - info->read_pos; + return _my_b_read(info,0,0) ? 0 : (size_t) (info->read_end - info->read_pos); } static inline my_off_t my_b_tell(const IO_CACHE *info) { if (info->type == WRITE_CACHE) { - return info->pos_in_file + (info->write_pos - info->request_pos); + return info->pos_in_file + (my_off_t)(info->write_pos - info->request_pos); } - return info->pos_in_file + (info->read_pos - info->request_pos); + return info->pos_in_file + (my_off_t) (info->read_pos - info->request_pos); } static inline my_off_t my_b_write_tell(const IO_CACHE *info) { - return info->pos_in_file + (info->write_pos - info->write_buffer); + return info->pos_in_file + (my_off_t) (info->write_pos - info->write_buffer); } static inline uchar* my_b_get_buffer_start(const IO_CACHE *info) @@ -597,7 +598,7 @@ static inline uchar* my_b_get_buffer_start(const IO_CACHE *info) static inline size_t my_b_get_bytes_in_buffer(const IO_CACHE *info) { - return info->read_end - info->request_pos; + return (size_t) (info->read_end - info->request_pos); } static inline my_off_t my_b_get_pos_in_file(const IO_CACHE *info) @@ -608,9 +609,9 @@ static inline my_off_t my_b_get_pos_in_file(const IO_CACHE *info) static inline size_t my_b_bytes_in_cache(const IO_CACHE *info) { if (info->type == WRITE_CACHE) { - return info->write_end - info->write_pos; + return (size_t) (info->write_end - info->write_pos); } - return info->read_end - info->read_pos; + return (size_t) (info->read_end - info->read_pos); } int my_b_copy_to_file(IO_CACHE *cache, FILE *file); @@ -733,12 +734,6 @@ void my_create_backup_name(char *to, const char *from, extern int my_copystat(const char *from, const char *to, int MyFlags); extern char * my_filename(File fd); -#ifdef EXTRA_DEBUG -void my_print_open_files(void); -#else -#define my_print_open_files() -#endif - extern my_bool init_tmpdir(MY_TMPDIR *tmpdir, const char *pathlist); extern char *my_tmpdir(MY_TMPDIR *tmpdir); extern void free_tmpdir(MY_TMPDIR *tmpdir); diff --git a/include/my_time.h b/include/my_time.h index f7d910fa07d..cec168c6fd6 100644 --- a/include/my_time.h +++ b/include/my_time.h @@ -104,7 +104,8 @@ typedef struct st_mysql_time_status static inline void my_time_status_init(MYSQL_TIME_STATUS *status) { - status->warnings= status->precision= 0; + status->warnings= 0; + status->precision= 0; } my_bool check_date(const MYSQL_TIME *ltime, my_bool not_zero_date, diff --git a/include/myisam.h b/include/myisam.h index e54b7fb5662..97f5a2d486a 100644 --- a/include/myisam.h +++ b/include/myisam.h @@ -373,7 +373,7 @@ typedef struct st_mi_sort_param int (*key_read)(struct st_mi_sort_param *,void *); int (*key_write)(struct st_mi_sort_param *, const void *); void (*lock_in_memory)(HA_CHECK *); - int (*write_keys)(struct st_mi_sort_param *, register uchar **, + int (*write_keys)(struct st_mi_sort_param *, uchar **, ulonglong , struct st_buffpek *, IO_CACHE *); my_off_t (*read_to_buffer)(IO_CACHE *,struct st_buffpek *, uint); int (*write_key)(struct st_mi_sort_param *, IO_CACHE *,uchar *, @@ -383,16 +383,15 @@ typedef struct st_mi_sort_param /* functions in mi_check */ void myisamchk_init(HA_CHECK *param); int chk_status(HA_CHECK *param, MI_INFO *info); -int chk_del(HA_CHECK *param, register MI_INFO *info, ulonglong test_flag); +int chk_del(HA_CHECK *param, MI_INFO *info, ulonglong test_flag); int chk_size(HA_CHECK *param, MI_INFO *info); int chk_key(HA_CHECK *param, MI_INFO *info); int chk_data_link(HA_CHECK *param, MI_INFO *info, my_bool extend); -int mi_repair(HA_CHECK *param, register MI_INFO *info, - char * name, int rep_quick); -int mi_sort_index(HA_CHECK *param, register MI_INFO *info, char * name); -int mi_repair_by_sort(HA_CHECK *param, register MI_INFO *info, +int mi_repair(HA_CHECK *param, MI_INFO *info, char * name, int rep_quick); +int mi_sort_index(HA_CHECK *param, MI_INFO *info, char * name); +int mi_repair_by_sort(HA_CHECK *param, MI_INFO *info, const char * name, int rep_quick); -int mi_repair_parallel(HA_CHECK *param, register MI_INFO *info, +int mi_repair_parallel(HA_CHECK *param, MI_INFO *info, const char * name, int rep_quick); int change_to_newfile(const char * filename, const char * old_ext, const char * new_ext, time_t backup_time, myf myflags); diff --git a/include/mysql/psi/mysql_file.h b/include/mysql/psi/mysql_file.h index 801c26086f5..f793aa6237c 100644 --- a/include/mysql/psi/mysql_file.h +++ b/include/mysql/psi/mysql_file.h @@ -529,16 +529,18 @@ inline_mysql_file_fgets( { char *result; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker; - PSI_file_locker_state state; - locker= PSI_FILE_CALL(get_thread_file_stream_locker) - (&state, file->m_psi, PSI_FILE_READ); - if (likely(locker != NULL)) + if (psi_likely(pfs_enabled)) { - PSI_FILE_CALL(start_file_wait)(locker, (size_t) size, src_file, src_line); - result= fgets(str, size, file->m_file); - PSI_FILE_CALL(end_file_wait)(locker, result ? strlen(result) : 0); - return result; + struct PSI_file_locker *locker; + PSI_file_locker_state state; + locker= PSI_FILE_CALL(get_thread_file_stream_locker) (&state, file->m_psi, PSI_FILE_READ); + if (likely(locker != NULL)) + { + PSI_FILE_CALL(start_file_wait)(locker, (size_t) size, src_file, src_line); + result= fgets(str, size, file->m_file); + PSI_FILE_CALL(end_file_wait)(locker, result ? strlen(result) : 0); + return result; + } } #endif @@ -555,16 +557,18 @@ inline_mysql_file_fgetc( { int result; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker; - PSI_file_locker_state state; - locker= PSI_FILE_CALL(get_thread_file_stream_locker) - (&state, file->m_psi, PSI_FILE_READ); - if (likely(locker != NULL)) + if (psi_likely(pfs_enabled)) { - PSI_FILE_CALL(start_file_wait)(locker, (size_t) 1, src_file, src_line); - result= fgetc(file->m_file); - PSI_FILE_CALL(end_file_wait)(locker, (size_t) 1); - return result; + struct PSI_file_locker *locker; + PSI_file_locker_state state; + locker= PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi, PSI_FILE_READ); + if (likely(locker != NULL)) + { + PSI_FILE_CALL(start_file_wait)(locker, (size_t) 1, src_file, src_line); + result= fgetc(file->m_file); + PSI_FILE_CALL(end_file_wait)(locker, (size_t) 1); + return result; + } } #endif @@ -581,18 +585,20 @@ inline_mysql_file_fputs( { int result; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker; - PSI_file_locker_state state; - size_t bytes; - locker= PSI_FILE_CALL(get_thread_file_stream_locker) - (&state, file->m_psi, PSI_FILE_WRITE); - if (likely(locker != NULL)) + if (psi_likely(pfs_enabled)) { - bytes= str ? strlen(str) : 0; - PSI_FILE_CALL(start_file_wait)(locker, bytes, src_file, src_line); - result= fputs(str, file->m_file); - PSI_FILE_CALL(end_file_wait)(locker, bytes); - return result; + struct PSI_file_locker *locker; + PSI_file_locker_state state; + size_t bytes; + locker= PSI_FILE_CALL(get_thread_file_stream_locker) (&state, file->m_psi, PSI_FILE_WRITE); + if (likely(locker != NULL)) + { + bytes= str ? strlen(str) : 0; + PSI_FILE_CALL(start_file_wait)(locker, bytes, src_file, src_line); + result= fputs(str, file->m_file); + PSI_FILE_CALL(end_file_wait)(locker, bytes); + return result; + } } #endif @@ -609,16 +615,18 @@ inline_mysql_file_fputc( { int result; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker; - PSI_file_locker_state state; - locker= PSI_FILE_CALL(get_thread_file_stream_locker) - (&state, file->m_psi, PSI_FILE_WRITE); - if (likely(locker != NULL)) + if (psi_likely(pfs_enabled)) { - PSI_FILE_CALL(start_file_wait)(locker, (size_t) 1, src_file, src_line); - result= fputc(c, file->m_file); - PSI_FILE_CALL(end_file_wait)(locker, (size_t) 1); - return result; + struct PSI_file_locker *locker; + PSI_file_locker_state state; + locker= PSI_FILE_CALL(get_thread_file_stream_locker) (&state, file->m_psi, PSI_FILE_WRITE); + if (likely(locker != NULL)) + { + PSI_FILE_CALL(start_file_wait)(locker, (size_t) 1, src_file, src_line); + result= fputc(c, file->m_file); + PSI_FILE_CALL(end_file_wait)(locker, (size_t) 1); + return result; + } } #endif @@ -635,18 +643,20 @@ inline_mysql_file_fprintf(MYSQL_FILE *file, const char *format, ...) int result; va_list args; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker; - PSI_file_locker_state state; - locker= PSI_FILE_CALL(get_thread_file_stream_locker) - (&state, file->m_psi, PSI_FILE_WRITE); - if (likely(locker != NULL)) + if (psi_likely(pfs_enabled)) { - PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, __FILE__, __LINE__); - va_start(args, format); - result= vfprintf(file->m_file, format, args); - va_end(args); - PSI_FILE_CALL(end_file_wait)(locker, (size_t) result); - return result; + struct PSI_file_locker *locker; + PSI_file_locker_state state; + locker= PSI_FILE_CALL(get_thread_file_stream_locker) (&state, file->m_psi, PSI_FILE_WRITE); + if (likely(locker != NULL)) + { + PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, __FILE__, __LINE__); + va_start(args, format); + result= vfprintf(file->m_file, format, args); + va_end(args); + PSI_FILE_CALL(end_file_wait)(locker, (size_t) result); + return result; + } } #endif @@ -665,16 +675,18 @@ inline_mysql_file_vfprintf( { int result; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker; - PSI_file_locker_state state; - locker= PSI_FILE_CALL(get_thread_file_stream_locker) - (&state, file->m_psi, PSI_FILE_WRITE); - if (likely(locker != NULL)) + if (psi_likely(pfs_enabled)) { - PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line); - result= vfprintf(file->m_file, format, args); - PSI_FILE_CALL(end_file_wait)(locker, (size_t) result); - return result; + struct PSI_file_locker *locker; + PSI_file_locker_state state; + locker= PSI_FILE_CALL(get_thread_file_stream_locker) (&state, file->m_psi, PSI_FILE_WRITE); + if (likely(locker != NULL)) + { + PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line); + result= vfprintf(file->m_file, format, args); + PSI_FILE_CALL(end_file_wait)(locker, (size_t) result); + return result; + } } #endif @@ -691,16 +703,18 @@ inline_mysql_file_fflush( { int result; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker; - PSI_file_locker_state state; - locker= PSI_FILE_CALL(get_thread_file_stream_locker) - (&state, file->m_psi, PSI_FILE_FLUSH); - if (likely(locker != NULL)) + if (psi_likely(pfs_enabled)) { - PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line); - result= fflush(file->m_file); - PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0); - return result; + struct PSI_file_locker *locker; + PSI_file_locker_state state; + locker= PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi, PSI_FILE_FLUSH); + if (likely(locker != NULL)) + { + PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line); + result= fflush(file->m_file); + PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0); + return result; + } } #endif @@ -723,16 +737,18 @@ inline_mysql_file_fstat( { int result; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker; - PSI_file_locker_state state; - locker= PSI_FILE_CALL(get_thread_file_descriptor_locker) - (&state, filenr, PSI_FILE_FSTAT); - if (likely(locker != NULL)) + if (psi_likely(pfs_enabled)) { - PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line); - result= my_fstat(filenr, stat_area, flags); - PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0); - return result; + struct PSI_file_locker *locker; + PSI_file_locker_state state; + locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, filenr, PSI_FILE_FSTAT); + if (likely(locker != NULL)) + { + PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line); + result= my_fstat(filenr, stat_area, flags); + PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0); + return result; + } } #endif @@ -749,16 +765,18 @@ inline_mysql_file_stat( { MY_STAT *result; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker; - PSI_file_locker_state state; - locker= PSI_FILE_CALL(get_thread_file_name_locker) - (&state, key, PSI_FILE_STAT, path, &locker); - if (likely(locker != NULL)) + if (psi_likely(pfs_enabled)) { - PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line); - result= my_stat(path, stat_area, flags); - PSI_FILE_CALL(end_file_open_wait)(locker, result); - return result; + struct PSI_file_locker *locker; + PSI_file_locker_state state; + locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_STAT, path, &locker); + if (likely(locker != NULL)) + { + PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line); + result= my_stat(path, stat_area, flags); + PSI_FILE_CALL(end_file_open_wait)(locker, result); + return result; + } } #endif @@ -775,17 +793,19 @@ inline_mysql_file_chsize( { int result; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker; - PSI_file_locker_state state; - locker= PSI_FILE_CALL(get_thread_file_descriptor_locker) - (&state, file, PSI_FILE_CHSIZE); - if (likely(locker != NULL)) + if (psi_likely(pfs_enabled)) { - PSI_FILE_CALL(start_file_wait)(locker, (size_t) newlength, src_file, - src_line); - result= my_chsize(file, newlength, filler, flags); - PSI_FILE_CALL(end_file_wait)(locker, (size_t) newlength); - return result; + struct PSI_file_locker *locker; + PSI_file_locker_state state; + locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_CHSIZE); + if (likely(locker != NULL)) + { + PSI_FILE_CALL(start_file_wait)(locker, (size_t) newlength, src_file, + src_line); + result= my_chsize(file, newlength, filler, flags); + PSI_FILE_CALL(end_file_wait)(locker, (size_t) newlength); + return result; + } } #endif @@ -805,22 +825,24 @@ inline_mysql_file_fopen( if (likely(that != NULL)) { #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker; - PSI_file_locker_state state; - locker= PSI_FILE_CALL(get_thread_file_name_locker) - (&state, key, PSI_FILE_STREAM_OPEN, filename, that); - if (likely(locker != NULL)) + if (psi_likely(pfs_enabled)) { - PSI_FILE_CALL(start_file_open_wait) - (locker, src_file, src_line); - that->m_file= my_fopen(filename, flags, myFlags); - that->m_psi= PSI_FILE_CALL(end_file_open_wait)(locker, that->m_file); - if (unlikely(that->m_file == NULL)) + struct PSI_file_locker *locker; + PSI_file_locker_state state; + locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_STREAM_OPEN, + filename, that); + if (likely(locker != NULL)) { - my_free(that); - return NULL; + PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line); + that->m_file= my_fopen(filename, flags, myFlags); + that->m_psi= PSI_FILE_CALL(end_file_open_wait)(locker, that->m_file); + if (unlikely(that->m_file == NULL)) + { + my_free(that); + return NULL; + } + return that; } - return that; } #endif @@ -846,17 +868,20 @@ inline_mysql_file_fclose( if (likely(file != NULL)) { #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker; - PSI_file_locker_state state; - locker= PSI_FILE_CALL(get_thread_file_stream_locker) - (&state, file->m_psi, PSI_FILE_STREAM_CLOSE); - if (likely(locker != NULL)) + if (psi_likely(pfs_enabled)) { - PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line); - result= my_fclose(file->m_file, flags); - PSI_FILE_CALL(end_file_close_wait)(locker, result); - my_free(file); - return result; + struct PSI_file_locker *locker; + PSI_file_locker_state state; + locker= PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi, + PSI_FILE_STREAM_CLOSE); + if (likely(locker != NULL)) + { + PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line); + result= my_fclose(file->m_file, flags); + PSI_FILE_CALL(end_file_close_wait)(locker, result); + my_free(file); + return result; + } } #endif @@ -875,21 +900,23 @@ inline_mysql_file_fread( { size_t result; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker; - PSI_file_locker_state state; - size_t bytes_read; - locker= PSI_FILE_CALL(get_thread_file_stream_locker) - (&state, file->m_psi, PSI_FILE_READ); - if (likely(locker != NULL)) + if (psi_likely(pfs_enabled)) { - PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line); - result= my_fread(file->m_file, buffer, count, flags); - if (flags & (MY_NABP | MY_FNABP)) - bytes_read= (result == 0) ? count : 0; - else - bytes_read= (result != MY_FILE_ERROR) ? result : 0; - PSI_FILE_CALL(end_file_wait)(locker, bytes_read); - return result; + struct PSI_file_locker *locker; + PSI_file_locker_state state; + size_t bytes_read; + locker= PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi, PSI_FILE_READ); + if (likely(locker != NULL)) + { + PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line); + result= my_fread(file->m_file, buffer, count, flags); + if (flags & (MY_NABP | MY_FNABP)) + bytes_read= (result == 0) ? count : 0; + else + bytes_read= (result != MY_FILE_ERROR) ? result : 0; + PSI_FILE_CALL(end_file_wait)(locker, bytes_read); + return result; + } } #endif @@ -906,21 +933,23 @@ inline_mysql_file_fwrite( { size_t result; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker; - PSI_file_locker_state state; - size_t bytes_written; - locker= PSI_FILE_CALL(get_thread_file_stream_locker) - (&state, file->m_psi, PSI_FILE_WRITE); - if (likely(locker != NULL)) + if (psi_likely(pfs_enabled)) { - PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line); - result= my_fwrite(file->m_file, buffer, count, flags); - if (flags & (MY_NABP | MY_FNABP)) - bytes_written= (result == 0) ? count : 0; - else - bytes_written= (result != MY_FILE_ERROR) ? result : 0; - PSI_FILE_CALL(end_file_wait)(locker, bytes_written); - return result; + struct PSI_file_locker *locker; + PSI_file_locker_state state; + size_t bytes_written; + locker= PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi, PSI_FILE_WRITE); + if (likely(locker != NULL)) + { + PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line); + result= my_fwrite(file->m_file, buffer, count, flags); + if (flags & (MY_NABP | MY_FNABP)) + bytes_written= (result == 0) ? count : 0; + else + bytes_written= (result != MY_FILE_ERROR) ? result : 0; + PSI_FILE_CALL(end_file_wait)(locker, bytes_written); + return result; + } } #endif @@ -937,16 +966,18 @@ inline_mysql_file_fseek( { my_off_t result; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker; - PSI_file_locker_state state; - locker= PSI_FILE_CALL(get_thread_file_stream_locker) - (&state, file->m_psi, PSI_FILE_SEEK); - if (likely(locker != NULL)) + if (psi_likely(pfs_enabled)) { - PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line); - result= my_fseek(file->m_file, pos, whence, flags); - PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0); - return result; + struct PSI_file_locker *locker; + PSI_file_locker_state state; + locker= PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi, PSI_FILE_SEEK); + if (likely(locker != NULL)) + { + PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line); + result= my_fseek(file->m_file, pos, whence, flags); + PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0); + return result; + } } #endif @@ -963,16 +994,18 @@ inline_mysql_file_ftell( { my_off_t result; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker; - PSI_file_locker_state state; - locker= PSI_FILE_CALL(get_thread_file_stream_locker) - (&state, file->m_psi, PSI_FILE_TELL); - if (likely(locker != NULL)) + if (psi_likely(pfs_enabled)) { - PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line); - result= my_ftell(file->m_file, flags); - PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0); - return result; + struct PSI_file_locker *locker; + PSI_file_locker_state state; + locker= PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi, PSI_FILE_TELL); + if (likely(locker != NULL)) + { + PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line); + result= my_ftell(file->m_file, flags); + PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0); + return result; + } } #endif @@ -989,16 +1022,19 @@ inline_mysql_file_create( { File file; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker; - PSI_file_locker_state state; - locker= PSI_FILE_CALL(get_thread_file_name_locker) - (&state, key, PSI_FILE_CREATE, filename, &locker); - if (likely(locker != NULL)) + if (psi_likely(pfs_enabled)) { - PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line); - file= my_create(filename, create_flags, access_flags, myFlags); - PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file); - return file; + struct PSI_file_locker *locker; + PSI_file_locker_state state; + locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_CREATE, filename, + &locker); + if (likely(locker != NULL)) + { + PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line); + file= my_create(filename, create_flags, access_flags, myFlags); + PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file); + return file; + } } #endif @@ -1035,16 +1071,19 @@ inline_mysql_file_open( { File file; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker; - PSI_file_locker_state state; - locker= PSI_FILE_CALL(get_thread_file_name_locker) - (&state, key, PSI_FILE_OPEN, filename, &locker); - if (likely(locker != NULL)) + if (psi_likely(pfs_enabled)) { - PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line); - file= my_open(filename, flags, myFlags); - PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file); - return file; + struct PSI_file_locker *locker; + PSI_file_locker_state state; + locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_OPEN, filename, + &locker); + if (likely(locker != NULL)) + { + PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line); + file= my_open(filename, flags, myFlags); + PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file); + return file; + } } #endif @@ -1061,16 +1100,18 @@ inline_mysql_file_close( { int result; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker; - PSI_file_locker_state state; - locker= PSI_FILE_CALL(get_thread_file_descriptor_locker) - (&state, file, PSI_FILE_CLOSE); - if (likely(locker != NULL)) + if (psi_likely(pfs_enabled)) { - PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line); - result= my_close(file, flags); - PSI_FILE_CALL(end_file_close_wait)(locker, result); - return result; + struct PSI_file_locker *locker; + PSI_file_locker_state state; + locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_CLOSE); + if (likely(locker != NULL)) + { + PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line); + result= my_close(file, flags); + PSI_FILE_CALL(end_file_close_wait)(locker, result); + return result; + } } #endif @@ -1087,21 +1128,23 @@ inline_mysql_file_read( { size_t result; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker; - PSI_file_locker_state state; - size_t bytes_read; - locker= PSI_FILE_CALL(get_thread_file_descriptor_locker) - (&state, file, PSI_FILE_READ); - if (likely(locker != NULL)) + if (psi_likely(pfs_enabled)) { - PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line); - result= my_read(file, buffer, count, flags); - if (flags & (MY_NABP | MY_FNABP)) - bytes_read= (result == 0) ? count : 0; - else - bytes_read= (result != MY_FILE_ERROR) ? result : 0; - PSI_FILE_CALL(end_file_wait)(locker, bytes_read); - return result; + struct PSI_file_locker *locker; + PSI_file_locker_state state; + size_t bytes_read; + locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_READ); + if (likely(locker != NULL)) + { + PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line); + result= my_read(file, buffer, count, flags); + if (flags & (MY_NABP | MY_FNABP)) + bytes_read= (result == 0) ? count : 0; + else + bytes_read= (result != MY_FILE_ERROR) ? result : 0; + PSI_FILE_CALL(end_file_wait)(locker, bytes_read); + return result; + } } #endif @@ -1118,21 +1161,23 @@ inline_mysql_file_write( { size_t result; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker; - PSI_file_locker_state state; - size_t bytes_written; - locker= PSI_FILE_CALL(get_thread_file_descriptor_locker) - (&state, file, PSI_FILE_WRITE); - if (likely(locker != NULL)) + if (psi_likely(pfs_enabled)) { - PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line); - result= my_write(file, buffer, count, flags); - if (flags & (MY_NABP | MY_FNABP)) - bytes_written= (result == 0) ? count : 0; - else - bytes_written= (result != MY_FILE_ERROR) ? result : 0; - PSI_FILE_CALL(end_file_wait)(locker, bytes_written); - return result; + struct PSI_file_locker *locker; + PSI_file_locker_state state; + size_t bytes_written; + locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_WRITE); + if (likely(locker != NULL)) + { + PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line); + result= my_write(file, buffer, count, flags); + if (flags & (MY_NABP | MY_FNABP)) + bytes_written= (result == 0) ? count : 0; + else + bytes_written= (result != MY_FILE_ERROR) ? result : 0; + PSI_FILE_CALL(end_file_wait)(locker, bytes_written); + return result; + } } #endif @@ -1149,21 +1194,23 @@ inline_mysql_file_pread( { size_t result; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker; - PSI_file_locker_state state; - size_t bytes_read; - locker= PSI_FILE_CALL(get_thread_file_descriptor_locker) - (&state, file, PSI_FILE_READ); - if (likely(locker != NULL)) + if (psi_likely(pfs_enabled)) { - PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line); - result= my_pread(file, buffer, count, offset, flags); - if (flags & (MY_NABP | MY_FNABP)) - bytes_read= (result == 0) ? count : 0; - else - bytes_read= (result != MY_FILE_ERROR) ? result : 0; - PSI_FILE_CALL(end_file_wait)(locker, bytes_read); - return result; + struct PSI_file_locker *locker; + PSI_file_locker_state state; + size_t bytes_read; + locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_READ); + if (likely(locker != NULL)) + { + PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line); + result= my_pread(file, buffer, count, offset, flags); + if (flags & (MY_NABP | MY_FNABP)) + bytes_read= (result == 0) ? count : 0; + else + bytes_read= (result != MY_FILE_ERROR) ? result : 0; + PSI_FILE_CALL(end_file_wait)(locker, bytes_read); + return result; + } } #endif @@ -1180,21 +1227,23 @@ inline_mysql_file_pwrite( { size_t result; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker; - PSI_file_locker_state state; - size_t bytes_written; - locker= PSI_FILE_CALL(get_thread_file_descriptor_locker) - (&state, file, PSI_FILE_WRITE); - if (likely(locker != NULL)) + if (psi_likely(pfs_enabled)) { - PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line); - result= my_pwrite(file, buffer, count, offset, flags); - if (flags & (MY_NABP | MY_FNABP)) - bytes_written= (result == 0) ? count : 0; - else - bytes_written= (result != MY_FILE_ERROR) ? result : 0; - PSI_FILE_CALL(end_file_wait)(locker, bytes_written); - return result; + struct PSI_file_locker *locker; + PSI_file_locker_state state; + size_t bytes_written; + locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_WRITE); + if (likely(locker != NULL)) + { + PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line); + result= my_pwrite(file, buffer, count, offset, flags); + if (flags & (MY_NABP | MY_FNABP)) + bytes_written= (result == 0) ? count : 0; + else + bytes_written= (result != MY_FILE_ERROR) ? result : 0; + PSI_FILE_CALL(end_file_wait)(locker, bytes_written); + return result; + } } #endif @@ -1211,16 +1260,18 @@ inline_mysql_file_seek( { my_off_t result; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker; - PSI_file_locker_state state; - locker= PSI_FILE_CALL(get_thread_file_descriptor_locker) - (&state, file, PSI_FILE_SEEK); - if (likely(locker != NULL)) + if (psi_likely(pfs_enabled)) { - PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line); - result= my_seek(file, pos, whence, flags); - PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0); - return result; + struct PSI_file_locker *locker; + PSI_file_locker_state state; + locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_SEEK); + if (likely(locker != NULL)) + { + PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line); + result= my_seek(file, pos, whence, flags); + PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0); + return result; + } } #endif @@ -1237,16 +1288,18 @@ inline_mysql_file_tell( { my_off_t result; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker; - PSI_file_locker_state state; - locker= PSI_FILE_CALL(get_thread_file_descriptor_locker) - (&state, file, PSI_FILE_TELL); - if (likely(locker != NULL)) + if (psi_likely(pfs_enabled)) { - PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line); - result= my_tell(file, flags); - PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0); - return result; + struct PSI_file_locker *locker; + PSI_file_locker_state state; + locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_TELL); + if (likely(locker != NULL)) + { + PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line); + result= my_tell(file, flags); + PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0); + return result; + } } #endif @@ -1263,16 +1316,18 @@ inline_mysql_file_delete( { int result; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker; - PSI_file_locker_state state; - locker= PSI_FILE_CALL(get_thread_file_name_locker) - (&state, key, PSI_FILE_DELETE, name, &locker); - if (likely(locker != NULL)) + if (psi_likely(pfs_enabled)) { - PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line); - result= my_delete(name, flags); - PSI_FILE_CALL(end_file_close_wait)(locker, result); - return result; + struct PSI_file_locker *locker; + PSI_file_locker_state state; + locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_DELETE, name, &locker); + if (likely(locker != NULL)) + { + PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line); + result= my_delete(name, flags); + PSI_FILE_CALL(end_file_close_wait)(locker, result); + return result; + } } #endif @@ -1289,16 +1344,18 @@ inline_mysql_file_rename( { int result; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker; - PSI_file_locker_state state; - locker= PSI_FILE_CALL(get_thread_file_name_locker) - (&state, key, PSI_FILE_RENAME, to, &locker); - if (likely(locker != NULL)) + if (psi_likely(pfs_enabled)) { - PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line); - result= my_rename(from, to, flags); - PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0); - return result; + struct PSI_file_locker *locker; + PSI_file_locker_state state; + locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_RENAME, to, &locker); + if (likely(locker != NULL)) + { + PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line); + result= my_rename(from, to, flags); + PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0); + return result; + } } #endif @@ -1317,17 +1374,20 @@ inline_mysql_file_create_with_symlink( { File file; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker; - PSI_file_locker_state state; - locker= PSI_FILE_CALL(get_thread_file_name_locker) - (&state, key, PSI_FILE_CREATE, filename, &locker); - if (likely(locker != NULL)) + if (psi_likely(pfs_enabled)) { - PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line); - file= my_create_with_symlink(linkname, filename, create_flags, access_flags, - flags); - PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file); - return file; + struct PSI_file_locker *locker; + PSI_file_locker_state state; + locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_CREATE, filename, + &locker); + if (likely(locker != NULL)) + { + PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line); + file= my_create_with_symlink(linkname, filename, create_flags, access_flags, + flags); + PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file); + return file; + } } #endif @@ -1348,16 +1408,19 @@ inline_mysql_file_delete_with_symlink( char buf[FN_REFLEN]; char *fullname= fn_format(buf, name, "", ext, MY_UNPACK_FILENAME | MY_APPEND_EXT); #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker; - PSI_file_locker_state state; - locker= PSI_FILE_CALL(get_thread_file_name_locker) - (&state, key, PSI_FILE_DELETE, fullname, &locker); - if (likely(locker != NULL)) + if (psi_likely(pfs_enabled)) { - PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line); - result= my_handler_delete_with_symlink(fullname, flags); - PSI_FILE_CALL(end_file_close_wait)(locker, result); - return result; + struct PSI_file_locker *locker; + PSI_file_locker_state state; + locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_DELETE, fullname, + &locker); + if (likely(locker != NULL)) + { + PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line); + result= my_handler_delete_with_symlink(fullname, flags); + PSI_FILE_CALL(end_file_close_wait)(locker, result); + return result; + } } #endif @@ -1375,16 +1438,18 @@ inline_mysql_file_rename_with_symlink( { int result; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker; - PSI_file_locker_state state; - locker= PSI_FILE_CALL(get_thread_file_name_locker) - (&state, key, PSI_FILE_RENAME, to, &locker); - if (likely(locker != NULL)) + if (psi_likely(pfs_enabled)) { - PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line); - result= my_rename_with_symlink(from, to, flags); - PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0); - return result; + struct PSI_file_locker *locker; + PSI_file_locker_state state; + locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_RENAME, to, &locker); + if (likely(locker != NULL)) + { + PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line); + result= my_rename_with_symlink(from, to, flags); + PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0); + return result; + } } #endif @@ -1401,16 +1466,18 @@ inline_mysql_file_sync( { int result= 0; #ifdef HAVE_PSI_FILE_INTERFACE - struct PSI_file_locker *locker; - PSI_file_locker_state state; - locker= PSI_FILE_CALL(get_thread_file_descriptor_locker) - (&state, fd, PSI_FILE_SYNC); - if (likely(locker != NULL)) + if (psi_likely(pfs_enabled)) { - PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line); - result= my_sync(fd, flags); - PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0); - return result; + struct PSI_file_locker *locker; + PSI_file_locker_state state; + locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, fd, PSI_FILE_SYNC); + if (likely(locker != NULL)) + { + PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line); + result= my_sync(fd, flags); + PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0); + return result; + } } #endif diff --git a/include/mysql/psi/mysql_idle.h b/include/mysql/psi/mysql_idle.h index b623edce108..16c9de7ff55 100644 --- a/include/mysql/psi/mysql_idle.h +++ b/include/mysql/psi/mysql_idle.h @@ -82,7 +82,7 @@ inline_mysql_start_idle_wait(PSI_idle_locker_state *state, static inline void 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); } #endif diff --git a/include/mysql/psi/mysql_socket.h b/include/mysql/psi/mysql_socket.h index 2bbe4c39849..3baabb6e57d 100644 --- a/include/mysql/psi/mysql_socket.h +++ b/include/mysql/psi/mysql_socket.h @@ -245,7 +245,7 @@ inline_mysql_start_socket_wait(PSI_socket_locker_state *state, const char *src_file, uint src_line) { 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) (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 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); } @@ -577,7 +577,7 @@ inline_mysql_socket_bind int result; #ifdef HAVE_PSI_SOCKET_INTERFACE - if (mysql_socket.m_psi != NULL) + if (psi_likely(mysql_socket.m_psi != NULL)) { /* Instrumentation start */ PSI_socket_locker_state state; @@ -617,7 +617,7 @@ inline_mysql_socket_getsockname int result; #ifdef HAVE_PSI_SOCKET_INTERFACE - if (mysql_socket.m_psi != NULL) + if (psi_likely(mysql_socket.m_psi != NULL)) { /* Instrumentation start */ PSI_socket_locker *locker; @@ -655,7 +655,7 @@ inline_mysql_socket_connect int result; #ifdef HAVE_PSI_SOCKET_INTERFACE - if (mysql_socket.m_psi != NULL) + if (psi_likely(mysql_socket.m_psi != NULL)) { /* Instrumentation start */ PSI_socket_locker *locker; @@ -693,7 +693,7 @@ inline_mysql_socket_getpeername int result; #ifdef HAVE_PSI_SOCKET_INTERFACE - if (mysql_socket.m_psi != NULL) + if (psi_likely(mysql_socket.m_psi != NULL)) { /* Instrumentation start */ PSI_socket_locker *locker; @@ -731,7 +731,7 @@ inline_mysql_socket_send ssize_t result; #ifdef HAVE_PSI_SOCKET_INTERFACE - if (mysql_socket.m_psi != NULL) + if (psi_likely(mysql_socket.m_psi != NULL)) { /* Instrumentation start */ PSI_socket_locker *locker; @@ -772,7 +772,7 @@ inline_mysql_socket_recv ssize_t result; #ifdef HAVE_PSI_SOCKET_INTERFACE - if (mysql_socket.m_psi != NULL) + if (psi_likely(mysql_socket.m_psi != NULL)) { /* Instrumentation start */ PSI_socket_locker *locker; @@ -813,7 +813,7 @@ inline_mysql_socket_sendto ssize_t result; #ifdef HAVE_PSI_SOCKET_INTERFACE - if (mysql_socket.m_psi != NULL) + if (psi_likely(mysql_socket.m_psi != NULL)) { /* Instrumentation start */ PSI_socket_locker *locker; @@ -855,7 +855,7 @@ inline_mysql_socket_recvfrom ssize_t result; #ifdef HAVE_PSI_SOCKET_INTERFACE - if (mysql_socket.m_psi != NULL) + if (psi_likely(mysql_socket.m_psi != NULL)) { /* Instrumentation start */ PSI_socket_locker *locker; @@ -896,7 +896,7 @@ inline_mysql_socket_getsockopt int result; #ifdef HAVE_PSI_SOCKET_INTERFACE - if (mysql_socket.m_psi != NULL) + if (psi_likely(mysql_socket.m_psi != NULL)) { /* Instrumentation start */ PSI_socket_locker *locker; @@ -935,7 +935,7 @@ inline_mysql_socket_setsockopt int result; #ifdef HAVE_PSI_SOCKET_INTERFACE - if (mysql_socket.m_psi) + if (psi_likely(mysql_socket.m_psi)) { /* Instrumentation start */ PSI_socket_locker *locker; @@ -973,7 +973,7 @@ inline_mysql_socket_listen int result; #ifdef HAVE_PSI_SOCKET_INTERFACE - if (mysql_socket.m_psi != NULL) + if (psi_likely(mysql_socket.m_psi != NULL)) { /* Instrumentation start */ PSI_socket_locker *locker; @@ -1087,7 +1087,7 @@ inline_mysql_socket_close int result; #ifdef HAVE_PSI_SOCKET_INTERFACE - if (mysql_socket.m_psi != NULL) + if (psi_likely(mysql_socket.m_psi != NULL)) { /* Instrumentation start */ PSI_socket_locker *locker; @@ -1142,7 +1142,7 @@ inline_mysql_socket_shutdown /* Instrumentation start */ #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_state state; diff --git a/include/mysql/psi/mysql_statement.h b/include/mysql/psi/mysql_statement.h index 2c59b50aa63..44d27ef1ea6 100644 --- a/include/mysql/psi/mysql_statement.h +++ b/include/mysql/psi/mysql_statement.h @@ -127,7 +127,7 @@ inline_mysql_digest_start(PSI_statement_locker *locker) { PSI_digest_locker* digest_locker= NULL; - if (likely(locker != NULL)) + if (psi_likely(locker != NULL)) digest_locker= PSI_DIGEST_CALL(digest_start)(locker); return digest_locker; } @@ -137,7 +137,7 @@ inline_mysql_digest_start(PSI_statement_locker *locker) static inline void 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); } #endif @@ -151,7 +151,7 @@ inline_mysql_start_statement(PSI_statement_locker_state *state, { PSI_statement_locker *locker; 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); return locker; } @@ -160,7 +160,7 @@ static inline struct PSI_statement_locker * inline_mysql_refine_statement(PSI_statement_locker *locker, PSI_statement_key key) { - if (likely(locker != NULL)) + if (psi_likely(locker != NULL)) { locker= PSI_STATEMENT_CALL(refine_statement)(locker, key); } @@ -171,7 +171,7 @@ static inline void inline_mysql_set_statement_text(PSI_statement_locker *locker, 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); } @@ -181,7 +181,7 @@ static inline void inline_mysql_set_statement_lock_time(PSI_statement_locker *locker, ulonglong count) { - if (likely(locker != NULL)) + if (psi_likely(locker != NULL)) { 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, ulonglong count) { - if (likely(locker != NULL)) + if (psi_likely(locker != NULL)) { 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, ulonglong count) { - if (likely(locker != NULL)) + if (psi_likely(locker != NULL)) { 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) { PSI_STAGE_CALL(end_stage)(); - if (likely(locker != NULL)) + if (psi_likely(locker != NULL)) PSI_STATEMENT_CALL(end_statement)(locker, stmt_da); } #endif diff --git a/include/mysql/psi/mysql_table.h b/include/mysql/psi/mysql_table.h index 5b4b64a8e48..e420f9a099e 100644 --- a/include/mysql/psi/mysql_table.h +++ b/include/mysql/psi/mysql_table.h @@ -87,7 +87,7 @@ #ifdef HAVE_PSI_TABLE_INTERFACE #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_state state; \ @@ -120,7 +120,7 @@ #ifdef HAVE_PSI_TABLE_INTERFACE #define MYSQL_TABLE_LOCK_WAIT(PSI, OP, FLAGS, PAYLOAD) \ { \ - if (PSI != NULL) \ + if (psi_likely(PSI != NULL)) \ { \ PSI_table_locker *locker; \ 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, ulong flags, const char *src_file, uint src_line) { - if (psi != NULL) + if (psi_likely(psi != NULL)) { struct PSI_table_locker *locker; 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 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); } #endif diff --git a/include/mysql/psi/mysql_thread.h b/include/mysql/psi/mysql_thread.h index 08715513f8c..6350467c3bc 100644 --- a/include/mysql/psi/mysql_thread.h +++ b/include/mysql/psi/mysql_thread.h @@ -682,7 +682,7 @@ static inline int inline_mysql_mutex_lock( int result; #ifdef HAVE_PSI_MUTEX_INTERFACE - if (that->m_psi != NULL) + if (psi_likely(that->m_psi != NULL)) { /* Instrumentation start */ PSI_mutex_locker *locker; @@ -725,7 +725,7 @@ static inline int inline_mysql_mutex_trylock( int result; #ifdef HAVE_PSI_MUTEX_INTERFACE - if (that->m_psi != NULL) + if (psi_likely(that->m_psi != NULL)) { /* Instrumentation start */ PSI_mutex_locker *locker; @@ -768,7 +768,7 @@ static inline int inline_mysql_mutex_unlock( int result; #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); #endif @@ -835,7 +835,7 @@ static inline int inline_mysql_rwlock_destroy( mysql_rwlock_t *that) { #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); that->m_psi= NULL; @@ -849,7 +849,7 @@ static inline int inline_mysql_prlock_destroy( mysql_prlock_t *that) { #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); that->m_psi= NULL; @@ -869,7 +869,7 @@ static inline int inline_mysql_rwlock_rdlock( int result; #ifdef HAVE_PSI_RWLOCK_INTERFACE - if (that->m_psi != NULL) + if (psi_likely(that->m_psi != NULL)) { /* Instrumentation start */ PSI_rwlock_locker *locker; @@ -905,7 +905,7 @@ static inline int inline_mysql_prlock_rdlock( int result; #ifdef HAVE_PSI_RWLOCK_INTERFACE - if (that->m_psi != NULL) + if (psi_likely(that->m_psi != NULL)) { /* Instrumentation start */ PSI_rwlock_locker *locker; @@ -941,7 +941,7 @@ static inline int inline_mysql_rwlock_wrlock( int result; #ifdef HAVE_PSI_RWLOCK_INTERFACE - if (that->m_psi != NULL) + if (psi_likely(that->m_psi != NULL)) { /* Instrumentation start */ PSI_rwlock_locker *locker; @@ -977,7 +977,7 @@ static inline int inline_mysql_prlock_wrlock( int result; #ifdef HAVE_PSI_RWLOCK_INTERFACE - if (that->m_psi != NULL) + if (psi_likely(that->m_psi != NULL)) { /* Instrumentation start */ PSI_rwlock_locker *locker; @@ -1013,7 +1013,7 @@ static inline int inline_mysql_rwlock_tryrdlock( int result; #ifdef HAVE_PSI_RWLOCK_INTERFACE - if (that->m_psi != NULL) + if (psi_likely(that->m_psi != NULL)) { /* Instrumentation start */ PSI_rwlock_locker *locker; @@ -1048,7 +1048,7 @@ static inline int inline_mysql_rwlock_trywrlock( int result; #ifdef HAVE_PSI_RWLOCK_INTERFACE - if (that->m_psi != NULL) + if (psi_likely(that->m_psi != NULL)) { /* Instrumentation start */ PSI_rwlock_locker *locker; @@ -1078,7 +1078,7 @@ static inline int inline_mysql_rwlock_unlock( { int result; #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); #endif result= rw_unlock(&that->m_rwlock); @@ -1091,7 +1091,7 @@ static inline int inline_mysql_prlock_unlock( { int result; #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); #endif result= rw_pr_unlock(&that->m_prlock); @@ -1135,7 +1135,7 @@ static inline int inline_mysql_cond_destroy( mysql_cond_t *that) { #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); that->m_psi= NULL; @@ -1155,7 +1155,7 @@ static inline int inline_mysql_cond_wait( int result; #ifdef HAVE_PSI_COND_INTERFACE - if (that->m_psi != NULL) + if (psi_likely(that->m_psi != NULL)) { /* Instrumentation start */ PSI_cond_locker *locker; @@ -1192,7 +1192,7 @@ static inline int inline_mysql_cond_timedwait( int result; #ifdef HAVE_PSI_COND_INTERFACE - if (that->m_psi != NULL) + if (psi_likely(that->m_psi != NULL)) { /* Instrumentation start */ 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); /* Instrumentation end */ - if (locker != NULL) + if (psi_likely(locker != NULL)) PSI_COND_CALL(end_cond_wait)(locker, result); return result; @@ -1222,7 +1222,7 @@ static inline int inline_mysql_cond_signal( { int result; #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); #endif result= pthread_cond_signal(&that->m_cond); @@ -1234,7 +1234,7 @@ static inline int inline_mysql_cond_broadcast( { int result; #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); #endif result= pthread_cond_broadcast(&that->m_cond); diff --git a/include/mysql/psi/psi.h b/include/mysql/psi/psi.h index 3f43445e08a..394dd1b30b4 100644 --- a/include/mysql/psi/psi.h +++ b/include/mysql/psi/psi.h @@ -40,6 +40,21 @@ #error "You must include my_global.h in the code for the build to be correct." #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 struct TABLE_SHARE; @@ -2346,6 +2361,7 @@ typedef struct PSI_stage_info_none PSI_stage_info; #endif /* HAVE_PSI_INTERFACE */ +extern MYSQL_PLUGIN_IMPORT my_bool pfs_enabled; extern MYSQL_PLUGIN_IMPORT PSI *PSI_server; /* diff --git a/include/mysql/psi/psi_abi_v1.h.pp b/include/mysql/psi/psi_abi_v1.h.pp index 17ac0271da2..ef18f59e4a9 100644 --- a/include/mysql/psi/psi_abi_v1.h.pp +++ b/include/mysql/psi/psi_abi_v1.h.pp @@ -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_statement_locker_state_v1 PSI_statement_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; C_MODE_END diff --git a/include/mysql/psi/psi_abi_v2.h.pp b/include/mysql/psi/psi_abi_v2.h.pp index 4e81fd66ca4..adf1af7cfae 100644 --- a/include/mysql/psi/psi_abi_v2.h.pp +++ b/include/mysql/psi/psi_abi_v2.h.pp @@ -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_statement_locker_state_v2 PSI_statement_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; C_MODE_END |