From 859aa3b2b02513e377a62fcaf3283ca12d543553 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 4 Jun 2021 14:07:46 +0200 Subject: [PATCH] Setup system tracing before launching profiler threads. This makes sure that profiler threads are properly included in sample data on Linux. This was previously working because sample capture was performed system-wide. Now samples are only captured in client context, which includes all spawned threads. Since this inclusion only works for threads which will be spawned after the trace starts, no thread can be created before sampling setup is done. --- client/TracyProfiler.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index e3da7563..b37950e2 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -1207,14 +1207,6 @@ Profiler::Profiler() void Profiler::SpawnWorkerThreads() { - s_thread = (Thread*)tracy_malloc( sizeof( Thread ) ); - new(s_thread) Thread( LaunchWorker, this ); - -#ifndef TRACY_NO_FRAME_IMAGE - s_compressThread = (Thread*)tracy_malloc( sizeof( Thread ) ); - new(s_compressThread) Thread( LaunchCompressWorker, this ); -#endif - #ifdef TRACY_HAS_SYSTEM_TRACING if( SysTraceStart( m_samplingPeriod ) ) { @@ -1224,6 +1216,14 @@ void Profiler::SpawnWorkerThreads() } #endif + s_thread = (Thread*)tracy_malloc( sizeof( Thread ) ); + new(s_thread) Thread( LaunchWorker, this ); + +#ifndef TRACY_NO_FRAME_IMAGE + s_compressThread = (Thread*)tracy_malloc( sizeof( Thread ) ); + new(s_compressThread) Thread( LaunchCompressWorker, this ); +#endif + #if defined _WIN32 || defined __CYGWIN__ s_profilerThreadId = GetThreadId( s_thread->Handle() ); AddVectoredExceptionHandler( 1, CrashFilter );