MCPcopy Create free account
hub / github.com/apache/brpc / ContentionProfilerStop

Function ContentionProfilerStop

src/bthread/mutex.cpp:355–373  ·  view source on GitHub ↗

Stop contention profiler.

Source from the content-addressed store, hash-verified

353
354// Stop contention profiler.
355void ContentionProfilerStop() {
356 ContentionProfiler* ctx = NULL;
357 if (g_cp) {
358 std::unique_lock<pthread_mutex_t> mu(g_cp_mutex);
359 if (g_cp) {
360 ctx = g_cp;
361 g_cp = NULL;
362 mu.unlock();
363
364 // make sure it's initialiazed in case no sample was gathered,
365 // otherwise nothing will be written and succeeding pprof will fail.
366 ctx->init_if_needed();
367 // Deletion is safe because usages of g_cp are inside g_cp_mutex.
368 delete ctx;
369 return;
370 }
371 }
372 LOG(ERROR) << "Contention profiler is not started!";
373}
374
375bool is_contention_site_valid(const bthread_contention_site_t& cs) {
376 return bvar::is_sampling_range_valid(cs.sampling_range);

Callers 2

contentionMethod · 0.85
DoProfilingFunction · 0.85

Calls 2

init_if_neededMethod · 0.80
unlockMethod · 0.45

Tested by

no test coverage detected