1
0
mirror of https://github.com/wolfpld/tracy synced 2025-04-29 12:23:53 +00:00

Merge pull request #545 from topolarity/fix-no-sampling

linux: respect `TRACY_NO_SAMPLING` for sys-tracing
This commit is contained in:
Bartosz Taudul 2023-04-04 23:29:08 +02:00 committed by GitHub
commit 856027a27d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -770,6 +770,13 @@ bool SysTraceStart( int64_t& samplingPeriod )
TracyDebug( "sched_wakeup id: %i\n", wakeupId ); TracyDebug( "sched_wakeup id: %i\n", wakeupId );
TracyDebug( "drm_vblank_event id: %i\n", vsyncId ); TracyDebug( "drm_vblank_event id: %i\n", vsyncId );
#ifdef TRACY_NO_SAMPLING
const bool noSoftwareSampling = true;
#else
const char* noSoftwareSamplingEnv = GetEnvVar( "TRACY_NO_SAMPLING" );
const bool noSoftwareSampling = noSoftwareSamplingEnv && noSoftwareSamplingEnv[0] == '1';
#endif
#ifdef TRACY_NO_SAMPLE_RETIREMENT #ifdef TRACY_NO_SAMPLE_RETIREMENT
const bool noRetirement = true; const bool noRetirement = true;
#else #else
@ -839,28 +846,31 @@ bool SysTraceStart( int64_t& samplingPeriod )
pe.clockid = CLOCK_MONOTONIC_RAW; pe.clockid = CLOCK_MONOTONIC_RAW;
#endif #endif
TracyDebug( "Setup software sampling\n" ); if( !noSoftwareSampling )
ProbePreciseIp( pe, currentPid );
for( int i=0; i<s_numCpus; i++ )
{ {
int fd = perf_event_open( &pe, currentPid, i, -1, PERF_FLAG_FD_CLOEXEC ); TracyDebug( "Setup software sampling\n" );
if( fd == -1 ) ProbePreciseIp( pe, currentPid );
for( int i=0; i<s_numCpus; i++ )
{ {
pe.exclude_kernel = 1; int fd = perf_event_open( &pe, currentPid, i, -1, PERF_FLAG_FD_CLOEXEC );
ProbePreciseIp( pe, currentPid );
fd = perf_event_open( &pe, currentPid, i, -1, PERF_FLAG_FD_CLOEXEC );
if( fd == -1 ) if( fd == -1 )
{ {
TracyDebug( " Failed to setup!\n"); pe.exclude_kernel = 1;
break; ProbePreciseIp( pe, currentPid );
fd = perf_event_open( &pe, currentPid, i, -1, PERF_FLAG_FD_CLOEXEC );
if( fd == -1 )
{
TracyDebug( " Failed to setup!\n");
break;
}
TracyDebug( " No access to kernel samples\n" );
}
new( s_ring+s_numBuffers ) RingBuffer( 64*1024, fd, EventCallstack );
if( s_ring[s_numBuffers].IsValid() )
{
s_numBuffers++;
TracyDebug( " Core %i ok\n", i );
} }
TracyDebug( " No access to kernel samples\n" );
}
new( s_ring+s_numBuffers ) RingBuffer( 64*1024, fd, EventCallstack );
if( s_ring[s_numBuffers].IsValid() )
{
s_numBuffers++;
TracyDebug( " Core %i ok\n", i );
} }
} }