MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / xrayHandler

Function xrayHandler

base/base/coverage.cpp:181–210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179
180static void xrayHandler(int32_t func_id, XRayEntryType type) __attribute__((xray_never_instrument));
181static void xrayHandler(int32_t func_id, XRayEntryType type)
182{
183 if (type == XRayEntryType::ENTRY || type == XRayEntryType::LOG_ARGS_ENTRY)
184 {
185 const uint32_t cur_gen = g_xray_generation.load(std::memory_order_relaxed);
186 if (g_tls_xray_generation != cur_gen) [[unlikely]]
187 {
188 g_tls_xray_baseline = g_tls_xray_depth;
189 g_tls_xray_generation = cur_gen;
190 }
191 const uint32_t abs = ++g_tls_xray_depth;
192 const uint32_t rel = (abs > g_tls_xray_baseline) ? abs - g_tls_xray_baseline : 0u;
193 const uint32_t depth = (rel < 255u) ? rel : 254u;
194
195 if (g_xray_to_profile && func_id >= 1 && func_id <= g_xray_max_id)
196 {
197 const uint32_t idx = g_xray_to_profile[func_id];
198 if (idx < g_xray_depth_size)
199 {
200 auto & slot = g_xray_min_depth[idx];
201 uint32_t old = slot.load(std::memory_order_relaxed);
202 while (old > depth && !slot.compare_exchange_weak(old, depth, std::memory_order_relaxed)) {}
203 }
204 }
205 }
206 else if (type == XRayEntryType::EXIT || type == XRayEntryType::TAIL)
207 {
208 --g_tls_xray_depth;
209 }
210}
211
212} // anonymous namespace
213

Callers

nothing calls this directly

Calls 1

loadMethod · 0.45

Tested by

no test coverage detected