MCPcopy Create free account
hub / github.com/ByConity/ByConity / initPerformanceCounters

Method initPerformanceCounters

src/Interpreters/ThreadStatusExt.cpp:209–262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207}
208
209void ThreadStatus::initPerformanceCounters()
210{
211 performance_counters_finalized = false;
212
213 /// Clear stats from previous query if a new query is started
214 /// TODO: make separate query_thread_performance_counters and thread_performance_counters
215 performance_counters.resetCounters();
216 memory_tracker.resetCounters();
217 memory_tracker.setDescription("(for thread)");
218
219 // query_start_time_{microseconds, nanoseconds} are all constructed from the same time point
220 // to ensure that they are all equal up to the precision of a second.
221 const auto now = std::chrono::system_clock::now();
222
223 query_start_time_nanoseconds = time_in_nanoseconds(now);
224 query_start_time = time_in_seconds(now);
225 query_start_time_microseconds = time_in_microseconds(now);
226 ++queries_started;
227
228 // query_start_time_nanoseconds cannot be used here since RUsageCounters expect CLOCK_MONOTONIC
229 *last_rusage = RUsageCounters::current();
230
231 if (auto query_context_ptr = query_context.lock())
232 {
233 const Settings & settings = query_context_ptr->getSettingsRef();
234 if (settings.metrics_perf_events_enabled)
235 {
236 try
237 {
238 current_thread_counters.initializeProfileEvents(
239 settings.metrics_perf_events_list);
240 }
241 catch (...)
242 {
243 tryLogCurrentException(__PRETTY_FUNCTION__);
244 }
245 }
246 }
247
248 if (!taskstats)
249 {
250 try
251 {
252 if (auto query_context_ptr = query_context.lock(); query_context_ptr && query_context_ptr->getSettingsRef().enable_os_task_stats)
253 taskstats = TasksStatsCounters::create(thread_id);
254 }
255 catch (...)
256 {
257 tryLogCurrentException(log);
258 }
259 }
260 if (taskstats)
261 taskstats->reset();
262}
263
264void ThreadStatus::finalizePerformanceCounters()
265{

Callers

nothing calls this directly

Calls 11

nowFunction · 0.85
time_in_nanosecondsFunction · 0.85
tryLogCurrentExceptionFunction · 0.85
time_in_secondsFunction · 0.70
time_in_microsecondsFunction · 0.70
createFunction · 0.50
resetCountersMethod · 0.45
setDescriptionMethod · 0.45
lockMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected