Loading 3party/gperftools/src/profiler.cc +6 −8 Original line number Diff line number Diff line Loading @@ -142,9 +142,9 @@ private: static void CpuProfilerSwitch(int signal_number) { static unsigned profile_count; static char base_profile_name[PATH_MAX]; static bool started = false; static std::atomic<unsigned> profile_count; static std::atomic<bool> started = false; if (base_profile_name[0] == '\0') { if (!GetUniquePathFromEnv("CPUPROFILE", base_profile_name)) { Loading @@ -154,7 +154,7 @@ CpuProfilerSwitch(int signal_number) } char full_profile_name[PATH_MAX + 16]; snprintf(full_profile_name, sizeof(full_profile_name), "%s.%u", base_profile_name, profile_count); snprintf(full_profile_name, sizeof(full_profile_name), "%s.%u", base_profile_name, profile_count.load()); if (!started) { if (!ProfilerStart(full_profile_name)) { RAW_LOG(FATAL, "Can't turn on cpu profiling for '%s': %s\n", full_profile_name, strerror(errno)); Loading @@ -167,12 +167,10 @@ CpuProfilerSwitch(int signal_number) if (interval > 0) { RAW_LOG(INFO, "Auto Stop cpu Profiling After %ds", interval); int cur_profile_count = profile_count; std::thread([interval, cur_profile_count] { std::thread([interval, cur_profile_count, signal_number] { std::this_thread::sleep_for(std::chrono::seconds(interval)); if (profile_count == cur_profile_count + 1) { RAW_LOG(INFO, "Trigger Auto stop CPU Profiling, duration=%ds", interval); ProfilerStop(); } // send signal to self if (started && profile_count.load() == cur_profile_count + 1) { raise(signal_number); } }).detach(); } } Loading Loading
3party/gperftools/src/profiler.cc +6 −8 Original line number Diff line number Diff line Loading @@ -142,9 +142,9 @@ private: static void CpuProfilerSwitch(int signal_number) { static unsigned profile_count; static char base_profile_name[PATH_MAX]; static bool started = false; static std::atomic<unsigned> profile_count; static std::atomic<bool> started = false; if (base_profile_name[0] == '\0') { if (!GetUniquePathFromEnv("CPUPROFILE", base_profile_name)) { Loading @@ -154,7 +154,7 @@ CpuProfilerSwitch(int signal_number) } char full_profile_name[PATH_MAX + 16]; snprintf(full_profile_name, sizeof(full_profile_name), "%s.%u", base_profile_name, profile_count); snprintf(full_profile_name, sizeof(full_profile_name), "%s.%u", base_profile_name, profile_count.load()); if (!started) { if (!ProfilerStart(full_profile_name)) { RAW_LOG(FATAL, "Can't turn on cpu profiling for '%s': %s\n", full_profile_name, strerror(errno)); Loading @@ -167,12 +167,10 @@ CpuProfilerSwitch(int signal_number) if (interval > 0) { RAW_LOG(INFO, "Auto Stop cpu Profiling After %ds", interval); int cur_profile_count = profile_count; std::thread([interval, cur_profile_count] { std::thread([interval, cur_profile_count, signal_number] { std::this_thread::sleep_for(std::chrono::seconds(interval)); if (profile_count == cur_profile_count + 1) { RAW_LOG(INFO, "Trigger Auto stop CPU Profiling, duration=%ds", interval); ProfilerStop(); } // send signal to self if (started && profile_count.load() == cur_profile_count + 1) { raise(signal_number); } }).detach(); } } Loading