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.
This commit is contained in:
Bartosz Taudul 2021-06-04 14:07:46 +02:00
parent 3c31fb56a8
commit 859aa3b2b0
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -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 );