You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

185 lines
5.0 KiB

  1. /* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation; version 2 of the License.
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License
  10. along with this program; if not, write to the Free Software Foundation,
  11. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
  12. #ifndef PFS_EVENTS_WAITS_H
  13. #define PFS_EVENTS_WAITS_H
  14. /**
  15. @file storage/perfschema/pfs_events_waits.h
  16. Events waits data structures (declarations).
  17. */
  18. #include "pfs_column_types.h"
  19. #include "pfs_lock.h"
  20. struct PFS_mutex;
  21. struct PFS_rwlock;
  22. struct PFS_cond;
  23. struct PFS_table;
  24. struct PFS_file;
  25. struct PFS_thread;
  26. struct PFS_instr_class;
  27. /** Class of a wait event. */
  28. enum events_waits_class
  29. {
  30. NO_WAIT_CLASS= 0,
  31. WAIT_CLASS_MUTEX,
  32. WAIT_CLASS_RWLOCK,
  33. WAIT_CLASS_COND,
  34. WAIT_CLASS_TABLE,
  35. WAIT_CLASS_FILE
  36. };
  37. /** State of a timer. */
  38. enum timer_state
  39. {
  40. /**
  41. Not timed.
  42. In this state, TIMER_START, TIMER_END and TIMER_WAIT are NULL.
  43. */
  44. TIMER_STATE_UNTIMED,
  45. /**
  46. About to start.
  47. In this state, TIMER_START, TIMER_END and TIMER_WAIT are NULL.
  48. */
  49. TIMER_STATE_STARTING,
  50. /**
  51. Started, but not yet ended.
  52. In this state, TIMER_START has a value, TIMER_END and TIMER_WAIT are NULL.
  53. */
  54. TIMER_STATE_STARTED,
  55. /**
  56. Ended.
  57. In this state, TIMER_START, TIMER_END and TIMER_WAIT have a value.
  58. */
  59. TIMER_STATE_TIMED
  60. };
  61. /** Target object a wait event is waiting on. */
  62. union events_waits_target
  63. {
  64. /** Mutex waited on. */
  65. PFS_mutex *m_mutex;
  66. /** RWLock waited on. */
  67. PFS_rwlock *m_rwlock;
  68. /** Condition waited on. */
  69. PFS_cond *m_cond;
  70. /** Table waited on. */
  71. PFS_table *m_table;
  72. /** File waited on. */
  73. PFS_file *m_file;
  74. };
  75. /** A wait event record. */
  76. struct PFS_events_waits
  77. {
  78. /**
  79. The type of wait.
  80. Readers:
  81. - the consumer threads.
  82. Writers:
  83. - the producer threads, in the instrumentation.
  84. Out of bound Writers:
  85. - TRUNCATE EVENTS_WAITS_CURRENT
  86. - TRUNCATE EVENTS_WAITS_HISTORY
  87. - TRUNCATE EVENTS_WAITS_HISTORY_LONG
  88. */
  89. events_waits_class m_wait_class;
  90. /** Executing thread. */
  91. PFS_thread *m_thread;
  92. /** Instrument metadata. */
  93. PFS_instr_class *m_class;
  94. /** Timer state. */
  95. enum timer_state m_timer_state;
  96. /** Event id. */
  97. ulonglong m_event_id;
  98. /**
  99. Timer start.
  100. This member is populated only if m_timed is true.
  101. */
  102. ulonglong m_timer_start;
  103. /**
  104. Timer end.
  105. This member is populated only if m_timed is true.
  106. */
  107. ulonglong m_timer_end;
  108. /** Schema name. */
  109. const char *m_schema_name;
  110. /** Length in bytes of @c m_schema_name. */
  111. uint m_schema_name_length;
  112. /** Object name. */
  113. const char *m_object_name;
  114. /** Length in bytes of @c m_object_name. */
  115. uint m_object_name_length;
  116. /** Address in memory of the object instance waited on. */
  117. const void *m_object_instance_addr;
  118. /** Location of the instrumentation in the source code (file name). */
  119. const char *m_source_file;
  120. /** Location of the instrumentation in the source code (line number). */
  121. uint m_source_line;
  122. /** Operation performed. */
  123. enum_operation_type m_operation;
  124. /**
  125. Number of bytes read/written.
  126. This member is populated for file READ/WRITE operations only.
  127. */
  128. size_t m_number_of_bytes;
  129. };
  130. /**
  131. A wait locker.
  132. A locker is a transient helper structure used by the instrumentation
  133. during the recording of a wait.
  134. */
  135. struct PFS_wait_locker
  136. {
  137. /** The timer used to measure the wait. */
  138. enum_timer_name m_timer_name;
  139. /** The object waited on. */
  140. events_waits_target m_target;
  141. /** The wait data recorded. */
  142. PFS_events_waits m_waits_current;
  143. };
  144. void insert_events_waits_history(PFS_thread *thread, PFS_events_waits *wait);
  145. void insert_events_waits_history_long(PFS_events_waits *wait);
  146. extern bool flag_events_waits_current;
  147. extern bool flag_events_waits_history;
  148. extern bool flag_events_waits_history_long;
  149. extern bool flag_events_waits_summary_by_thread_by_event_name;
  150. extern bool flag_events_waits_summary_by_event_name;
  151. extern bool flag_events_waits_summary_by_instance;
  152. extern bool flag_events_locks_summary_by_thread_by_name;
  153. extern bool flag_events_locks_summary_by_event_name;
  154. extern bool flag_events_locks_summary_by_instance;
  155. extern bool flag_file_summary_by_event_name;
  156. extern bool flag_file_summary_by_instance;
  157. extern bool events_waits_history_long_full;
  158. extern volatile uint32 events_waits_history_long_index;
  159. extern PFS_events_waits *events_waits_history_long_array;
  160. extern ulong events_waits_history_long_size;
  161. int init_events_waits_history_long(uint events_waits_history_long_sizing);
  162. void cleanup_events_waits_history_long();
  163. void reset_events_waits_current();
  164. void reset_events_waits_history();
  165. void reset_events_waits_history_long();
  166. #endif