MySQL 8.4.2
Source Code Documentation
pfs_instr_class.h File Reference

Performance schema instruments metadata (declarations). More...

#include "my_config.h"
#include <assert.h>
#include <sys/types.h>
#include <atomic>
#include "lf.h"
#include "my_compiler.h"
#include "my_inttypes.h"
#include "mysql/components/services/bits/psi_metric_bits.h"
#include "mysql_com.h"
#include "mysqld_error.h"
#include "prealloced_array.h"
#include "storage/perfschema/pfs_column_types.h"
#include "storage/perfschema/pfs_global.h"
#include "storage/perfschema/pfs_lock.h"
#include "storage/perfschema/pfs_name.h"
#include "storage/perfschema/pfs_stat.h"
#include "storage/perfschema/terminology_use_previous_enum.h"

Go to the source code of this file.

Classes

struct  PFS_instr_config
 User-defined instrument configuration. More...
 
class  PFS_instr_name
 Encapsulates the name of an instrumented entity. More...
 
struct  PFS_instr_class
 Information for all instrumentation. More...
 
struct  PFS_mutex_class
 Instrumentation metadata for a mutex. More...
 
struct  PFS_rwlock_class
 Instrumentation metadata for a read write lock. More...
 
struct  PFS_cond_class
 Instrumentation metadata for a condition. More...
 
struct  PFS_thread_class
 Instrumentation metadata of a thread. More...
 
struct  PFS_metric_class
 Instrumentation metadata for a metric. More...
 
struct  PFS_meter_class
 Instrumentation metadata for a meter. More...
 
struct  PFS_table_share_key
 Key identifying a table share. More...
 
struct  PFS_table_key
 Table index or 'key'. More...
 
struct  PFS_table_share_index
 Index statistics of a table. More...
 
struct  PFS_table_share_lock
 Lock statistics of a table. More...
 
struct  PFS_table_share
 Instrumentation metadata for a table share. More...
 
struct  PFS_error_class
 Instrumentation metadata for an error. More...
 
struct  PFS_file_class
 Instrumentation metadata for a file. More...
 
struct  PFS_stage_class
 Instrumentation metadata for a stage. More...
 
struct  PFS_statement_class
 Instrumentation metadata for a statement. More...
 
struct  PFS_transaction_class
 Instrumentation metadata for a transaction. More...
 
struct  PFS_socket_class
 Instrumentation metadata for a socket. More...
 
struct  PFS_memory_class
 Instrumentation metadata for a memory. More...
 

Macros

#define PFS_MAX_INFO_NAME_LENGTH   128
 Maximum length of an instrument name. More...
 
#define PFS_MAX_OS_NAME_LENGTH   16
 Maximum length of the thread os name. More...
 
#define PFS_MAX_FULL_PREFIX_NAME_LENGTH   32
 Maximum length of the 'full' prefix of an instrument name. More...
 
#define PFS_MUTEX_PARTITIONS   2
 
#define GLOBAL_TABLE_IO_EVENT_INDEX   0
 
#define GLOBAL_TABLE_LOCK_EVENT_INDEX   1
 
#define GLOBAL_IDLE_EVENT_INDEX   2
 
#define GLOBAL_METADATA_EVENT_INDEX   3
 
#define COUNT_GLOBAL_EVENT_INDEX   4
 Number of global wait events. More...
 
#define GLOBAL_TRANSACTION_INDEX   0
 Transaction events are not wait events . More...
 
#define GLOBAL_ERROR_INDEX   0
 

Typedefs

typedef unsigned int PFS_sync_key
 Key, naming a synch instrument (mutex, rwlock, cond). More...
 
typedef unsigned int PFS_thread_key
 Key, naming a thread instrument. More...
 
typedef unsigned int PFS_file_key
 Key, naming a file instrument. More...
 
typedef unsigned int PFS_stage_key
 Key, naming a stage instrument. More...
 
typedef unsigned int PFS_statement_key
 Key, naming a statement instrument. More...
 
typedef unsigned int PFS_transaction_key
 Key, naming a transaction instrument. More...
 
typedef unsigned int PFS_socket_key
 Key, naming a socket instrument. More...
 
typedef unsigned int PFS_memory_key
 Key, naming a memory instrument. More...
 
typedef unsigned int PFS_meter_key
 Key, naming a meter instrument. More...
 
typedef unsigned int PFS_metric_key
 Key, naming a metric instrument. More...
 
typedef Prealloced_array< PFS_instr_config *, 10 > Pfs_instr_config_array
 

Enumerations

enum  PFS_class_type {
  PFS_CLASS_NONE = 0 , PFS_CLASS_MUTEX = 1 , PFS_CLASS_RWLOCK = 2 , PFS_CLASS_COND = 3 ,
  PFS_CLASS_FILE = 4 , PFS_CLASS_TABLE = 5 , PFS_CLASS_STAGE = 6 , PFS_CLASS_STATEMENT = 7 ,
  PFS_CLASS_TRANSACTION = 8 , PFS_CLASS_SOCKET = 9 , PFS_CLASS_TABLE_IO = 10 , PFS_CLASS_TABLE_LOCK = 11 ,
  PFS_CLASS_IDLE = 12 , PFS_CLASS_MEMORY = 13 , PFS_CLASS_METADATA = 14 , PFS_CLASS_ERROR = 15 ,
  PFS_CLASS_THREAD = 16 , PFS_CLASS_METRIC = 17 , PFS_CLASS_METER = 18 , PFS_CLASS_LAST = PFS_CLASS_METER ,
  PFS_CLASS_MAX = PFS_CLASS_LAST + 1
}
 

Functions

uint sanitize_index_count (uint count)
 
void init_event_name_sizing (const PFS_global_param *param)
 
void register_global_classes ()
 
int init_sync_class (uint mutex_class_sizing, uint rwlock_class_sizing, uint cond_class_sizing)
 Initialize the instrument synch class buffers. More...
 
void cleanup_sync_class ()
 Cleanup the instrument synch class buffers. More...
 
int init_thread_class (uint thread_class_sizing)
 Initialize the thread class buffer. More...
 
void cleanup_thread_class ()
 Cleanup the thread class buffers. More...
 
int init_table_share (uint table_share_sizing)
 Initialize the table share buffer. More...
 
void cleanup_table_share ()
 Cleanup the table share buffers. More...
 
int init_table_share_lock_stat (uint table_stat_sizing)
 Initialize the table lock stat buffer. More...
 
void cleanup_table_share_lock_stat ()
 Cleanup the table stat buffers. More...
 
PFS_table_share_lockcreate_table_share_lock_stat ()
 Create a table share lock instrumentation. More...
 
void release_table_share_lock_stat (PFS_table_share_lock *pfs)
 Release a table share lock instrumentation. More...
 
int init_table_share_index_stat (uint index_stat_sizing)
 Initialize table index stat buffer. More...
 
void cleanup_table_share_index_stat ()
 Cleanup the table stat buffers. More...
 
PFS_table_share_indexcreate_table_share_index_stat (const TABLE_SHARE *server_share, uint server_index)
 Create a table share index instrumentation. More...
 
void release_table_share_index_stat (PFS_table_share_index *pfs)
 Release a table share index instrumentation. More...
 
int init_table_share_hash (const PFS_global_param *param)
 Initialize the table share hash table. More...
 
void cleanup_table_share_hash ()
 Cleanup the table share hash table. More...
 
int init_file_class (uint file_class_sizing)
 Initialize the file class buffer. More...
 
void cleanup_file_class ()
 Cleanup the file class buffers. More...
 
int init_stage_class (uint stage_class_sizing)
 Initialize the stage class buffer. More...
 
void cleanup_stage_class ()
 Cleanup the stage class buffers. More...
 
int init_statement_class (uint statement_class_sizing)
 Initialize the statement class buffer. More...
 
void cleanup_statement_class ()
 Cleanup the statement class buffers. More...
 
int init_socket_class (uint socket_class_sizing)
 Initialize the socket class buffer. More...
 
void cleanup_socket_class ()
 Cleanup the socket class buffers. More...
 
int init_memory_class (uint memory_class_sizing)
 Initialize the memory class buffer. More...
 
void cleanup_memory_class ()
 Cleanup the memory class buffers. More...
 
int init_metric_class (uint metric_class_sizing)
 Initialize the metric class buffer. More...
 
void cleanup_metric_class ()
 Cleanup the metric class buffers. More...
 
int init_meter_class (uint meter_class_sizing)
 Initialize the meter class buffer. More...
 
void cleanup_meter_class ()
 Cleanup the meter class buffers. More...
 
PFS_sync_key register_mutex_class (const char *name, uint name_length, PSI_mutex_info *info)
 Register a mutex instrumentation metadata. More...
 
PFS_sync_key register_rwlock_class (const char *name, uint name_length, PSI_rwlock_info *info)
 Register a rwlock instrumentation metadata. More...
 
PFS_sync_key register_cond_class (const char *name, uint name_length, PSI_cond_info *info)
 Register a condition instrumentation metadata. More...
 
PFS_thread_key register_thread_class (const char *name, uint name_length, PSI_thread_info *info)
 Register a thread instrumentation metadata. More...
 
PFS_file_key register_file_class (const char *name, uint name_length, PSI_file_info *info)
 Register a file instrumentation metadata. More...
 
PFS_stage_key register_stage_class (const char *name, uint prefix_length, uint name_length, PSI_stage_info *info)
 Register a stage instrumentation metadata. More...
 
PFS_statement_key register_statement_class (const char *name, uint name_length, PSI_statement_info *info)
 Register a statement instrumentation metadata. More...
 
PFS_socket_key register_socket_class (const char *name, uint name_length, PSI_socket_info *info)
 Register a socket instrumentation metadata. More...
 
PFS_memory_key register_memory_class (const char *name, uint name_length, PSI_memory_info *info)
 Register a memory instrumentation metadata. More...
 
PFS_meter_key register_meter_class (const char *name, uint name_length, PSI_meter_info_v1 *info)
 Register a meter instrumentation metadata. More...
 
void unregister_meter_class (PSI_meter_info_v1 *info)
 
uint32 meter_class_count ()
 
PFS_metric_key register_metric_class (const char *name, uint name_length, PSI_metric_info_v1 *info, const char *meter)
 Register a metric instrumentation metadata. More...
 
void unregister_metric_class (PSI_metric_info_v1 *info)
 
uint32 metric_class_count ()
 
PFS_mutex_classfind_mutex_class (PFS_sync_key key)
 Find a mutex instrumentation class by key. More...
 
PFS_mutex_classsanitize_mutex_class (PFS_mutex_class *unsafe)
 
PFS_rwlock_classfind_rwlock_class (PFS_sync_key key)
 Find a rwlock instrumentation class by key. More...
 
PFS_rwlock_classsanitize_rwlock_class (PFS_rwlock_class *unsafe)
 
PFS_cond_classfind_cond_class (PFS_sync_key key)
 Find a condition instrumentation class by key. More...
 
PFS_cond_classsanitize_cond_class (PFS_cond_class *unsafe)
 
PFS_thread_classfind_thread_class (PFS_sync_key key)
 Find a thread instrumentation class by key. More...
 
PFS_thread_classsanitize_thread_class (PFS_thread_class *unsafe)
 
PFS_file_classfind_file_class (PFS_file_key key)
 Find a file instrumentation class by key. More...
 
PFS_file_classsanitize_file_class (PFS_file_class *unsafe)
 
PFS_stage_classfind_stage_class (PFS_stage_key key)
 Find a stage instrumentation class by key. More...
 
PFS_stage_classsanitize_stage_class (PFS_stage_class *unsafe)
 
PFS_statement_classfind_statement_class (PFS_stage_key key)
 Find a statement instrumentation class by key. More...
 
PFS_statement_classsanitize_statement_class (PFS_statement_class *unsafe)
 
PFS_instr_classfind_table_class (uint index)
 
PFS_instr_classsanitize_table_class (PFS_instr_class *unsafe)
 
PFS_socket_classfind_socket_class (PFS_socket_key key)
 Find a socket instrumentation class by key. More...
 
PFS_socket_classsanitize_socket_class (PFS_socket_class *unsafe)
 
PFS_memory_classfind_memory_class (PFS_memory_key key)
 Find a memory instrumentation class by key. More...
 
PFS_memory_classsanitize_memory_class (PFS_memory_class *unsafe)
 
PFS_instr_classfind_idle_class (uint index)
 
PFS_instr_classsanitize_idle_class (PFS_instr_class *unsafe)
 
PFS_instr_classfind_metadata_class (uint index)
 
PFS_instr_classsanitize_metadata_class (PFS_instr_class *unsafe)
 
PFS_error_classfind_error_class (uint index)
 
PFS_error_classsanitize_error_class (PFS_instr_class *unsafe)
 
PFS_transaction_classfind_transaction_class (uint index)
 
PFS_transaction_classsanitize_transaction_class (PFS_transaction_class *unsafe)
 
PFS_meter_classfind_meter_class (PSI_meter_key key)
 Find a meter instrumentation class by key. More...
 
PFS_meter_classsanitize_meter_class (PFS_meter_class *unsafe)
 
PFS_metric_classfind_metric_class (PSI_metric_key key)
 Find a metric instrumentation class by key. More...
 
PFS_metric_classsanitize_metric_class (PFS_metric_class *unsafe)
 
PFS_table_sharefind_or_create_table_share (PFS_thread *thread, bool temporary, const TABLE_SHARE *share)
 Find or create a table share instrumentation. More...
 
void release_table_share (PFS_table_share *pfs)
 
void drop_table_share (PFS_thread *thread, bool temporary, const char *schema_name, uint schema_name_length, const char *table_name, uint table_name_length)
 Drop the instrumented table share associated with a table. More...
 
PFS_table_sharesanitize_table_share (PFS_table_share *unsafe)
 Sanitize an unsafe table_share pointer. More...
 
void reset_events_waits_by_class ()
 Reset the wait statistics per instrument class. More...
 
void reset_file_class_io ()
 Reset the I/O statistics per file class. More...
 
void reset_socket_class_io ()
 Reset the I/O statistics per socket class. More...
 
void update_table_share_derived_flags (PFS_thread *thread)
 Update derived flags for all table shares. More...
 
void update_program_share_derived_flags (PFS_thread *thread)
 Update derived flags for all stored procedure shares. More...
 
ulonglong gtid_monitoring_getsystime ()
 Get current time for GTID monitoring. More...
 

Variables

bool pfs_enabled
 Global performance schema flag. More...
 
std::atomic< uint32pfs_unload_plugin_ref_count
 Global ref count for plugin and component events. More...
 
Pfs_instr_config_arraypfs_instr_config_array
 PFS_INSTRUMENT option settings array. More...
 
uint mutex_class_start
 
uint rwlock_class_start
 
uint cond_class_start
 
uint file_class_start
 
uint socket_class_start
 
uint wait_class_max
 
PFS_single_stat global_idle_stat
 Statistics for the IDLE instrument. More...
 
PFS_table_io_stat global_table_io_stat
 Statistics for dropped table I/O. More...
 
PFS_table_lock_stat global_table_lock_stat
 Statistics for dropped table lock. More...
 
PFS_single_stat global_metadata_stat
 Statistics for the METADATA instrument. More...
 
PFS_transaction_stat global_transaction_stat
 Statistics for the transaction instrument. More...
 
PFS_error_stat global_error_stat
 Statistics for the error instrument. More...
 
PFS_instr_class global_table_io_class
 Instrument controlling all table I/O. More...
 
PFS_instr_class global_table_lock_class
 Instrument controlling all table lock. More...
 
PFS_instr_class global_idle_class
 Instrument controlling all idle waits. More...
 
PFS_instr_class global_metadata_class
 Instrument controlling all metadata locks. More...
 
PFS_error_class global_error_class
 Instrument controlling all server errors. More...
 
PFS_transaction_class global_transaction_class
 
ulong mutex_class_max
 Size of the mutex class array. More...
 
ulong mutex_class_lost
 Number of mutex class lost. More...
 
ulong rwlock_class_max
 Size of the rwlock class array. More...
 
ulong rwlock_class_lost
 Number of rwlock class lost. More...
 
ulong cond_class_max
 Size of the condition class array. More...
 
ulong cond_class_lost
 Number of condition class lost. More...
 
ulong thread_class_max
 Size of the thread class array. More...
 
ulong thread_class_lost
 Number of thread class lost. More...
 
ulong file_class_max
 Size of the file class array. More...
 
ulong file_class_lost
 Number of file class lost. More...
 
ulong stage_class_max
 Size of the stage class array. More...
 
ulong stage_class_lost
 Number of stage class lost. More...
 
ulong statement_class_max
 Size of the statement class array. More...
 
ulong statement_class_lost
 Number of statement class lost. More...
 
ulong transaction_class_max
 Number of transaction classes. More...
 
ulong socket_class_max
 Size of the socket class array. More...
 
ulong socket_class_lost
 Number of socket class lost. More...
 
ulong memory_class_max
 Size of the memory class array. More...
 
ulong memory_class_lost
 Number of memory class lost. More...
 
ulong meter_class_max
 Size of the meter class array. More...
 
ulong meter_class_lost
 Number of meter class lost. More...
 
ulong metric_class_max
 Size of the metric class array. More...
 
ulong metric_class_lost
 Number of metric class lost. More...
 
ulong error_class_max
 Number of error classes. More...
 
PFS_mutex_classmutex_class_array
 
PFS_rwlock_classrwlock_class_array
 
PFS_cond_classcond_class_array
 
PFS_file_classfile_class_array
 
PFS_meter_classmeter_class_array
 
PFS_metric_classmetric_class_array
 
LF_HASH table_share_hash
 Hash index for instrumented table shares. More...
 

Detailed Description

Performance schema instruments metadata (declarations).

Macro Definition Documentation

◆ PFS_MAX_FULL_PREFIX_NAME_LENGTH

#define PFS_MAX_FULL_PREFIX_NAME_LENGTH   32

Maximum length of the 'full' prefix of an instrument name.

For example, for the instrument name 'wait/sync/mutex/sql/LOCK_open', the full prefix is 'wait/sync/mutex/sql/', which in turn derives from a prefix 'wait/sync/mutex' for mutexes, and a category of 'sql' for mutexes of the sql layer in the server.

◆ PFS_MAX_INFO_NAME_LENGTH

#define PFS_MAX_INFO_NAME_LENGTH   128

Maximum length of an instrument name.

For example, 'wait/sync/mutex/sql/LOCK_open' is an instrument name.

◆ PFS_MAX_OS_NAME_LENGTH

#define PFS_MAX_OS_NAME_LENGTH   16

Maximum length of the thread os name.

Must include a terminating NUL character. Length is 16 because of linux pthread_setname_np(3)

See also
my_thread_self_setname()