Debian Codegraph @

storage/perfschema/pfs_events_waits.h

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