MySQL 8.0.39
Source Code Documentation
pfs_instr_class.h
Go to the documentation of this file.
1/* Copyright (c) 2008, 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef PFS_INSTR_CLASS_H
25#define PFS_INSTR_CLASS_H
26
27#include "my_config.h"
28
29#include <assert.h>
30#include <sys/types.h>
31#include <atomic>
32
33#include "lf.h"
34#include "my_compiler.h"
35
36#include "my_inttypes.h"
37#include "mysql_com.h" /* NAME_LEN */
38#include "mysqld_error.h"
39#include "prealloced_array.h"
46
47struct TABLE_SHARE;
48
49/**
50 @file storage/perfschema/pfs_instr_class.h
51 Performance schema instruments metadata (declarations).
52*/
53
54/**
55 Maximum length of an instrument name.
56 For example, 'wait/sync/mutex/sql/LOCK_open' is an instrument name.
57*/
58#define PFS_MAX_INFO_NAME_LENGTH 128
59
60/**
61 Maximum length of the thread os name.
62 Must include a terminating NUL character.
63 Length is 16 because of linux pthread_setname_np(3)
64 @see my_thread_self_setname()
65*/
66#define PFS_MAX_OS_NAME_LENGTH 16
67
68/**
69 Maximum length of the 'full' prefix of an instrument name.
70 For example, for the instrument name 'wait/sync/mutex/sql/LOCK_open',
71 the full prefix is 'wait/sync/mutex/sql/', which in turn derives from
72 a prefix 'wait/sync/mutex' for mutexes, and a category of 'sql' for mutexes
73 of the sql layer in the server.
74*/
75#define PFS_MAX_FULL_PREFIX_NAME_LENGTH 32
76
77struct PFS_global_param;
78struct PFS_table_share;
79class PFS_opaque_container_page;
80
81/**
82 @addtogroup performance_schema_buffers
83 @{
84*/
85
86extern bool pfs_enabled;
87
88/** Global ref count for plugin and component events. */
89extern std::atomic<uint32> pfs_unload_plugin_ref_count;
90
91/** Key, naming a synch instrument (mutex, rwlock, cond). */
92typedef unsigned int PFS_sync_key;
93/** Key, naming a thread instrument. */
94typedef unsigned int PFS_thread_key;
95/** Key, naming a file instrument. */
96typedef unsigned int PFS_file_key;
97/** Key, naming a stage instrument. */
98typedef unsigned int PFS_stage_key;
99/** Key, naming a statement instrument. */
100typedef unsigned int PFS_statement_key;
101/** Key, naming a transaction instrument. */
102typedef unsigned int PFS_transaction_key;
103/** Key, naming a socket instrument. */
104typedef unsigned int PFS_socket_key;
105/** Key, naming a memory instrument. */
106typedef unsigned int PFS_memory_key;
107
129
130/** User-defined instrument configuration. */
132 /* Instrument name. */
133 char *m_name;
134 /* Name length. */
136 /** Enabled flag. */
138 /** Timed flag. */
140};
141
144
145struct PFS_thread;
146
152extern uint wait_class_max;
153
154/**
155 Encapsulates the name of an instrumented entity.
156*/
158 public:
160 /*
161 DO NOT ACCESS THE DATA MEMBERS DIRECTLY. USE THE GETTERS AND
162 SETTERS INSTEAD.
163
164 The data members should really have been private, but having both
165 private and public members would make the class a non-POD. We
166 need to call memset on PFS_instr_class (in init_instr_class), and
167 the behavior of memset is undefined on non-POD objects. Therefore
168 we keep the data members public, with an underscore prefix, and
169 this warning text.
170 */
171 public /*private*/:
172 /** Instrument name. */
173 char m_private_name[max_length + 1];
174 /** Length in bytes of @c m_name. */
176 /** Old instrument name, if any. */
178 /** Length in bytes of old instrument name len, if any. */
180 /** The oldest version that uses the new name. */
182
183 public:
184 /** Return the name as a string. */
185 const char *str() const;
186 /** Return the length of the string. */
187 uint length() const;
188 /**
189 Copy the specified name to this name.
190
191 @param class_type The class type of this name, i.e., whether it is
192 the name of a mutex, thread, etc.
193
194 @param name The buffer to read from.
195
196 @param max_length_arg If is given, at most that many chars are
197 copied, plus the terminating '\0'. Otherwise, up to buffer_size-1
198 characters are copied, plus the terminating '\0'.
199 */
200 void set(PFS_class_type class_type, const char *name,
201 uint max_length_arg = max_length);
202};
203
204/** Information for all instrumentation. */
206 /** Class type */
208 /** True if this instrument is enabled. */
210 /** True if this instrument is timed. */
212 /** Instrument flags. */
214 /** Instrument enforced flags. */
216 /** Volatility index. */
218 /**
219 Instrument name index.
220 Self index in:
221 - EVENTS_WAITS_SUMMARY_*_BY_EVENT_NAME for waits
222 - EVENTS_STAGES_SUMMARY_*_BY_EVENT_NAME for stages
223 - EVENTS_STATEMENTS_SUMMARY_*_BY_EVENT_NAME for statements
224 - EVENTS_TRANSACTIONS_SUMMARY_*_BY_EVENT_NAME for transactions
225 */
227 /** Instrument name. */
229 /** Documentation. */
231
232 bool is_singleton() const { return m_flags & PSI_FLAG_SINGLETON; }
233
234 bool is_mutable() const { return m_flags & PSI_FLAG_MUTABLE; }
235
236 bool is_progress() const { return m_flags & PSI_FLAG_STAGE_PROGRESS; }
237
239
240 bool is_priority() const { return m_flags & PSI_FLAG_RWLOCK_PR; }
241
242 bool is_transferable() const { return m_flags & PSI_FLAG_TRANSFER; }
243
244 bool is_user() const { return m_flags & PSI_FLAG_USER; }
245
247
248 bool is_global() const { return m_flags & PSI_FLAG_ONLY_GLOBAL_STAT; }
249
250 bool has_seqnum() const {
252 }
253
255
257
260 }
261
262 bool is_disabled() const { return m_flags & PSI_FLAG_DISABLED; }
263
264 bool is_untimed() const { return m_flags & PSI_FLAG_UNTIMED; }
265
267
268 void enforce_valid_flags(uint allowed_flags) {
269 /* Reserved for future use. */
270 allowed_flags |= PSI_FLAG_THREAD | PSI_FLAG_TRANSFER;
271
272 const uint valid_flags = m_flags & allowed_flags;
273 /*
274 This fails when the instrumented code is providing
275 flags that are not supported for this instrument.
276 To fix it, clean up the instrumented code.
277 */
278 assert(valid_flags == m_flags);
279 m_flags = valid_flags;
280 }
281
283 static void set_timed(PFS_instr_class *pfs, bool timed);
284
285 bool is_deferred() const {
286 switch (m_type) {
287 case PFS_CLASS_SOCKET:
288 return true;
289 break;
290 default:
291 return false;
292 break;
293 };
294 }
295
296 bool can_be_timed() const {
297 switch (m_type) {
298 case PFS_CLASS_MEMORY:
299 case PFS_CLASS_ERROR:
300 case PFS_CLASS_THREAD:
301 return false;
302 default:
303 return true;
304 };
305 }
306
307 bool can_be_enforced() const {
308 switch (m_type) {
309 case PFS_CLASS_MEMORY:
310 return true;
311 default:
312 return false;
313 };
314 }
315};
316
317struct PFS_mutex;
318
319#define PFS_MUTEX_PARTITIONS 2
320
321/** Instrumentation metadata for a mutex. */
323 /** Mutex usage statistics. */
325 /** Singleton instance. */
327};
328
329struct PFS_rwlock;
330
331/** Instrumentation metadata for a read write lock. */
333 /** Rwlock usage statistics. */
335 /** Singleton instance. */
337};
338
339struct PFS_cond;
340
341/** Instrumentation metadata for a condition. */
343 /**
344 Condition usage statistics.
345 This statistic is not exposed in user visible tables yet.
346 */
348 /** Singleton instance. */
350};
351
352/** Instrumentation metadata of a thread. */
354 /** Singleton instance. */
356 /** Thread history instrumentation flag. */
357 bool m_history{false};
358 /** Thread os name. */
359 char m_os_name[PFS_MAX_OS_NAME_LENGTH];
360 /** Thread instance sequence number counter. */
361 std::atomic<unsigned int> m_seqnum;
362};
363
364/** Key identifying a table share. */
366 /** Object type. */
368
369 /** Table schema. */
371
372 /** Table name. */
374};
375
376/** Table index or 'key' */
378 /** Index name */
380 /** Length in bytes of @c m_name. */
382};
383
384/** Index statistics of a table.*/
387 /** The index name */
389 /** The index stat */
391 /** Owner table share. To be used later. */
393 /** Container page. */
394 PFS_opaque_container_page *m_page;
395};
396
397/** Lock statistics of a table.*/
400 /** Lock stats. */
402 /** Owner table share. To be used later. */
404 /** Container page. */
405 PFS_opaque_container_page *m_page;
406};
407
408/** Instrumentation metadata for a table share. */
410 public:
411 uint32 get_version() { return m_lock.get_version(); }
412
413 enum_object_type get_object_type() const { return m_key.m_type; }
414
415 void aggregate_io();
416 void aggregate_lock();
417
418 void sum_io(PFS_single_stat *result, uint key_count);
419 void sum_lock(PFS_single_stat *result);
420 void sum(PFS_single_stat *result, uint key_count);
421
422 inline void aggregate() {
423 aggregate_io();
424 aggregate_lock();
425 }
426
427 inline void init_refcount() { m_refcount.store(1); }
428
429 inline int get_refcount() { return m_refcount.load(); }
430
431 inline void inc_refcount() { ++m_refcount; }
432
433 inline void dec_refcount() { --m_refcount; }
434
435 void refresh_setup_object_flags(PFS_thread *thread);
436
437 /** Internal lock. */
439 /**
440 True if table instrumentation is enabled.
441 This flag is computed from the content of table setup_objects.
442 */
444 /**
445 True if table instrumentation is timed.
446 This flag is computed from the content of table setup_objects.
447 */
449
450 /** Search key. */
452
453 /** Number of indexes. */
455 /** Container page. */
456 PFS_opaque_container_page *m_page;
457
458 PFS_table_share_lock *find_lock_stat() const;
459 PFS_table_share_lock *find_or_create_lock_stat();
460 void destroy_lock_stat();
461
462 PFS_table_share_index *find_index_stat(uint index) const;
463 PFS_table_share_index *find_or_create_index_stat(
464 const TABLE_SHARE *server_share, uint index);
465 void destroy_index_stats();
466
467 private:
468 /** Number of opened table handles. */
469 std::atomic<int> m_refcount;
470 /** Table locks statistics. */
471 std::atomic<PFS_table_share_lock *> m_race_lock_stat;
472 /** Table indexes stats. */
473 std::atomic<PFS_table_share_index *> m_race_index_stat[MAX_INDEXES + 1];
474};
475
476/** Statistics for the IDLE instrument. */
478/** Statistics for dropped table I/O. */
480/** Statistics for dropped table lock. */
482/** Statistics for the METADATA instrument. */
484/** Statistics for the transaction instrument. */
486/** Statistics for the error instrument. */
488
490 if (likely(count <= MAX_INDEXES)) {
491 return count;
492 }
493 return 0;
494}
495
496#define GLOBAL_TABLE_IO_EVENT_INDEX 0
497#define GLOBAL_TABLE_LOCK_EVENT_INDEX 1
498#define GLOBAL_IDLE_EVENT_INDEX 2
499#define GLOBAL_METADATA_EVENT_INDEX 3
500/** Number of global wait events. */
501#define COUNT_GLOBAL_EVENT_INDEX 4
502
503/** Transaction events are not wait events .*/
504#define GLOBAL_TRANSACTION_INDEX 0
505
506#define GLOBAL_ERROR_INDEX 0
507
508/**
509 Instrument controlling all table I/O.
510 This instrument is used with table SETUP_OBJECTS.
511*/
513
514/**
515 Instrument controlling all table lock.
516 This instrument is used with table SETUP_OBJECTS.
517*/
519
520/**
521 Instrument controlling all idle waits.
522*/
524
525/**
526 Instrument controlling all metadata locks.
527*/
529
530/** Instrumentation metadata for an error. */
532/**
533 Instrument controlling all server errors.
534*/
536
537struct PFS_file;
538
539/** Instrumentation metadata for a file. */
541 /** File usage statistics. */
543 /** Singleton instance. */
545};
546
547/** Instrumentation metadata for a stage. */
549 /**
550 Length of the @c "stage/<component>/" prefix.
551 This is to extract @c "foo" from @c "stage/sql/foo".
552 */
554 /** Stage usage statistics. */
556};
557
558/** Instrumentation metadata for a statement. */
560
561/** Instrumentation metadata for a transaction. */
563
565
566struct PFS_socket;
567
568/** Instrumentation metadata for a socket. */
570 /** Socket usage statistics. */
572 /** Singleton instance. */
574};
575
576/** Instrumentation metadata for a memory. */
578
580
582
583int init_sync_class(uint mutex_class_sizing, uint rwlock_class_sizing,
584 uint cond_class_sizing);
585
586void cleanup_sync_class();
587int init_thread_class(uint thread_class_sizing);
589int init_table_share(uint table_share_sizing);
591
592int init_table_share_lock_stat(uint table_stat_sizing);
596
597int init_table_share_index_stat(uint index_stat_sizing);
600 uint index);
602
605int init_file_class(uint file_class_sizing);
606void cleanup_file_class();
607int init_stage_class(uint stage_class_sizing);
609int init_statement_class(uint statement_class_sizing);
611int init_socket_class(uint socket_class_sizing);
613int init_memory_class(uint memory_class_sizing);
615
616PFS_sync_key register_mutex_class(const char *name, uint name_length,
618
619PFS_sync_key register_rwlock_class(const char *name, uint name_length,
621
622PFS_sync_key register_cond_class(const char *name, uint name_length,
624
625PFS_thread_key register_thread_class(const char *name, uint name_length,
627
628PFS_file_key register_file_class(const char *name, uint name_length,
630
631PFS_stage_key register_stage_class(const char *name, uint prefix_length,
632 uint name_length, PSI_stage_info *info);
633
634PFS_statement_key register_statement_class(const char *name, uint name_length,
636
637PFS_socket_key register_socket_class(const char *name, uint name_length,
639
640PFS_memory_key register_memory_class(const char *name, uint name_length,
642
671 PFS_transaction_class *unsafe);
672
674 const TABLE_SHARE *share);
676void drop_table_share(PFS_thread *thread, bool temporary,
677 const char *schema_name, uint schema_name_length,
678 const char *table_name, uint table_name_length);
679
681
682extern ulong mutex_class_max;
683extern ulong mutex_class_lost;
684extern ulong rwlock_class_max;
685extern ulong rwlock_class_lost;
686extern ulong cond_class_max;
687extern ulong cond_class_lost;
688extern ulong thread_class_max;
689extern ulong thread_class_lost;
690extern ulong file_class_max;
691extern ulong file_class_lost;
692extern ulong stage_class_max;
693extern ulong stage_class_lost;
694extern ulong statement_class_max;
695extern ulong statement_class_lost;
696extern ulong transaction_class_max;
697extern ulong socket_class_max;
698extern ulong socket_class_lost;
699extern ulong memory_class_max;
700extern ulong memory_class_lost;
701extern ulong error_class_max;
702
703/* Exposing the data directly, for iterators. */
704
709
713
714/** Update derived flags for all table shares. */
716
717/** Update derived flags for all stored procedure shares. */
719
721
722/**
723 Get current time for GTID monitoring.
724
725 @return my_getsystime() when PFS monitoring is enabled.
726 @return 0 when PFS monitoring is disabled.
727*/
729
730/** @} */
731#endif
Encapsulates the name of an instrumented entity.
Definition: pfs_instr_class.h:157
const char * m_private_old_name
Old instrument name, if any.
Definition: pfs_instr_class.h:177
terminology_use_previous::enum_compatibility_version m_private_version
The oldest version that uses the new name.
Definition: pfs_instr_class.h:181
uint m_private_old_name_length
Length in bytes of old instrument name len, if any.
Definition: pfs_instr_class.h:179
static constexpr uint max_length
Definition: pfs_instr_class.h:159
uint m_private_name_length
Length in bytes of m_name.
Definition: pfs_instr_class.h:175
A typesafe replacement for DYNAMIC_ARRAY.
Definition: prealloced_array.h:71
#define PSI_FLAG_SINGLETON
Singleton flag.
Definition: component_common.h:35
void release_table_share(TABLE_SHARE *share)
Mark that we are not using table share anymore.
Definition: sql_base.cc:982
PFS_instr_class global_metadata_class
Instrument controlling all metadata locks.
Definition: pfs_instr_class.cc:177
LF_HASH table_share_hash
Hash index for instrumented table shares.
Definition: pfs_instr_class.cc:190
PFS_sync_key register_rwlock_class(const char *name, uint name_length, PSI_rwlock_info *info)
Register a rwlock instrumentation metadata.
Definition: pfs_instr_class.cc:1211
PFS_thread_class * sanitize_thread_class(PFS_thread_class *unsafe)
Definition: pfs_instr_class.cc:1414
uint socket_class_start
Definition: pfs_instr_class.cc:224
PFS_socket_class * sanitize_socket_class(PFS_socket_class *unsafe)
Definition: pfs_instr_class.cc:1664
unsigned int PFS_transaction_key
Key, naming a transaction instrument.
Definition: pfs_instr_class.h:102
PFS_rwlock_class * find_rwlock_class(PFS_sync_key key)
Find a rwlock instrumentation class by key.
Definition: pfs_instr_class.cc:1318
ulong error_class_max
Number of error classes.
Definition: pfs_instr_class.cc:151
PFS_socket_key register_socket_class(const char *name, uint name_length, PSI_socket_info *info)
Register a socket instrumentation metadata.
Definition: pfs_instr_class.cc:1620
ulong stage_class_max
Size of the stage class array.
Definition: pfs_instr_class.cc:123
PFS_stage_key register_stage_class(const char *name, uint prefix_length, uint name_length, PSI_stage_info *info)
Register a stage instrumentation metadata.
Definition: pfs_instr_class.cc:1469
unsigned int PFS_file_key
Key, naming a file instrument.
Definition: pfs_instr_class.h:96
void cleanup_memory_class()
Cleanup the memory class buffers.
Definition: pfs_instr_class.cc:1012
unsigned int PFS_sync_key
Key, naming a synch instrument (mutex, rwlock, cond).
Definition: pfs_instr_class.h:92
PFS_rwlock_class * rwlock_class_array
Definition: pfs_instr_class.cc:154
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.
Definition: pfs_instr_class.cc:2025
int init_table_share(uint table_share_sizing)
Initialize the table share buffer.
Definition: pfs_instr_class.cc:473
void cleanup_table_share_index_stat()
Cleanup the table stat buffers.
Definition: pfs_instr_class.cc:819
ulonglong gtid_monitoring_getsystime()
Get current time for GTID monitoring.
Definition: pfs_instr_class.cc:2127
PFS_instr_class global_table_lock_class
Instrument controlling all table lock.
Definition: pfs_instr_class.cc:175
uint mutex_class_start
Definition: pfs_instr_class.cc:219
PFS_instr_class global_idle_class
Instrument controlling all idle waits.
Definition: pfs_instr_class.cc:176
ulong thread_class_max
Size of the thread class array.
Definition: pfs_instr_class.cc:115
ulong socket_class_lost
Number of socket class lost.
Definition: pfs_instr_class.cc:133
void cleanup_table_share_lock_stat()
Cleanup the table stat buffers.
Definition: pfs_instr_class.cc:761
PFS_table_share * find_or_create_table_share(PFS_thread *thread, bool temporary, const TABLE_SHARE *share)
Find or create a table share instrumentation.
Definition: pfs_instr_class.cc:1835
PFS_instr_class * find_metadata_class(uint index)
Definition: pfs_instr_class.cc:1756
uint sanitize_index_count(uint count)
Definition: pfs_instr_class.h:489
ulong socket_class_max
Size of the socket class array.
Definition: pfs_instr_class.cc:131
unsigned int PFS_socket_key
Key, naming a socket instrument.
Definition: pfs_instr_class.h:104
ulong rwlock_class_lost
Number of rwlock class lost.
Definition: pfs_instr_class.cc:109
int init_table_share_lock_stat(uint table_stat_sizing)
Initialize the table lock stat buffer.
Definition: pfs_instr_class.cc:725
PFS_stage_class * sanitize_stage_class(PFS_stage_class *unsafe)
Definition: pfs_instr_class.cc:1594
PFS_cond_class * find_cond_class(PFS_sync_key key)
Find a condition instrumentation class by key.
Definition: pfs_instr_class.cc:1332
Prealloced_array< PFS_instr_config *, 10 > Pfs_instr_config_array
Definition: pfs_instr_class.h:142
int init_file_class(uint file_class_sizing)
Initialize the file class buffer.
Definition: pfs_instr_class.cc:828
uint length() const
Return the length of the string.
Definition: pfs_instr_class.cc:234
PFS_file_key register_file_class(const char *name, uint name_length, PSI_file_info *info)
Register a file instrumentation metadata.
Definition: pfs_instr_class.cc:1426
Pfs_instr_config_array * pfs_instr_config_array
PFS_INSTRUMENT option settings array.
Definition: pfs_instr_class.cc:80
ulong memory_class_lost
Number of memory class lost.
Definition: pfs_instr_class.cc:137
ulong statement_class_lost
Number of statement class lost.
Definition: pfs_instr_class.cc:129
PFS_stage_class * find_stage_class(PFS_stage_key key)
Find a stage instrumentation class by key.
Definition: pfs_instr_class.cc:1590
uint cond_class_start
Definition: pfs_instr_class.cc:221
PFS_statement_class * find_statement_class(PFS_stage_key key)
Find a statement instrumentation class by key.
Definition: pfs_instr_class.cc:1604
ulong cond_class_max
Size of the condition class array.
Definition: pfs_instr_class.cc:111
ulong mutex_class_lost
Number of mutex class lost.
Definition: pfs_instr_class.cc:105
PFS_statement_class * sanitize_statement_class(PFS_statement_class *unsafe)
Definition: pfs_instr_class.cc:1608
unsigned int PFS_memory_key
Key, naming a memory instrument.
Definition: pfs_instr_class.h:106
PFS_table_lock_stat global_table_lock_stat
Statistics for dropped table lock.
Definition: pfs_instr_class.cc:170
void register_global_classes()
Definition: pfs_instr_class.cc:287
ulong memory_class_max
Size of the memory class array.
Definition: pfs_instr_class.cc:135
void reset_file_class_io()
Reset the I/O statistics per file class.
Definition: pfs_instr_class.cc:2070
uint wait_class_max
Definition: pfs_instr_class.cc:223
PFS_table_share_lock * create_table_share_lock_stat()
Create a table share lock instrumentation.
Definition: pfs_instr_class.cc:737
PFS_transaction_class * find_transaction_class(uint index)
Definition: pfs_instr_class.cc:1784
PFS_statement_key register_statement_class(const char *name, uint name_length, PSI_statement_info *info)
Register a statement instrumentation metadata.
Definition: pfs_instr_class.cc:1520
void update_table_share_derived_flags(PFS_thread *thread)
Update derived flags for all table shares.
Definition: pfs_instr_class.cc:2103
ulong stage_class_lost
Number of stage class lost.
Definition: pfs_instr_class.cc:125
PFS_thread_key register_thread_class(const char *name, uint name_length, PSI_thread_info *info)
Register a thread instrumentation metadata.
Definition: pfs_instr_class.cc:1347
void cleanup_stage_class()
Cleanup the stage class buffers.
Definition: pfs_instr_class.cc:889
PFS_cond_class * sanitize_cond_class(PFS_cond_class *unsafe)
Definition: pfs_instr_class.cc:1336
PFS_instr_class * sanitize_idle_class(PFS_instr_class *unsafe)
Definition: pfs_instr_class.cc:1749
PFS_error_stat global_error_stat
Statistics for the error instrument.
Definition: pfs_instr_class.cc:173
PFS_thread_class * find_thread_class(PFS_sync_key key)
Find a thread instrumentation class by key.
Definition: pfs_instr_class.cc:1410
PFS_table_io_stat global_table_io_stat
Statistics for dropped table I/O.
Definition: pfs_instr_class.cc:169
PFS_sync_key register_cond_class(const char *name, uint name_length, PSI_cond_info *info)
Register a condition instrumentation metadata.
Definition: pfs_instr_class.cc:1259
PFS_instr_class * sanitize_metadata_class(PFS_instr_class *unsafe)
Definition: pfs_instr_class.cc:1763
PFS_mutex_class * sanitize_mutex_class(PFS_mutex_class *unsafe)
Definition: pfs_instr_class.cc:1308
PFS_error_class global_error_class
Instrument controlling all server errors.
Definition: pfs_instr_class.cc:178
uint file_class_start
Definition: pfs_instr_class.cc:222
PFS_transaction_stat global_transaction_stat
Statistics for the transaction instrument.
Definition: pfs_instr_class.cc:172
PFS_cond_class * cond_class_array
Definition: pfs_instr_class.cc:155
PFS_rwlock_class * sanitize_rwlock_class(PFS_rwlock_class *unsafe)
Definition: pfs_instr_class.cc:1322
ulong file_class_lost
Number of file class lost.
Definition: pfs_instr_class.cc:121
PFS_error_class * sanitize_error_class(PFS_instr_class *unsafe)
int init_stage_class(uint stage_class_sizing)
Initialize the stage class buffer.
Definition: pfs_instr_class.cc:869
PFS_instr_class * find_idle_class(uint index)
Definition: pfs_instr_class.cc:1742
int init_thread_class(uint thread_class_sizing)
Initialize the thread class buffer.
Definition: pfs_instr_class.cc:431
void init_event_name_sizing(const PFS_global_param *param)
Definition: pfs_instr_class.cc:277
int init_socket_class(uint socket_class_sizing)
Initialize the socket class buffer.
Definition: pfs_instr_class.cc:951
PFS_socket_class * find_socket_class(PFS_socket_key key)
Find a socket instrumentation class by key.
Definition: pfs_instr_class.cc:1660
void update_program_share_derived_flags(PFS_thread *thread)
Update derived flags for all stored procedure shares.
Definition: pfs_instr_class.cc:2122
PFS_error_class * find_error_class(uint index)
Definition: pfs_instr_class.cc:1770
PFS_file_class * sanitize_file_class(PFS_file_class *unsafe)
Definition: pfs_instr_class.cc:1581
unsigned int PFS_stage_key
Key, naming a stage instrument.
Definition: pfs_instr_class.h:98
std::atomic< uint32 > pfs_unload_plugin_ref_count
Global ref count for plugin and component events.
void cleanup_thread_class()
Cleanup the thread class buffers.
Definition: pfs_instr_class.cc:452
int init_statement_class(uint statement_class_sizing)
Initialize the statement class buffer.
Definition: pfs_instr_class.cc:910
ulong file_class_max
Size of the file class array.
Definition: pfs_instr_class.cc:119
ulong thread_class_lost
Number of thread class lost.
Definition: pfs_instr_class.cc:117
void reset_events_waits_by_class()
Reset the wait statistics per instrument class.
Definition: pfs_instr_class.cc:2060
PFS_table_share * sanitize_table_share(PFS_table_share *unsafe)
Sanitize an unsafe table_share pointer.
Definition: pfs_instr_class.cc:2055
PFS_memory_key register_memory_class(const char *name, uint name_length, PSI_memory_info *info)
Register a memory instrumentation metadata.
Definition: pfs_instr_class.cc:1676
PFS_transaction_class global_transaction_class
Definition: pfs_instr_class.cc:179
unsigned int PFS_statement_key
Key, naming a statement instrument.
Definition: pfs_instr_class.h:100
PFS_single_stat global_idle_stat
Statistics for the IDLE instrument.
Definition: pfs_instr_class.cc:168
unsigned int PFS_thread_key
Key, naming a thread instrument.
Definition: pfs_instr_class.h:94
int init_table_share_index_stat(uint index_stat_sizing)
Initialize table index stat buffer.
Definition: pfs_instr_class.cc:770
PFS_sync_key register_mutex_class(const char *name, uint name_length, PSI_mutex_info *info)
Register a mutex instrumentation metadata.
Definition: pfs_instr_class.cc:1114
PFS_memory_class * sanitize_memory_class(PFS_memory_class *unsafe)
Definition: pfs_instr_class.cc:1719
void cleanup_file_class()
Cleanup the file class buffers.
Definition: pfs_instr_class.cc:848
bool pfs_enabled
Global performance schema flag.
Definition: pfs_instr_class.cc:68
uint rwlock_class_start
Definition: pfs_instr_class.cc:220
PFS_class_type
Definition: pfs_instr_class.h:108
ulong mutex_class_max
Size of the mutex class array.
Definition: pfs_instr_class.cc:103
PFS_single_stat global_metadata_stat
Statistics for the METADATA instrument.
Definition: pfs_instr_class.cc:171
ulong statement_class_max
Size of the statement class array.
Definition: pfs_instr_class.cc:127
void cleanup_table_share_hash()
Cleanup the table share hash table.
Definition: pfs_instr_class.cc:563
const char * str() const
Return the name as a string.
Definition: pfs_instr_class.cc:226
PFS_instr_class global_table_io_class
Instrument controlling all table I/O.
Definition: pfs_instr_class.cc:174
void reset_socket_class_io()
Reset the I/O statistics per socket class.
Definition: pfs_instr_class.cc:2080
PFS_instr_class * sanitize_table_class(PFS_instr_class *unsafe)
Definition: pfs_instr_class.cc:1734
int init_table_share_hash(const PFS_global_param *param)
Initialize the table share hash table.
Definition: pfs_instr_class.cc:552
void cleanup_table_share()
Cleanup the table share buffers.
Definition: pfs_instr_class.cc:482
ulong rwlock_class_max
Size of the rwlock class array.
Definition: pfs_instr_class.cc:107
void cleanup_socket_class()
Cleanup the socket class buffers.
Definition: pfs_instr_class.cc:971
void set(PFS_class_type class_type, const char *name, uint max_length_arg=max_length)
Copy the specified name to this name.
Definition: pfs_instr_class.cc:259
ulong cond_class_lost
Number of condition class lost.
Definition: pfs_instr_class.cc:113
PFS_memory_class * find_memory_class(PFS_memory_key key)
Find a memory instrumentation class by key.
Definition: pfs_instr_class.cc:1715
PFS_transaction_class * sanitize_transaction_class(PFS_transaction_class *unsafe)
Definition: pfs_instr_class.cc:1791
ulong transaction_class_max
Number of transaction classes.
Definition: pfs_instr_class.cc:144
void cleanup_sync_class()
Cleanup the instrument synch class buffers.
Definition: pfs_instr_class.cc:388
int init_memory_class(uint memory_class_sizing)
Initialize the memory class buffer.
Definition: pfs_instr_class.cc:992
void release_table_share_lock_stat(PFS_table_share_lock *pfs)
Release a table share lock instrumentation.
Definition: pfs_instr_class.cc:755
void cleanup_statement_class()
Cleanup the statement class buffers.
Definition: pfs_instr_class.cc:930
void release_table_share_index_stat(PFS_table_share_index *pfs)
Release a table share index instrumentation.
Definition: pfs_instr_class.cc:813
PFS_mutex_class * mutex_class_array
Definition: pfs_instr_class.cc:153
PFS_instr_class * find_table_class(uint index)
Definition: pfs_instr_class.cc:1724
PFS_table_share_index * create_table_share_index_stat(const TABLE_SHARE *server_share, uint server_index)
Create a table share index instrumentation.
Definition: pfs_instr_class.cc:782
int init_sync_class(uint mutex_class_sizing, uint rwlock_class_sizing, uint cond_class_sizing)
Initialize the instrument synch class buffers.
Definition: pfs_instr_class.cc:343
PFS_mutex_class * find_mutex_class(PFS_sync_key key)
Find a mutex instrumentation class by key.
Definition: pfs_instr_class.cc:1304
PFS_file_class * file_class_array
Definition: pfs_instr_class.cc:197
PFS_file_class * find_file_class(PFS_file_key key)
Find a file instrumentation class by key.
Definition: pfs_instr_class.cc:1577
@ PFS_CLASS_MAX
Definition: pfs_instr_class.h:127
@ PFS_CLASS_IDLE
Definition: pfs_instr_class.h:121
@ PFS_CLASS_LAST
Definition: pfs_instr_class.h:126
@ PFS_CLASS_MUTEX
Definition: pfs_instr_class.h:110
@ PFS_CLASS_STAGE
Definition: pfs_instr_class.h:115
@ PFS_CLASS_NONE
Definition: pfs_instr_class.h:109
@ PFS_CLASS_TABLE
Definition: pfs_instr_class.h:114
@ PFS_CLASS_TABLE_LOCK
Definition: pfs_instr_class.h:120
@ PFS_CLASS_FILE
Definition: pfs_instr_class.h:113
@ PFS_CLASS_TABLE_IO
Definition: pfs_instr_class.h:119
@ PFS_CLASS_METADATA
Definition: pfs_instr_class.h:123
@ PFS_CLASS_RWLOCK
Definition: pfs_instr_class.h:111
@ PFS_CLASS_COND
Definition: pfs_instr_class.h:112
@ PFS_CLASS_MEMORY
Definition: pfs_instr_class.h:122
@ PFS_CLASS_THREAD
Definition: pfs_instr_class.h:125
@ PFS_CLASS_ERROR
Definition: pfs_instr_class.h:124
@ PFS_CLASS_STATEMENT
Definition: pfs_instr_class.h:116
@ PFS_CLASS_SOCKET
Definition: pfs_instr_class.h:118
@ PFS_CLASS_TRANSACTION
Definition: pfs_instr_class.h:117
unsigned int PSI_cond_key
Instrumented cond key.
Definition: psi_cond_bits.h:44
unsigned int PSI_file_key
Instrumented file key.
Definition: psi_file_bits.h:48
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:49
unsigned int PSI_mutex_key
Instrumented mutex key.
Definition: psi_mutex_bits.h:52
unsigned int PSI_rwlock_key
Instrumented rwlock key.
Definition: psi_rwlock_bits.h:44
unsigned int PSI_socket_key
Instrumented socket key.
Definition: psi_socket_bits.h:49
unsigned int PSI_stage_key
Instrumented stage key.
Definition: psi_stage_bits.h:43
unsigned int PSI_statement_key
Instrumented statement key.
Definition: psi_statement_bits.h:49
unsigned int PSI_thread_key
Instrumented thread key.
Definition: psi_thread_bits.h:50
#define PSI_FLAG_USER
User flag.
Definition: psi_bits.h:103
#define PSI_FLAG_TRANSFER
Transferable flag.
Definition: psi_bits.h:95
#define PSI_FLAG_DISABLED
Instrument is disabled by default.
Definition: psi_bits.h:146
#define PSI_FLAG_MUTABLE
Mutable flag.
Definition: psi_bits.h:68
#define PSI_FLAG_STAGE_PROGRESS
Stage progress flag.
Definition: psi_bits.h:82
#define PSI_FLAG_RWLOCK_SX
Shared Exclusive flag.
Definition: psi_bits.h:88
#define PSI_FLAG_UNTIMED
Instrument is not timed by default.
Definition: psi_bits.h:151
#define PSI_FLAG_NO_SEQNUM
No sequence number flag.
Definition: psi_bits.h:136
#define PSI_FLAG_THREAD
Per Thread flag.
Definition: psi_bits.h:75
#define PSI_FLAG_AUTO_SEQNUM
Automatic sequence number flag.
Definition: psi_bits.h:130
#define PSI_FLAG_MEM_COLLECT
Enable collecting the memory consumed by threads.
Definition: psi_bits.h:141
#define PSI_FLAG_THREAD_SYSTEM
System thread flag.
Definition: psi_bits.h:124
#define PSI_FLAG_RWLOCK_PR
Priority lock flag.
Definition: psi_bits.h:118
#define PSI_FLAG_ONLY_GLOBAL_STAT
Global stat only flag.
Definition: psi_bits.h:112
static int flags[50]
Definition: hp_test1.cc:40
#define MAX_INDEXES
Definition: config.h:210
Header for compiler-dependent features.
constexpr bool likely(bool expr)
Definition: my_compiler.h:55
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
uint32_t uint32
Definition: my_inttypes.h:67
static int count
Definition: myisam_ftdump.cc:43
Common definition between mysql server & client.
#define NAME_LEN
Definition: mysql_com.h:67
Log info(cout, "NOTE")
const char * table_name
Definition: rules_table_service.cc:56
enum_compatibility_version
Enumeration holding the possible values for @terminology_use_previous.
Definition: terminology_use_previous_enum.h:48
Data types for columns used in the performance schema tables (declarations)
enum_object_type
Enum values for the various OBJECT_TYPE columns.
Definition: pfs_column_types.h:222
Miscellaneous global dependencies (declarations).
#define PFS_ALIGNED
Definition: pfs_global.h:57
#define PFS_MAX_OS_NAME_LENGTH
Maximum length of the thread os name.
Definition: pfs_instr_class.h:66
#define PFS_MAX_INFO_NAME_LENGTH
Maximum length of an instrument name.
Definition: pfs_instr_class.h:58
Performance schema internal locks (declarations).
Object names (declarations).
Statistics (declarations).
required string key
Definition: replication_asynchronous_connection_failover.proto:60
required bool enabled
Definition: replication_group_member_actions.proto:33
static const LEX_CSTRING pfs
Definition: sql_show_processlist.cc:66
case opt name
Definition: sslopt-case.h:33
Definition: lf.h:185
Instrumentation metadata for a condition.
Definition: pfs_instr_class.h:342
PFS_cond_stat m_cond_stat
Condition usage statistics.
Definition: pfs_instr_class.h:347
PFS_cond * m_singleton
Singleton instance.
Definition: pfs_instr_class.h:349
Statistics for conditions usage.
Definition: pfs_stat.h:238
Instrumented condition implementation.
Definition: pfs_instr.h:160
Instrumentation metadata for an error.
Definition: pfs_instr_class.h:531
Statistics for all server errors.
Definition: pfs_stat.h:557
Instrumentation metadata for a file.
Definition: pfs_instr_class.h:540
PFS_file * m_singleton
Singleton instance.
Definition: pfs_instr_class.h:544
PFS_file_stat m_file_stat
File usage statistics.
Definition: pfs_instr_class.h:542
Statistics for FILE usage.
Definition: pfs_stat.h:308
Instrumented File and FILE implementation.
Definition: pfs_instr.h:177
Performance schema global sizing parameters.
Definition: pfs_server.h:113
Information for all instrumentation.
Definition: pfs_instr_class.h:205
bool is_deferred() const
Definition: pfs_instr_class.h:285
bool m_enabled
True if this instrument is enabled.
Definition: pfs_instr_class.h:209
static void set_enabled(PFS_instr_class *pfs, bool enabled)
uint m_flags
Instrument flags.
Definition: pfs_instr_class.h:213
bool is_untimed() const
Definition: pfs_instr_class.h:264
bool is_singleton() const
Definition: pfs_instr_class.h:232
PFS_class_type m_type
Class type.
Definition: pfs_instr_class.h:207
bool is_priority() const
Definition: pfs_instr_class.h:240
static void set_timed(PFS_instr_class *pfs, bool timed)
void set_enforced_flags(uint flags)
Definition: pfs_instr_class.h:266
bool is_progress() const
Definition: pfs_instr_class.h:236
bool can_be_timed() const
Definition: pfs_instr_class.h:296
bool is_transferable() const
Definition: pfs_instr_class.h:242
bool has_enforced_memory_cnt() const
Definition: pfs_instr_class.h:258
PFS_instr_name m_name
Instrument name.
Definition: pfs_instr_class.h:228
bool has_default_memory_cnt() const
Definition: pfs_instr_class.h:256
uint m_event_name_index
Instrument name index.
Definition: pfs_instr_class.h:226
bool has_auto_seqnum() const
Definition: pfs_instr_class.h:254
bool is_disabled() const
Definition: pfs_instr_class.h:262
bool m_timed
True if this instrument is timed.
Definition: pfs_instr_class.h:211
bool can_be_enforced() const
Definition: pfs_instr_class.h:307
bool is_global() const
Definition: pfs_instr_class.h:248
char * m_documentation
Documentation.
Definition: pfs_instr_class.h:230
bool is_user() const
Definition: pfs_instr_class.h:244
uint m_enforced_flags
Instrument enforced flags.
Definition: pfs_instr_class.h:215
bool is_mutable() const
Definition: pfs_instr_class.h:234
bool is_shared_exclusive() const
Definition: pfs_instr_class.h:238
int m_volatility
Volatility index.
Definition: pfs_instr_class.h:217
void enforce_valid_flags(uint allowed_flags)
Definition: pfs_instr_class.h:268
bool is_system_thread() const
Definition: pfs_instr_class.h:246
bool has_seqnum() const
Definition: pfs_instr_class.h:250
User-defined instrument configuration.
Definition: pfs_instr_class.h:131
uint m_name_length
Definition: pfs_instr_class.h:135
bool m_enabled
Enabled flag.
Definition: pfs_instr_class.h:137
bool m_timed
Timed flag.
Definition: pfs_instr_class.h:139
char * m_name
Definition: pfs_instr_class.h:133
Instrumentation metadata for a memory.
Definition: pfs_instr_class.h:577
Instrumentation metadata for a mutex.
Definition: pfs_instr_class.h:322
PFS_mutex_stat m_mutex_stat
Mutex usage statistics.
Definition: pfs_instr_class.h:324
PFS_mutex * m_singleton
Singleton instance.
Definition: pfs_instr_class.h:326
Statistics for mutex usage.
Definition: pfs_stat.h:177
Instrumented mutex implementation.
Definition: pfs_instr.h:101
Instrumentation metadata for a read write lock.
Definition: pfs_instr_class.h:332
PFS_rwlock * m_singleton
Singleton instance.
Definition: pfs_instr_class.h:336
PFS_rwlock_stat m_rwlock_stat
Rwlock usage statistics.
Definition: pfs_instr_class.h:334
Statistics for rwlock usage.
Definition: pfs_stat.h:204
Instrumented rwlock implementation.
Definition: pfs_instr.h:127
Definition: pfs_name.h:186
Single statistic.
Definition: pfs_stat.h:52
Instrumentation metadata for a socket.
Definition: pfs_instr_class.h:569
PFS_socket_stat m_socket_stat
Socket usage statistics.
Definition: pfs_instr_class.h:571
PFS_socket * m_singleton
Singleton instance.
Definition: pfs_instr_class.h:573
Statistics for SOCKET usage.
Definition: pfs_stat.h:875
Instrumented socket implementation.
Definition: pfs_instr.h:287
Instrumentation metadata for a stage.
Definition: pfs_instr_class.h:548
uint m_prefix_length
Length of the "stage/<component>/" prefix.
Definition: pfs_instr_class.h:553
PFS_stage_stat m_stage_stat
Stage usage statistics.
Definition: pfs_instr_class.h:555
Statistics for stage usage.
Definition: pfs_stat.h:323
Instrumentation metadata for a statement.
Definition: pfs_instr_class.h:559
Single table I/O statistic.
Definition: pfs_stat.h:648
Table index or 'key'.
Definition: pfs_instr_class.h:377
uint m_name_length
Length in bytes of m_name.
Definition: pfs_instr_class.h:381
char m_name[NAME_LEN]
Index name.
Definition: pfs_instr_class.h:379
Statistics for table locks.
Definition: pfs_stat.h:710
Definition: pfs_name.h:234
Index statistics of a table.
Definition: pfs_instr_class.h:385
PFS_table_key m_key
The index name.
Definition: pfs_instr_class.h:388
PFS_table_io_stat m_stat
The index stat.
Definition: pfs_instr_class.h:390
pfs_lock m_lock
Definition: pfs_instr_class.h:386
PFS_table_share * m_owner
Owner table share.
Definition: pfs_instr_class.h:392
PFS_opaque_container_page * m_page
Container page.
Definition: pfs_instr_class.h:394
Key identifying a table share.
Definition: pfs_instr_class.h:365
PFS_schema_name m_schema_name
Table schema.
Definition: pfs_instr_class.h:370
PFS_table_name m_table_name
Table name.
Definition: pfs_instr_class.h:373
enum_object_type m_type
Object type.
Definition: pfs_instr_class.h:367
Lock statistics of a table.
Definition: pfs_instr_class.h:398
PFS_opaque_container_page * m_page
Container page.
Definition: pfs_instr_class.h:405
pfs_lock m_lock
Definition: pfs_instr_class.h:399
PFS_table_share * m_owner
Owner table share.
Definition: pfs_instr_class.h:403
PFS_table_lock_stat m_stat
Lock stats.
Definition: pfs_instr_class.h:401
Instrumentation metadata for a table share.
Definition: pfs_instr_class.h:409
PFS_table_share_key m_key
Search key.
Definition: pfs_instr_class.h:451
std::atomic< PFS_table_share_lock * > m_race_lock_stat
Table locks statistics.
Definition: pfs_instr_class.h:471
uint32 get_version()
Definition: pfs_instr_class.h:411
enum_object_type get_object_type() const
Definition: pfs_instr_class.h:413
bool m_timed
True if table instrumentation is timed.
Definition: pfs_instr_class.h:448
bool m_enabled
True if table instrumentation is enabled.
Definition: pfs_instr_class.h:443
void inc_refcount()
Definition: pfs_instr_class.h:431
PFS_opaque_container_page * m_page
Container page.
Definition: pfs_instr_class.h:456
void aggregate()
Definition: pfs_instr_class.h:422
int get_refcount()
Definition: pfs_instr_class.h:429
void init_refcount()
Definition: pfs_instr_class.h:427
std::atomic< int > m_refcount
Number of opened table handles.
Definition: pfs_instr_class.h:469
uint m_key_count
Number of indexes.
Definition: pfs_instr_class.h:454
void dec_refcount()
Definition: pfs_instr_class.h:433
pfs_lock m_lock
Internal lock.
Definition: pfs_instr_class.h:438
Instrumentation metadata of a thread.
Definition: pfs_instr_class.h:353
PFS_thread * m_singleton
Singleton instance.
Definition: pfs_instr_class.h:355
std::atomic< unsigned int > m_seqnum
Thread instance sequence number counter.
Definition: pfs_instr_class.h:361
Instrumented thread implementation.
Definition: pfs_instr.h:373
Instrumentation metadata for a transaction.
Definition: pfs_instr_class.h:562
Statistics for transaction usage.
Definition: pfs_stat.h:459
Condition information.
Definition: psi_cond_bits.h:88
File instrument information.
Definition: psi_file_bits.h:114
Memory instrument information.
Definition: psi_memory_bits.h:58
Mutex information.
Definition: psi_mutex_bits.h:73
Rwlock information.
Definition: psi_rwlock_bits.h:162
Socket instrument information.
Definition: psi_socket_bits.h:128
Stage instrument information.
Definition: psi_stage_bits.h:74
Statement instrument information.
Definition: psi_statement_bits.h:133
Thread instrument information.
Definition: psi_thread_bits.h:117
This structure is shared between different table objects.
Definition: table.h:690
A 'lock' protecting performance schema internal buffers.
Definition: pfs_lock.h:154
Definition: result.h:30
unsigned int uint
Definition: uca9-dump.cc:75