MySQL 8.4.0
Source Code Documentation
psi_bits.h
Go to the documentation of this file.
1/* Copyright (c) 2008, 2024, 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 COMPONENTS_SERVICES_BITS_PSI_BITS_H
25#define COMPONENTS_SERVICES_BITS_PSI_BITS_H
26
27/**
28 @file mysql/components/services/bits/psi_bits.h
29 Performance schema instrumentation interface.
30
31 @defgroup instrumentation_interface Instrumentation Interface
32 @ingroup performance_schema
33 @{
34
35 @defgroup psi_api Instrumentation Programming Interface
36 @{
37 @}
38
39 @defgroup psi_abi Instrumentation Binary Interface
40 @{
41*/
42
43static constexpr unsigned PSI_INSTRUMENT_ME = 0;
44
45#define PSI_DOCUMENT_ME ""
46
47// Remove 'constexpr' in order to pick the right overload for
48// Prealloced_array CTOR.
49// See https://bugs.llvm.org/show_bug.cgi?id=51582
50// and TEST_F(PreallocedArrayTest, CorrectOverloadIsChosen)
51#if defined(__clang__) && defined(_WIN32)
52static unsigned PSI_NOT_INSTRUMENTED = 0;
53#else
54static constexpr unsigned PSI_NOT_INSTRUMENTED = 0;
55#endif
56
57/**
58 Singleton flag.
59 This flag indicate that an instrumentation point is a singleton.
60*/
61#define PSI_FLAG_SINGLETON (1 << 0)
62
63/**
64 Mutable flag.
65 This flag indicate that an instrumentation point is a general placeholder,
66 that can mutate into a more specific instrumentation point.
67*/
68#define PSI_FLAG_MUTABLE (1 << 1)
69
70/**
71 Per Thread flag.
72 This flag indicates the instrumented object is per thread.
73 Reserved for future use.
74*/
75#define PSI_FLAG_THREAD (1 << 2)
76
77/**
78 Stage progress flag.
79 This flag apply to the stage instruments only.
80 It indicates the instrumentation provides progress data.
81*/
82#define PSI_FLAG_STAGE_PROGRESS (1 << 3)
83
84/**
85 Shared Exclusive flag.
86 Indicates that rwlock support the shared exclusive state.
87*/
88#define PSI_FLAG_RWLOCK_SX (1 << 4)
89
90/**
91 Transferable flag.
92 This flag indicate that an instrumented object can
93 be created by a thread and destroyed by another thread.
94*/
95#define PSI_FLAG_TRANSFER (1 << 5)
96
97/**
98 User flag.
99 This flag indicate that an instrumented object exists on a
100 user or foreground thread. If not set, then the object
101 exists on a system or background thread.
102*/
103#define PSI_FLAG_USER (1 << 6)
104
105/**
106 Global stat only flag.
107 This flag indicates statistics for the instrument
108 are aggregated globally only.
109 No per thread / account / user / host aggregations
110 are available.
111*/
112#define PSI_FLAG_ONLY_GLOBAL_STAT (1 << 7)
113
114/**
115 Priority lock flag.
116 Indicates that rwlock support the priority lock scheduling.
117*/
118#define PSI_FLAG_RWLOCK_PR (1 << 8)
119
120/**
121 System thread flag.
122 Indicates that the instrumented object exists on a system thread.
123*/
124#define PSI_FLAG_THREAD_SYSTEM (1 << 9)
125
126/**
127 Automatic sequence number flag.
128 Generate thread instances names automatically.
129*/
130#define PSI_FLAG_AUTO_SEQNUM (1 << 10)
131
132/**
133 No sequence number flag.
134 Use thread instances names without sequence numbers.
135*/
136#define PSI_FLAG_NO_SEQNUM (1 << 11)
137
138/**
139 Enable collecting the memory consumed by threads.
140*/
141#define PSI_FLAG_MEM_COLLECT (1 << 12)
142
143/**
144 Instrument is disabled by default.
145*/
146#define PSI_FLAG_DISABLED (1 << 13)
147
148/**
149 Instrument is not timed by default.
150*/
151#define PSI_FLAG_UNTIMED (1 << 14)
152
153#define PSI_VOLATILITY_UNKNOWN 0
154#define PSI_VOLATILITY_PERMANENT 1
155#define PSI_VOLATILITY_PROVISIONING 2
156#define PSI_VOLATILITY_DDL 3
157#define PSI_VOLATILITY_CACHE 4
158#define PSI_VOLATILITY_SESSION 5
159#define PSI_VOLATILITY_TRANSACTION 6
160#define PSI_VOLATILITY_QUERY 7
161#define PSI_VOLATILITY_INTRA_QUERY 8
162
163#define PSI_COUNT_VOLATILITY 9
164
167};
168
169/**
170 Instrumented artifact.
171 The object instrumented can be enabled or disabled.
172 The @c m_enabled member is visible and public,
173 and must be tested by the instrumented code
174 before making low level api calls to
175 the actual instrumentation implementation.
176*/
177struct PSI_instr {
178 /**
179 Instrumentation is enabled.
180 This flag must be checked before making calls to:
181 - @c PSI_MUTEX_CALL(start_mutex_wait)
182 - @c PSI_MUTEX_CALL(unlock_mutex)
183 - @c PSI_RWLOCK_CALL(start_rwlock_rdwait)
184 - @c PSI_RWLOCK_CALL(start_rwlock_wrwait)
185 - @c PSI_RWLOCK_CALL(unlock_rwlock)
186 - @c PSI_COND_CALL(start_cond_wait)
187 - @c PSI_COND_CALL(signal_cond)
188 - @c PSI_COND_CALL(broadcast_cond)
189 - @c PSI_SOCKET_CALL(start_socket_wait)
190 */
192};
193
194/**
195 @} (end of group psi_abi)
196 @} (end of group instrumentation_interface)
197*/
198
199#endif /* COMPONENTS_SERVICES_BITS_PSI_BITS_H */
static constexpr unsigned PSI_INSTRUMENT_ME
Definition: psi_bits.h:43
static constexpr unsigned PSI_NOT_INSTRUMENTED
Definition: psi_bits.h:54
Instrumented artifact.
Definition: psi_bits.h:177
bool m_enabled
Instrumentation is enabled.
Definition: psi_bits.h:191
Definition: psi_bits.h:165
int m_placeholder
Definition: psi_bits.h:166