1 | /* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. |
2 | Copyright (c) 2017, MariaDB Corporation. |
3 | |
4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by |
6 | the Free Software Foundation; version 2 of the License. |
7 | |
8 | This program is distributed in the hope that it will be useful, |
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | GNU General Public License for more details. |
12 | |
13 | You should have received a copy of the GNU General Public License |
14 | along with this program; if not, write to the Free Software Foundation, |
15 | 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ |
16 | |
17 | #ifndef PFS_EVENTS_WAITS_H |
18 | #define PFS_EVENTS_WAITS_H |
19 | |
20 | /** |
21 | @file storage/perfschema/pfs_events_waits.h |
22 | Events waits data structures (declarations). |
23 | */ |
24 | |
25 | #include "pfs_column_types.h" |
26 | #include "pfs_lock.h" |
27 | #include "pfs_events.h" |
28 | |
29 | struct PFS_mutex; |
30 | struct PFS_rwlock; |
31 | struct PFS_cond; |
32 | struct PFS_table; |
33 | struct PFS_file; |
34 | struct PFS_thread; |
35 | struct PFS_socket; |
36 | struct PFS_instr_class; |
37 | struct PFS_table_share; |
38 | struct PFS_account; |
39 | struct PFS_user; |
40 | struct PFS_host; |
41 | |
42 | /** Class of a wait event. */ |
43 | enum events_waits_class |
44 | { |
45 | NO_WAIT_CLASS= 0, |
46 | WAIT_CLASS_MUTEX, |
47 | WAIT_CLASS_RWLOCK, |
48 | WAIT_CLASS_COND, |
49 | WAIT_CLASS_TABLE, |
50 | WAIT_CLASS_FILE, |
51 | WAIT_CLASS_SOCKET, |
52 | WAIT_CLASS_IDLE |
53 | }; |
54 | |
55 | /** A wait event record. */ |
56 | struct PFS_events_waits : public PFS_events |
57 | { |
58 | /** |
59 | The type of wait. |
60 | Readers: |
61 | - the consumer threads. |
62 | Writers: |
63 | - the producer threads, in the instrumentation. |
64 | Out of bound Writers: |
65 | - TRUNCATE EVENTS_WAITS_CURRENT |
66 | - TRUNCATE EVENTS_WAITS_HISTORY |
67 | - TRUNCATE EVENTS_WAITS_HISTORY_LONG |
68 | */ |
69 | events_waits_class m_wait_class; |
70 | /** Executing thread. */ |
71 | PFS_thread *m_thread; |
72 | /** Object type */ |
73 | enum_object_type m_object_type; |
74 | /** Table share, for table operations only. */ |
75 | PFS_table_share *m_weak_table_share; |
76 | /** File, for file operations only. */ |
77 | PFS_file *m_weak_file; |
78 | /** Socket, for socket operations only. */ |
79 | PFS_socket *m_weak_socket; |
80 | /** For weak pointers, target object version. */ |
81 | uint32 m_weak_version; |
82 | /** Address in memory of the object instance waited on. */ |
83 | const void *m_object_instance_addr; |
84 | /** Operation performed. */ |
85 | enum_operation_type m_operation; |
86 | /** |
87 | Number of bytes read/written. |
88 | This member is populated for file READ/WRITE operations only. |
89 | */ |
90 | size_t m_number_of_bytes; |
91 | /** |
92 | Index used. |
93 | This member is populated for TABLE IO operations only. |
94 | */ |
95 | uint m_index; |
96 | /** Flags */ |
97 | ulong m_flags; |
98 | }; |
99 | |
100 | /** TIMED bit in the state flags bitfield. */ |
101 | #define STATE_FLAG_TIMED (1U<<0) |
102 | /** THREAD bit in the state flags bitfield. */ |
103 | #define STATE_FLAG_THREAD (1U<<1) |
104 | /** EVENT bit in the state flags bitfield. */ |
105 | #define STATE_FLAG_EVENT (1U<<2) |
106 | /** DIGEST bit in the state flags bitfield. */ |
107 | #define STATE_FLAG_DIGEST (1U<<3) |
108 | |
109 | void insert_events_waits_history(PFS_thread *thread, PFS_events_waits *wait); |
110 | |
111 | void insert_events_waits_history_long(PFS_events_waits *wait); |
112 | |
113 | extern bool flag_events_waits_current; |
114 | extern bool flag_events_waits_history; |
115 | extern bool flag_events_waits_history_long; |
116 | extern bool flag_global_instrumentation; |
117 | extern bool flag_thread_instrumentation; |
118 | |
119 | extern bool events_waits_history_long_full; |
120 | extern volatile uint32 events_waits_history_long_index; |
121 | extern PFS_events_waits *events_waits_history_long_array; |
122 | extern ulong events_waits_history_long_size; |
123 | |
124 | int init_events_waits_history_long(uint events_waits_history_long_sizing); |
125 | void cleanup_events_waits_history_long(); |
126 | |
127 | void reset_events_waits_current(); |
128 | void reset_events_waits_history(); |
129 | void reset_events_waits_history_long(); |
130 | void reset_events_waits_by_thread(); |
131 | void reset_events_waits_by_account(); |
132 | void reset_events_waits_by_user(); |
133 | void reset_events_waits_by_host(); |
134 | void reset_events_waits_global(); |
135 | void aggregate_account_waits(PFS_account *account); |
136 | void aggregate_user_waits(PFS_user *user); |
137 | void aggregate_host_waits(PFS_host *host); |
138 | |
139 | void reset_table_waits_by_table(); |
140 | void reset_table_io_waits_by_table(); |
141 | void reset_table_lock_waits_by_table(); |
142 | void reset_table_waits_by_table_handle(); |
143 | void reset_table_io_waits_by_table_handle(); |
144 | void reset_table_lock_waits_by_table_handle(); |
145 | |
146 | #endif |
147 | |
148 | |