MySQL  8.0.20
Source Code Documentation
pfs_instr_class.h
Go to the documentation of this file.
1 /* Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved.
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 <sys/types.h>
29 #include <atomic>
30 
31 #include "lf.h"
32 #include "my_compiler.h"
33 #include "my_dbug.h"
34 #include "my_inttypes.h"
35 #include "mysql_com.h" /* NAME_LEN */
36 #include "mysqld_error.h"
37 #include "prealloced_array.h"
42 
43 struct TABLE_SHARE;
44 
45 /**
46  @file storage/perfschema/pfs_instr_class.h
47  Performance schema instruments metadata (declarations).
48 */
49 
50 /**
51  Maximum length of an instrument name.
52  For example, 'wait/sync/mutex/sql/LOCK_open' is an instrument name.
53 */
54 #define PFS_MAX_INFO_NAME_LENGTH 128
55 
56 /**
57  Maximum length of the 'full' prefix of an instrument name.
58  For example, for the instrument name 'wait/sync/mutex/sql/LOCK_open',
59  the full prefix is 'wait/sync/mutex/sql/', which in turn derives from
60  a prefix 'wait/sync/mutex' for mutexes, and a category of 'sql' for mutexes
61  of the sql layer in the server.
62 */
63 #define PFS_MAX_FULL_PREFIX_NAME_LENGTH 32
64 
65 struct PFS_global_param;
66 struct PFS_table_share;
67 class PFS_opaque_container_page;
68 
69 /**
70  @addtogroup performance_schema_buffers
71  @{
72 */
73 
74 extern bool pfs_enabled;
75 
76 /** Global ref count for plugin and component events. */
77 extern std::atomic<uint32> pfs_unload_plugin_ref_count;
78 
79 /** Key, naming a synch instrument (mutex, rwlock, cond). */
80 typedef unsigned int PFS_sync_key;
81 /** Key, naming a thread instrument. */
82 typedef unsigned int PFS_thread_key;
83 /** Key, naming a file instrument. */
84 typedef unsigned int PFS_file_key;
85 /** Key, naming a stage instrument. */
86 typedef unsigned int PFS_stage_key;
87 /** Key, naming a statement instrument. */
88 typedef unsigned int PFS_statement_key;
89 /** Key, naming a transaction instrument. */
90 typedef unsigned int PFS_transaction_key;
91 /** Key, naming a socket instrument. */
92 typedef unsigned int PFS_socket_key;
93 /** Key, naming a memory instrument. */
94 typedef unsigned int PFS_memory_key;
95 
116 };
117 
118 /** User-defined instrument configuration. */
120  /* Instrument name. */
121  char *m_name;
122  /* Name length. */
124  /** Enabled flag. */
125  bool m_enabled;
126  /** Timed flag. */
127  bool m_timed;
128 };
129 
132 
133 struct PFS_thread;
134 
135 extern uint mutex_class_start;
136 extern uint rwlock_class_start;
137 extern uint cond_class_start;
138 extern uint file_class_start;
139 extern uint socket_class_start;
140 extern uint wait_class_max;
141 
142 /** Information for all instrumentation. */
144  /** Class type */
146  /** True if this instrument is enabled. */
147  bool m_enabled;
148  /** True if this instrument is timed. */
149  bool m_timed;
150  /** Instrument flags. */
152  /** Volatility index. */
154  /**
155  Instrument name index.
156  Self index in:
157  - EVENTS_WAITS_SUMMARY_*_BY_EVENT_NAME for waits
158  - EVENTS_STAGES_SUMMARY_*_BY_EVENT_NAME for stages
159  - EVENTS_STATEMENTS_SUMMARY_*_BY_EVENT_NAME for statements
160  - EVENTS_TRANSACTIONS_SUMMARY_*_BY_EVENT_NAME for transactions
161  */
163  /** Instrument name. */
165  /** Length in bytes of @c m_name. */
167  /** Documentation. */
169 
170  bool is_singleton() const { return m_flags & PSI_FLAG_SINGLETON; }
171 
172  bool is_mutable() const { return m_flags & PSI_FLAG_MUTABLE; }
173 
174  bool is_progress() const { return m_flags & PSI_FLAG_STAGE_PROGRESS; }
175 
176  bool is_shared_exclusive() const { return m_flags & PSI_FLAG_RWLOCK_SX; }
177 
178  bool is_priority() const { return m_flags & PSI_FLAG_RWLOCK_PR; }
179 
180  bool is_transferable() const { return m_flags & PSI_FLAG_TRANSFER; }
181 
182  bool is_user() const { return m_flags & PSI_FLAG_USER; }
183 
184  bool is_global() const { return m_flags & PSI_FLAG_ONLY_GLOBAL_STAT; }
185 
186  void enforce_valid_flags(uint allowed_flags) {
187  /* Reserved for future use. */
188  allowed_flags |= PSI_FLAG_THREAD | PSI_FLAG_TRANSFER;
189 
190  uint valid_flags = m_flags & allowed_flags;
191  /*
192  This fails when the instrumented code is providing
193  flags that are not supported for this instrument.
194  To fix it, clean up the instrumented code.
195  */
196  DBUG_ASSERT(valid_flags == m_flags);
197  m_flags = valid_flags;
198  }
199 
200  static void set_enabled(PFS_instr_class *pfs, bool enabled);
201  static void set_timed(PFS_instr_class *pfs, bool timed);
202 
203  bool is_deferred() const {
204  switch (m_type) {
205  case PFS_CLASS_SOCKET:
206  return true;
207  break;
208  default:
209  return false;
210  break;
211  };
212  }
213 
214  bool can_be_timed() const {
215  switch (m_type) {
216  case PFS_CLASS_MEMORY:
217  case PFS_CLASS_ERROR:
218  case PFS_CLASS_THREAD:
219  return false;
220  default:
221  return true;
222  };
223  }
224 };
225 
226 struct PFS_mutex;
227 
228 #define PFS_MUTEX_PARTITIONS 2
229 
230 /** Instrumentation metadata for a mutex. */
232  /** Mutex usage statistics. */
234  /** Singleton instance. */
236 };
237 
238 struct PFS_rwlock;
239 
240 /** Instrumentation metadata for a read write lock. */
242  /** Rwlock usage statistics. */
244  /** Singleton instance. */
246 };
247 
248 struct PFS_cond;
249 
250 /** Instrumentation metadata for a condition. */
252  /**
253  Condition usage statistics.
254  This statistic is not exposed in user visible tables yet.
255  */
257  /** Singleton instance. */
259 };
260 
261 /** Instrumentation metadata of a thread. */
263  /** Singleton instance. */
265  /** Thread history instrumentation flag. */
266  bool m_history{false};
267 };
268 
269 /** Key identifying a table share. */
271  /**
272  Hash search key.
273  This has to be a string for @c LF_HASH,
274  the format is @c "<enum_object_type><schema_name><0x00><object_name><0x00>"
275  @see create_table_def_key
276  */
277  char m_hash_key[1 + NAME_LEN + 1 + NAME_LEN + 1];
278  /** Length in bytes of @c m_hash_key. */
280 };
281 
282 /** Table index or 'key' */
284  /** Index name */
286  /** Length in bytes of @c m_name. */
288 };
289 
290 /** Index statistics of a table.*/
293  /** The index name */
295  /** The index stat */
297  /** Owner table share. To be used later. */
299  /** Container page. */
300  PFS_opaque_container_page *m_page;
301 };
302 
303 /** Lock statistics of a table.*/
306  /** Lock stats. */
308  /** Owner table share. To be used later. */
310  /** Container page. */
311  PFS_opaque_container_page *m_page;
312 };
313 
314 /** Instrumentation metadata for a table share. */
316  public:
317  uint32 get_version() { return m_lock.get_version(); }
318 
320  return (enum_object_type)m_key.m_hash_key[0];
321  }
322 
323  void aggregate_io(void);
324  void aggregate_lock(void);
325 
326  void sum_io(PFS_single_stat *result, uint key_count);
327  void sum_lock(PFS_single_stat *result);
328  void sum(PFS_single_stat *result, uint key_count);
329 
330  inline void aggregate(void) {
331  aggregate_io();
332  aggregate_lock();
333  }
334 
335  inline void init_refcount(void) { m_refcount.store(1); }
336 
337  inline int get_refcount(void) { return m_refcount.load(); }
338 
339  inline void inc_refcount(void) { ++m_refcount; }
340 
341  inline void dec_refcount(void) { --m_refcount; }
342 
343  void refresh_setup_object_flags(PFS_thread *thread);
344 
345  /** Internal lock. */
347  /**
348  True if table instrumentation is enabled.
349  This flag is computed from the content of table setup_objects.
350  */
351  bool m_enabled;
352  /**
353  True if table instrumentation is timed.
354  This flag is computed from the content of table setup_objects.
355  */
356  bool m_timed;
357 
358  /** Search key. */
360  /** Schema name. */
361  const char *m_schema_name;
362  /** Length in bytes of @c m_schema_name. */
364  /** Table name. */
365  const char *m_table_name;
366  /** Length in bytes of @c m_table_name. */
368  /** Number of indexes. */
370  /** Container page. */
371  PFS_opaque_container_page *m_page;
372 
373  PFS_table_share_lock *find_lock_stat() const;
374  PFS_table_share_lock *find_or_create_lock_stat();
375  void destroy_lock_stat();
376 
377  PFS_table_share_index *find_index_stat(uint index) const;
378  PFS_table_share_index *find_or_create_index_stat(
379  const TABLE_SHARE *server_share, uint index);
380  void destroy_index_stats();
381 
382  private:
383  /** Number of opened table handles. */
384  std::atomic<int> m_refcount;
385  /** Table locks statistics. */
386  std::atomic<PFS_table_share_lock *> m_race_lock_stat;
387  /** Table indexes stats. */
388  std::atomic<PFS_table_share_index *> m_race_index_stat[MAX_INDEXES + 1];
389 };
390 
391 /** Statistics for the IDLE instrument. */
393 /** Statistics for dropped table I/O. */
395 /** Statistics for dropped table lock. */
397 /** Statistics for the METADATA instrument. */
399 /** Statistics for the transaction instrument. */
401 /** Statistics for the error instrument. */
403 
405  if (likely(count <= MAX_INDEXES)) {
406  return count;
407  }
408  return 0;
409 }
410 
411 #define GLOBAL_TABLE_IO_EVENT_INDEX 0
412 #define GLOBAL_TABLE_LOCK_EVENT_INDEX 1
413 #define GLOBAL_IDLE_EVENT_INDEX 2
414 #define GLOBAL_METADATA_EVENT_INDEX 3
415 /** Number of global wait events. */
416 #define COUNT_GLOBAL_EVENT_INDEX 4
417 
418 /** Transaction events are not wait events .*/
419 #define GLOBAL_TRANSACTION_INDEX 0
420 
421 #define GLOBAL_ERROR_INDEX 0
422 
423 /**
424  Instrument controlling all table I/O.
425  This instrument is used with table SETUP_OBJECTS.
426 */
428 
429 /**
430  Instrument controlling all table lock.
431  This instrument is used with table SETUP_OBJECTS.
432 */
434 
435 /**
436  Instrument controlling all idle waits.
437 */
439 
440 /**
441  Instrument controlling all metadata locks.
442 */
444 
445 /** Instrumentation metadata for an error. */
447 /**
448  Instrument controlling all server errors.
449 */
450 extern PFS_error_class global_error_class;
451 
452 struct PFS_file;
453 
454 /** Instrumentation metadata for a file. */
456  /** File usage statistics. */
458  /** Singleton instance. */
460 };
461 
462 /** Instrumentation metadata for a stage. */
464  /**
465  Length of the @c "stage/<component>/" prefix.
466  This is to extract @c "foo" from @c "stage/sql/foo".
467  */
469  /** Stage usage statistics. */
471 };
472 
473 /** Instrumentation metadata for a statement. */
475 
476 /** Instrumentation metadata for a transaction. */
478 
479 extern PFS_transaction_class global_transaction_class;
480 
481 struct PFS_socket;
482 
483 /** Instrumentation metadata for a socket. */
485  /** Socket usage statistics. */
487  /** Singleton instance. */
489 };
490 
491 /** Instrumentation metadata for a memory. */
493 
494 void init_event_name_sizing(const PFS_global_param *param);
495 
497 
498 int init_sync_class(uint mutex_class_sizing, uint rwlock_class_sizing,
499  uint cond_class_sizing);
500 
501 void cleanup_sync_class();
502 int init_thread_class(uint thread_class_sizing);
503 void cleanup_thread_class();
504 int init_table_share(uint table_share_sizing);
505 void cleanup_table_share();
506 
507 int init_table_share_lock_stat(uint table_stat_sizing);
511 
512 int init_table_share_index_stat(uint index_stat_sizing);
515  uint index);
517 
518 int init_table_share_hash(const PFS_global_param *param);
520 int init_file_class(uint file_class_sizing);
521 void cleanup_file_class();
522 int init_stage_class(uint stage_class_sizing);
523 void cleanup_stage_class();
524 int init_statement_class(uint statement_class_sizing);
526 int init_socket_class(uint socket_class_sizing);
527 void cleanup_socket_class();
528 int init_memory_class(uint memory_class_sizing);
529 void cleanup_memory_class();
530 
531 PFS_sync_key register_mutex_class(const char *name, uint name_length,
533 
534 PFS_sync_key register_rwlock_class(const char *name, uint name_length,
535  PSI_rwlock_info *info);
536 
537 PFS_sync_key register_cond_class(const char *name, uint name_length,
538  PSI_cond_info *info);
539 
540 PFS_thread_key register_thread_class(const char *name, uint name_length,
541  PSI_thread_info *info);
542 
543 PFS_file_key register_file_class(const char *name, uint name_length,
544  PSI_file_info *info);
545 
546 PFS_stage_key register_stage_class(const char *name, uint prefix_length,
547  uint name_length, PSI_stage_info *info);
548 
549 PFS_statement_key register_statement_class(const char *name, uint name_length,
550  PSI_statement_info *info);
551 
552 PFS_socket_key register_socket_class(const char *name, uint name_length,
553  PSI_socket_info *info);
554 
555 PFS_memory_key register_memory_class(const char *name, uint name_length,
556  PSI_memory_info *info);
557 
570 PFS_statement_class *find_statement_class(PSI_statement_key key);
571 PFS_statement_class *sanitize_statement_class(PFS_statement_class *unsafe);
576 PFS_memory_class *find_memory_class(PSI_memory_key key);
577 PFS_memory_class *sanitize_memory_class(PFS_memory_class *unsafe);
582 PFS_error_class *find_error_class(uint index);
583 PFS_error_class *sanitize_error_class(PFS_instr_class *unsafe);
584 PFS_transaction_class *find_transaction_class(uint index);
585 PFS_transaction_class *sanitize_transaction_class(
586  PFS_transaction_class *unsafe);
587 
588 PFS_table_share *find_or_create_table_share(PFS_thread *thread, bool temporary,
589  const TABLE_SHARE *share);
591 void drop_table_share(PFS_thread *thread, bool temporary,
592  const char *schema_name, uint schema_name_length,
593  const char *table_name, uint table_name_length);
594 
596 
597 extern ulong mutex_class_max;
598 extern ulong mutex_class_lost;
599 extern ulong rwlock_class_max;
600 extern ulong rwlock_class_lost;
601 extern ulong cond_class_max;
602 extern ulong cond_class_lost;
603 extern ulong thread_class_max;
604 extern ulong thread_class_lost;
605 extern ulong file_class_max;
606 extern ulong file_class_lost;
607 extern ulong stage_class_max;
608 extern ulong stage_class_lost;
609 extern ulong statement_class_max;
610 extern ulong statement_class_lost;
611 extern ulong transaction_class_max;
612 extern ulong socket_class_max;
613 extern ulong socket_class_lost;
614 extern ulong memory_class_max;
615 extern ulong memory_class_lost;
616 extern ulong error_class_max;
617 
618 /* Exposing the data directly, for iterators. */
619 
624 
626 void reset_file_class_io();
627 void reset_socket_class_io();
628 
629 /** Update derived flags for all table shares. */
631 
632 /** Update derived flags for all stored procedure shares. */
634 
636 
637 /**
638  Get current time for GTID monitoring.
639 
640  @return my_getsystime() when PFS monitoring is enabled.
641  @return 0 when PFS monitoring is disabled.
642 */
644 
645 /** @} */
646 #endif
int init_table_share_hash(const PFS_global_param *param)
Initialize the table share hash table.
Definition: pfs_instr_class.cc:445
Statistics for rwlock usage.
Definition: pfs_stat.h:203
Definition: result.h:33
unsigned long long int ulonglong
Definition: my_inttypes.h:55
PFS_class_type m_type
Class type.
Definition: pfs_instr_class.h:145
pfs_lock m_lock
Definition: pfs_instr_class.h:292
PFS_single_stat global_idle_stat
Statistics for the IDLE instrument.
Definition: pfs_instr_class.cc:164
unsigned int PSI_file_key
Instrumented file key.
Definition: psi_file_bits.h:46
ulonglong gtid_monitoring_getsystime()
Get current time for GTID monitoring.
Definition: pfs_instr_class.cc:1999
enum_object_type
Enum values for the various OBJECT_TYPE columns.
Definition: pfs_column_types.h:197
PFS_table_share_key m_key
Search key.
Definition: pfs_instr_class.h:359
#define PSI_FLAG_THREAD
Per Thread flag.
Definition: psi_base.h:68
Statistics for mutex usage.
Definition: pfs_stat.h:176
std::atomic< PFS_table_share_lock * > m_race_lock_stat
Table locks statistics.
Definition: pfs_instr_class.h:386
ulong stage_class_max
Size of the stage class array.
Definition: pfs_instr_class.cc:119
PFS_rwlock_class * rwlock_class_array
Definition: pfs_instr_class.cc:150
PFS_cond_class * cond_class_array
Definition: pfs_instr_class.cc:151
Instrumented socket implementation.
Definition: pfs_instr.h:262
Lock statistics of a table.
Definition: pfs_instr_class.h:304
ulong transaction_class_max
Number of transaction classes.
Definition: pfs_instr_class.cc:140
PFS_rwlock * m_singleton
Singleton instance.
Definition: pfs_instr_class.h:245
ssize_t count
Definition: memcached.c:386
void release_table_share_lock_stat(PFS_table_share_lock *pfs)
Release a table share lock instrumentation.
Definition: pfs_instr_class.cc:664
void reset_events_waits_by_class()
Reset the wait statistics per instrument class.
Definition: pfs_instr_class.cc:1934
Prealloced_array< PFS_instr_config *, 10 > Pfs_instr_config_array
Definition: pfs_instr_class.h:130
Information for all instrumentation.
Definition: pfs_instr_class.h:143
Instrumentation metadata for a socket.
Definition: pfs_instr_class.h:484
This structure is shared between different table objects.
Definition: table.h:654
uint rwlock_class_start
Definition: pfs_instr_class.cc:216
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:1164
ulong stage_class_lost
Number of stage class lost.
Definition: pfs_instr_class.cc:121
void cleanup_table_share_lock_stat(void)
Cleanup the table stat buffers.
Definition: pfs_instr_class.cc:671
PFS_socket_class * sanitize_socket_class(PFS_socket_class *unsafe)
Definition: pfs_instr_class.cc:1533
LF_HASH table_share_hash
Hash index for instrumented table shares.
Definition: pfs_instr_class.cc:186
Some integer typedefs for easier portability.
bool m_timed
True if table instrumentation is timed.
Definition: pfs_instr_class.h:356
Statistics for table locks.
Definition: pfs_stat.h:682
Instrumentation metadata for a table share.
Definition: pfs_instr_class.h:315
Instrumentation metadata for a stage.
Definition: pfs_instr_class.h:463
Instrumentation metadata for a memory.
Definition: pfs_instr_class.h:492
void cleanup_sync_class(void)
Cleanup the instrument synch class buffers.
Definition: pfs_instr_class.cc:333
void cleanup_table_share_hash(void)
Cleanup the table share hash table.
Definition: pfs_instr_class.cc:455
Statistics for FILE usage.
Definition: pfs_stat.h:307
Definition: pfs_instr_class.h:98
Definition: pfs_instr_class.h:104
Instrumentation metadata for an error.
Definition: pfs_instr_class.h:446
PFS_statement_class * sanitize_statement_class(PFS_statement_class *unsafe)
Definition: pfs_instr_class.cc:1477
uint m_schema_name_length
Length in bytes of m_schema_name.
Definition: pfs_instr_class.h:363
PFS_cond * m_singleton
Singleton instance.
Definition: pfs_instr_class.h:258
PFS_mutex * m_singleton
Singleton instance.
Definition: pfs_instr_class.h:235
Performance schema internal locks (declarations).
uint m_prefix_length
Length of the "stage/<component>/" prefix.
Definition: pfs_instr_class.h:468
PFS_table_share_lock * create_table_share_lock_stat()
Create a table share lock instrumentation.
Definition: pfs_instr_class.cc:646
#define PSI_FLAG_USER
User flag.
Definition: psi_base.h:96
bool is_progress() const
Definition: pfs_instr_class.h:174
void cleanup_table_share_index_stat(void)
Cleanup the table stat buffers.
Definition: pfs_instr_class.cc:730
PFS_table_key m_key
The index name.
Definition: pfs_instr_class.h:294
Single table I/O statistic.
Definition: pfs_stat.h:620
PFS_class_type
Definition: pfs_instr_class.h:96
int m_volatility
Volatility index.
Definition: pfs_instr_class.h:153
PFS_error_class global_error_class
Instrument controlling all server errors.
Definition: pfs_instr_class.cc:174
PFS_instr_class * sanitize_idle_class(PFS_instr_class *unsafe)
Definition: pfs_instr_class.cc:1617
Instrumentation metadata for a condition.
Definition: pfs_instr_class.h:251
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:1489
std::atomic< uint32 > pfs_unload_plugin_ref_count
Global ref count for plugin and component events.
PFS_instr_class global_table_io_class
Instrument controlling all table I/O.
Definition: pfs_instr_class.cc:170
Statistics for SOCKET usage.
Definition: pfs_stat.h:849
Instrumentation metadata for a read write lock.
Definition: pfs_instr_class.h:241
File instrument information.
Definition: psi_file_bits.h:112
#define NAME_LEN
Definition: mysql_com.h:67
bool enabled
true if enabled.
Definition: buf0dblwr.cc:81
void cleanup_statement_class(void)
Cleanup the statement class buffers.
Definition: pfs_instr_class.cc:844
Definition: pfs_instr_class.h:101
Definition: pfs_instr_class.h:97
Miscellaneous global dependencies (declarations).
PFS_instr_class * find_table_class(uint index)
Definition: pfs_instr_class.cc:1592
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:46
PFS_instr_class * sanitize_table_class(PFS_instr_class *unsafe)
Definition: pfs_instr_class.cc:1602
ulong mutex_class_max
Size of the mutex class array.
Definition: pfs_instr_class.cc:99
void init_event_name_sizing(const PFS_global_param *param)
Definition: pfs_instr_class.cc:222
PFS_rwlock_stat m_rwlock_stat
Rwlock usage statistics.
Definition: pfs_instr_class.h:243
uint m_name_length
Definition: pfs_instr_class.h:123
PFS_instr_class * find_idle_class(uint index)
Definition: pfs_instr_class.cc:1610
Memory instrument information.
Definition: psi_memory_bits.h:55
PFS_error_class * sanitize_error_class(PFS_instr_class *unsafe)
Instrumentation metadata for a statement.
Definition: pfs_instr_class.h:474
void cleanup_stage_class(void)
Cleanup the stage class buffers.
Definition: pfs_instr_class.cc:802
PFS_cond_class * sanitize_cond_class(PFS_cond_class *unsafe)
Definition: pfs_instr_class.cc:1241
PFS_transaction_class global_transaction_class
Definition: pfs_instr_class.cc:175
const char * m_schema_name
Schema name.
Definition: pfs_instr_class.h:361
#define PSI_FLAG_RWLOCK_SX
Shared Exclusive flag.
Definition: psi_base.h:81
void release_table_share_index_stat(PFS_table_share_index *pfs)
Release a table share index instrumentation.
Definition: pfs_instr_class.cc:723
PFS_cond_stat m_cond_stat
Condition usage statistics.
Definition: pfs_instr_class.h:256
Instrumentation metadata for a transaction.
Definition: pfs_instr_class.h:477
bool m_timed
Timed flag.
Definition: pfs_instr_class.h:127
uint sanitize_index_count(uint count)
Definition: pfs_instr_class.h:404
PFS_mutex_class * sanitize_mutex_class(PFS_mutex_class *unsafe)
Definition: pfs_instr_class.cc:1213
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:1545
ulong rwlock_class_max
Size of the rwlock class array.
Definition: pfs_instr_class.cc:103
Condition information.
Definition: psi_cond_bits.h:85
PFS_file * m_singleton
Singleton instance.
Definition: pfs_instr_class.h:459
Instrumentation metadata of a thread.
Definition: pfs_instr_class.h:262
unsigned int PSI_mutex_key
Instrumented mutex key.
Definition: psi_mutex_bits.h:49
Statistics for all server errors.
Definition: pfs_stat.h:531
Common definition between mysql server & client.
bool is_user() const
Definition: pfs_instr_class.h:182
ulong statement_class_lost
Number of statement class lost.
Definition: pfs_instr_class.cc:125
PFS_error_class * find_error_class(uint index)
Definition: pfs_instr_class.cc:1638
PFS_instr_class global_idle_class
Instrument controlling all idle waits.
Definition: pfs_instr_class.cc:172
PFS_thread_class * sanitize_thread_class(PFS_thread_class *unsafe)
Definition: pfs_instr_class.cc:1300
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:1252
uint m_key_length
Length in bytes of m_hash_key.
Definition: pfs_instr_class.h:279
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:692
unsigned int PSI_cond_key
Instrumented cond key.
Definition: psi_cond_bits.h:41
ulong rwlock_class_lost
Number of rwlock class lost.
Definition: pfs_instr_class.cc:105
unsigned int PFS_stage_key
Key, naming a stage instrument.
Definition: pfs_instr_class.h:86
A typesafe replacement for DYNAMIC_ARRAY.
Definition: prealloced_array.h:66
PFS_transaction_class * find_transaction_class(uint index)
Definition: pfs_instr_class.cc:1652
#define DBUG_ASSERT(A)
Definition: my_dbug.h:199
Data types for columns used in the performance schema tables (declarations)
PFS_single_stat global_metadata_stat
Statistics for the METADATA instrument.
Definition: pfs_instr_class.cc:167
void release_table_share(TABLE_SHARE *share)
Mark that we are not using table share anymore.
Definition: sql_base.cc:940
void reset_socket_class_io(void)
Reset the I/O statistics per socket class.
Definition: pfs_instr_class.cc:1954
uint m_key_count
Number of indexes.
Definition: pfs_instr_class.h:369
void cleanup_memory_class(void)
Cleanup the memory class buffers.
Definition: pfs_instr_class.cc:928
PFS_stage_class * sanitize_stage_class(PFS_stage_class *unsafe)
Definition: pfs_instr_class.cc:1463
ulong statement_class_max
Size of the statement class array.
Definition: pfs_instr_class.cc:123
Socket instrument information.
Definition: psi_socket_bits.h:126
unsigned int PFS_memory_key
Key, naming a memory instrument.
Definition: pfs_instr_class.h:94
PFS_opaque_container_page * m_page
Container page.
Definition: pfs_instr_class.h:300
PFS_socket_class * find_socket_class(PFS_socket_key key)
Find a socket instrumentation class by key.
Definition: pfs_instr_class.cc:1529
Single statistic.
Definition: pfs_stat.h:51
void update_table_share_derived_flags(PFS_thread *thread)
Update derived flags for all table shares.
Definition: pfs_instr_class.cc:1976
uint m_table_name_length
Length in bytes of m_table_name.
Definition: pfs_instr_class.h:367
bool is_global() const
Definition: pfs_instr_class.h:184
bool m_timed
True if this instrument is timed.
Definition: pfs_instr_class.h:149
int init_thread_class(uint thread_class_sizing)
Initialize the thread class buffer.
Definition: pfs_instr_class.cc:376
PFS_file_class * sanitize_file_class(PFS_file_class *unsafe)
Definition: pfs_instr_class.cc:1450
Stage instrument information.
Definition: psi_stage_bits.h:71
int init_file_class(uint file_class_sizing)
Initialize the file class buffer.
Definition: pfs_instr_class.cc:739
bool is_transferable() const
Definition: pfs_instr_class.h:180
PFS_socket * m_singleton
Singleton instance.
Definition: pfs_instr_class.h:488
Definition: pfs_instr_class.h:115
Instrumented mutex implementation.
Definition: pfs_instr.h:99
Definition: pfs_instr_class.h:113
PFS_table_lock_stat m_stat
Lock stats.
Definition: pfs_instr_class.h:307
Definition: pfs_instr_class.h:100
uint m_event_name_index
Instrument name index.
Definition: pfs_instr_class.h:162
unsigned int PSI_socket_key
Instrumented socket key.
Definition: psi_socket_bits.h:47
Definition: pfs_instr_class.h:106
ulong socket_class_max
Size of the socket class array.
Definition: pfs_instr_class.cc:127
#define PFS_ALIGNED
Definition: pfs_global.h:54
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:1019
int init_stage_class(uint stage_class_sizing)
Initialize the stage class buffer.
Definition: pfs_instr_class.cc:781
ulong cond_class_lost
Number of condition class lost.
Definition: pfs_instr_class.cc:109
int init_table_share(uint table_share_sizing)
Initialize the table share buffer.
Definition: pfs_instr_class.cc:418
PFS_instr_class global_table_lock_class
Instrument controlling all table lock.
Definition: pfs_instr_class.cc:171
void dec_refcount(void)
Definition: pfs_instr_class.h:341
int init_memory_class(uint memory_class_sizing)
Initialize the memory class buffer.
Definition: pfs_instr_class.cc:907
int init_table_share_index_stat(uint index_stat_sizing)
Initialize table index stat buffer.
Definition: pfs_instr_class.cc:680
Definition: pfs_instr_class.h:110
ulong mutex_class_lost
Number of mutex class lost.
Definition: pfs_instr_class.cc:101
enum_object_type get_object_type()
Definition: pfs_instr_class.h:319
Definition: pfs_instr_class.h:109
#define PSI_FLAG_SINGLETON
Singleton flag.
Definition: component_common.h:34
PFS_opaque_container_page * m_page
Container page.
Definition: pfs_instr_class.h:371
#define PSI_FLAG_RWLOCK_PR
Priority lock flag.
Definition: psi_base.h:111
ulong socket_class_lost
Number of socket class lost.
Definition: pfs_instr_class.cc:129
Statistics (declarations).
Header for compiler-dependent features.
ulong error_class_max
Number of error classes.
Definition: pfs_instr_class.cc:147
bool pfs_enabled
Global performance schema flag.
Definition: pfs_instr_class.cc:64
uint m_name_length
Length in bytes of m_name.
Definition: pfs_instr_class.h:166
ulong file_class_lost
Number of file class lost.
Definition: pfs_instr_class.cc:117
PFS_table_lock_stat global_table_lock_stat
Statistics for dropped table lock.
Definition: pfs_instr_class.cc:166
Statement instrument information.
Definition: psi_statement_bits.h:108
Instrumented rwlock implementation.
Definition: pfs_instr.h:116
PFS_table_io_stat global_table_io_stat
Statistics for dropped table I/O.
Definition: pfs_instr_class.cc:165
unsigned int uint
Definition: uca-dump.cc:29
PFS_statement_class * find_statement_class(PFS_stage_key key)
Find a statement instrumentation class by key.
Definition: pfs_instr_class.cc:1473
Definition: pfs_instr_class.h:107
case opt name
Definition: sslopt-case.h:32
uint mutex_class_start
Definition: pfs_instr_class.cc:215
#define PFS_MAX_INFO_NAME_LENGTH
Maximum length of an instrument name.
Definition: pfs_instr_class.h:54
void cleanup_socket_class(void)
Cleanup the socket class buffers.
Definition: pfs_instr_class.cc:886
unsigned int PFS_sync_key
Key, naming a synch instrument (mutex, rwlock, cond).
Definition: pfs_instr_class.h:80
char * m_documentation
Documentation.
Definition: pfs_instr_class.h:168
unsigned int PFS_socket_key
Key, naming a socket instrument.
Definition: pfs_instr_class.h:92
uint32_t uint32
Definition: my_inttypes.h:66
PFS_rwlock_class * sanitize_rwlock_class(PFS_rwlock_class *unsafe)
Definition: pfs_instr_class.cc:1227
Definition: lf.h:181
unsigned int PFS_file_key
Key, naming a file instrument.
Definition: pfs_instr_class.h:84
#define PSI_FLAG_ONLY_GLOBAL_STAT
Global stat only flag.
Definition: psi_base.h:105
uint cond_class_start
Definition: pfs_instr_class.cc:217
Rwlock information.
Definition: psi_rwlock_bits.h:159
void update_program_share_derived_flags(PFS_thread *thread)
Update derived flags for all stored procedure shares.
Definition: pfs_instr_class.cc:1994
void aggregate(void)
Definition: pfs_instr_class.h:330
unsigned int PSI_rwlock_key
Instrumented rwlock key.
Definition: psi_rwlock_bits.h:41
ulong file_class_max
Size of the file class array.
Definition: pfs_instr_class.cc:115
PFS_stage_stat m_stage_stat
Stage usage statistics.
Definition: pfs_instr_class.h:470
unsigned int PFS_thread_key
Key, naming a thread instrument.
Definition: pfs_instr_class.h:82
Instrumentation metadata for a mutex.
Definition: pfs_instr_class.h:231
Statistics for conditions usage.
Definition: pfs_stat.h:237
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:1355
bool likely(bool expr)
Definition: my_compiler.h:54
PFS_opaque_container_page * m_page
Container page.
Definition: pfs_instr_class.h:311
bool m_enabled
True if table instrumentation is enabled.
Definition: pfs_instr_class.h:351
PFS_mutex_class * find_mutex_class(PFS_sync_key key)
Find a mutex instrumentation class by key.
Definition: pfs_instr_class.cc:1209
A &#39;lock&#39; protecting performance schema internal buffers.
Definition: pfs_lock.h:152
Mutex information.
Definition: psi_mutex_bits.h:70
#define MAX_INDEXES
Definition: config.h:201
uint file_class_start
Definition: pfs_instr_class.cc:218
bool is_priority() const
Definition: pfs_instr_class.h:178
static const char * key
Definition: suite_stubs.c:14
pfs_lock m_lock
Internal lock.
Definition: pfs_instr_class.h:346
Definition: pfs_instr_class.h:103
PFS_mutex_class * mutex_class_array
Definition: pfs_instr_class.cc:149
Instrumented condition implementation.
Definition: pfs_instr.h:140
unsigned int PFS_transaction_key
Key, naming a transaction instrument.
Definition: pfs_instr_class.h:90
Table index or &#39;key&#39;.
Definition: pfs_instr_class.h:283
unsigned int PFS_statement_key
Key, naming a statement instrument.
Definition: pfs_instr_class.h:88
Index statistics of a table.
Definition: pfs_instr_class.h:291
ulong memory_class_max
Size of the memory class array.
Definition: pfs_instr_class.cc:131
Statistics for stage usage.
Definition: pfs_stat.h:322
Definition: pfs_instr_class.h:114
ulong thread_class_max
Size of the thread class array.
Definition: pfs_instr_class.cc:111
Thread instrument information.
Definition: psi_thread_bits.h:78
PFS_rwlock_class * find_rwlock_class(PFS_sync_key key)
Find a rwlock instrumentation class by key.
Definition: pfs_instr_class.cc:1223
unsigned int PSI_thread_key
Instrumented thread key.
Definition: psi_thread_bits.h:48
PFS_thread_class * find_thread_class(PFS_sync_key key)
Find a thread instrumentation class by key.
Definition: pfs_instr_class.cc:1296
bool m_enabled
Enabled flag.
Definition: pfs_instr_class.h:125
bool is_mutable() const
Definition: pfs_instr_class.h:172
void inc_refcount(void)
Definition: pfs_instr_class.h:339
Instrumentation metadata for a file.
Definition: pfs_instr_class.h:455
Definition: pfs_instr_class.h:112
uint wait_class_max
Definition: pfs_instr_class.cc:219
PFS_table_share * m_owner
Owner table share.
Definition: pfs_instr_class.h:309
uint m_name_length
Length in bytes of m_name.
Definition: pfs_instr_class.h:287
unsigned int PSI_statement_key
Instrumented statement key.
Definition: psi_statement_bits.h:45
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:1703
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:1406
Definition: pfs_instr_class.h:102
Pfs_instr_config_array * pfs_instr_config_array
PFS_INSTRUMENT option settings array.
Definition: pfs_instr_class.cc:76
ulong thread_class_lost
Number of thread class lost.
Definition: pfs_instr_class.cc:113
pfs_lock m_lock
Definition: pfs_instr_class.h:305
int init_table_share_lock_stat(uint table_stat_sizing)
Initialize the table lock stat buffer.
Definition: pfs_instr_class.cc:634
void reset_file_class_io(void)
Reset the I/O statistics per file class.
Definition: pfs_instr_class.cc:1944
PFS_mutex_stat m_mutex_stat
Mutex usage statistics.
Definition: pfs_instr_class.h:233
PFS_transaction_stat global_transaction_stat
Statistics for the transaction instrument.
Definition: pfs_instr_class.cc:168
bool is_deferred() const
Definition: pfs_instr_class.h:203
PFS_instr_class global_metadata_class
Instrument controlling all metadata locks.
Definition: pfs_instr_class.cc:173
PFS_file_class * file_class_array
Definition: pfs_instr_class.cc:193
PFS_file_class * find_file_class(PFS_file_key key)
Find a file instrumentation class by key.
Definition: pfs_instr_class.cc:1446
PFS_error_stat global_error_stat
Statistics for the error instrument.
Definition: pfs_instr_class.cc:169
PFS_instr_class * sanitize_metadata_class(PFS_instr_class *unsafe)
Definition: pfs_instr_class.cc:1631
void cleanup_file_class(void)
Cleanup the file class buffers.
Definition: pfs_instr_class.cc:760
void cleanup_table_share(void)
Cleanup the table share buffers.
Definition: pfs_instr_class.cc:427
char * m_name
Definition: pfs_instr_class.h:121
void register_global_classes()
Definition: pfs_instr_class.cc:232
PFS_memory_class * find_memory_class(PFS_memory_key key)
Find a memory instrumentation class by key.
Definition: pfs_instr_class.cc:1583
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:288
Definition: pfs_instr_class.h:108
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:1898
int get_refcount(void)
Definition: pfs_instr_class.h:337
void enforce_valid_flags(uint allowed_flags)
Definition: pfs_instr_class.h:186
PFS_cond_class * find_cond_class(PFS_sync_key key)
Find a condition instrumentation class by key.
Definition: pfs_instr_class.cc:1237
Statistics for transaction usage.
Definition: pfs_stat.h:433
ulong memory_class_lost
Number of memory class lost.
Definition: pfs_instr_class.cc:133
PFS_transaction_class * sanitize_transaction_class(PFS_transaction_class *unsafe)
Definition: pfs_instr_class.cc:1659
PFS_stage_class * find_stage_class(PFS_stage_key key)
Find a stage instrumentation class by key.
Definition: pfs_instr_class.cc:1459
unsigned int PSI_stage_key
Instrumented stage key.
Definition: psi_stage_bits.h:40
#define PSI_FLAG_MUTABLE
Mutable flag.
Definition: psi_base.h:61
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:1116
PFS_instr_class * find_metadata_class(uint index)
Definition: pfs_instr_class.cc:1624
PFS_table_share * m_owner
Owner table share.
Definition: pfs_instr_class.h:298
uint m_flags
Instrument flags.
Definition: pfs_instr_class.h:151
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:1312
Log info(cout, "NOTE")
Definition: pfs_instr_class.h:111
bool is_singleton() const
Definition: pfs_instr_class.h:170
#define PSI_FLAG_STAGE_PROGRESS
Stage progress flag.
Definition: psi_base.h:75
Definition: pfs_instr_class.h:99
PFS_file_stat m_file_stat
File usage statistics.
Definition: pfs_instr_class.h:457
Key identifying a table share.
Definition: pfs_instr_class.h:270
#define PSI_FLAG_TRANSFER
Transferable flag.
Definition: psi_base.h:88
bool m_enabled
True if this instrument is enabled.
Definition: pfs_instr_class.h:147
const char * m_table_name
Table name.
Definition: pfs_instr_class.h:365
Instrumented thread implementation.
Definition: pfs_instr.h:341
Instrumented File and FILE implementation.
Definition: pfs_instr.h:150
PFS_memory_class * sanitize_memory_class(PFS_memory_class *unsafe)
Definition: pfs_instr_class.cc:1587
Definition: pfs_instr_class.h:105
Performance schema global sizing parameters.
Definition: pfs_server.h:111
int init_statement_class(uint statement_class_sizing)
Initialize the statement class buffer.
Definition: pfs_instr_class.cc:823
std::atomic< int > m_refcount
Number of opened table handles.
Definition: pfs_instr_class.h:384
User-defined instrument configuration.
Definition: pfs_instr_class.h:119
PFS_thread * m_singleton
Singleton instance.
Definition: pfs_instr_class.h:264
PFS_table_io_stat m_stat
The index stat.
Definition: pfs_instr_class.h:296
int init_socket_class(uint socket_class_sizing)
Initialize the socket class buffer.
Definition: pfs_instr_class.cc:865
uint32 get_version()
Definition: pfs_instr_class.h:317
bool is_shared_exclusive() const
Definition: pfs_instr_class.h:176
bool can_be_timed() const
Definition: pfs_instr_class.h:214
uint socket_class_start
Definition: pfs_instr_class.cc:220
ulong cond_class_max
Size of the condition class array.
Definition: pfs_instr_class.cc:107
PFS_table_share * sanitize_table_share(PFS_table_share *unsafe)
Sanitize an unsafe table_share pointer.
Definition: pfs_instr_class.cc:1929
void cleanup_thread_class(void)
Cleanup the thread class buffers.
Definition: pfs_instr_class.cc:397
PFS_socket_stat m_socket_stat
Socket usage statistics.
Definition: pfs_instr_class.h:486
const char * table_name
Definition: rules_table_service.cc:55
void init_refcount(void)
Definition: pfs_instr_class.h:335