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