1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Allow disabling cycle/retirement sampling.

This commit is contained in:
Bartosz Taudul 2021-05-19 23:38:32 +02:00
parent 3a0e12043d
commit 741de5c8fb
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -1,4 +1,5 @@
#include "TracySysTrace.hpp" #include "TracySysTrace.hpp"
#include "../common/TracySystem.hpp"
#ifdef TRACY_HAS_SYSTEM_TRACING #ifdef TRACY_HAS_SYSTEM_TRACING
@ -689,6 +690,13 @@ static void SetupSampling( int64_t& samplingPeriod )
return; return;
#endif #endif
#ifdef TRACY_NO_SAMPLE_RETIREMENT
const bool noRetirement = true;
#else
const char* noRetirementEnv = GetEnvVar( "TRACY_NO_SAMPLE_RETIREMENT" );
const bool noRetirement = noRetirementEnv && noRetirementEnv[0] == '1';
#endif
samplingPeriod = GetSamplingPeriod(); samplingPeriod = GetSamplingPeriod();
s_numCpus = (int)std::thread::hardware_concurrency(); s_numCpus = (int)std::thread::hardware_concurrency();
@ -738,6 +746,8 @@ static void SetupSampling( int64_t& samplingPeriod )
pe.exclude_idle = 1; pe.exclude_idle = 1;
pe.precise_ip = 2; pe.precise_ip = 2;
if( !noRetirement )
{
for( int i=0; i<s_numCpus; i++ ) for( int i=0; i<s_numCpus; i++ )
{ {
const int fd = perf_event_open( &pe, -1, i, -1, PERF_FLAG_FD_CLOEXEC ); const int fd = perf_event_open( &pe, -1, i, -1, PERF_FLAG_FD_CLOEXEC );
@ -747,10 +757,13 @@ static void SetupSampling( int64_t& samplingPeriod )
s_numBuffers++; s_numBuffers++;
} }
} }
}
// Instructions retired // Instructions retired
pe.config = PERF_COUNT_HW_INSTRUCTIONS; pe.config = PERF_COUNT_HW_INSTRUCTIONS;
if( !noRetirement )
{
for( int i=0; i<s_numCpus; i++ ) for( int i=0; i<s_numCpus; i++ )
{ {
const int fd = perf_event_open( &pe, -1, i, -1, PERF_FLAG_FD_CLOEXEC ); const int fd = perf_event_open( &pe, -1, i, -1, PERF_FLAG_FD_CLOEXEC );
@ -760,6 +773,7 @@ static void SetupSampling( int64_t& samplingPeriod )
s_numBuffers++; s_numBuffers++;
} }
} }
}
s_threadSampling = (Thread*)tracy_malloc( sizeof( Thread ) ); s_threadSampling = (Thread*)tracy_malloc( sizeof( Thread ) );