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