diff --git a/flow/Platform.actor.cpp b/flow/Platform.actor.cpp index cc1d224076..de46c1b86b 100644 --- a/flow/Platform.actor.cpp +++ b/flow/Platform.actor.cpp @@ -3756,6 +3756,7 @@ volatile bool profileThread = false; volatile int64_t profileThreadId = -1; void (*chainedSignalHandler)(int) = nullptr; volatile bool profilingEnabled = 1; +volatile thread_local bool flowProfilingEnabled = 1; volatile int64_t numProfilesDisabled = 0; volatile int64_t numProfilesOverflowed = 0; @@ -3833,6 +3834,7 @@ void setProfilingEnabled(int enabled) { if (profileThread) { profilingEnabled = enabled; } + flowProfilingEnabled = enabled; #else // No profiling for other platforms! #endif diff --git a/flow/Profiler.actor.cpp b/flow/Profiler.actor.cpp index e200302b9d..3541e29f0b 100644 --- a/flow/Profiler.actor.cpp +++ b/flow/Profiler.actor.cpp @@ -33,7 +33,7 @@ #include "flow/Platform.h" #include "flow/actorcompiler.h" // This must be the last include. -extern volatile int profilingEnabled; +extern volatile thread_local int flowProfilingEnabled; static uint64_t sys_gettid() { return syscall(__NR_gettid); @@ -146,7 +146,7 @@ struct Profiler { if (inSigHandler.exchange(true)) { return; } - if (profilingEnabled) { + if (flowProfilingEnabled) { double t = timer(); output_buffer->push(*(void**)&t); size_t n = platform::raw_backtrace(addresses, 256);