1
0
mirror of https://github.com/wolfpld/tracy synced 2025-01-15 20:08:00 +00:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Bartosz Taudul
bb25687f7e
Update manual. 2021-05-11 18:37:08 +02:00
Bartosz Taudul
84bb131f81
Update NEWS. 2021-05-11 18:32:06 +02:00
Bartosz Taudul
42a272edf5
Allow control of sampling frequency. 2021-05-11 18:31:20 +02:00
3 changed files with 38 additions and 5 deletions

1
NEWS
View File

@ -25,6 +25,7 @@ v0.x.x (xxxx-xx-xx)
can be now imported. A pseudo-TID will be created for each PID+TID pair
in such circumstances.
- Added support for custom source location tag ("loc") in chrome traces.
- Sampling frequency can be now controlled using TRACY_SAMPLING_HZ macro.
v0.7.7 (2021-04-01)

View File

@ -2,6 +2,33 @@
#ifdef TRACY_HAS_SYSTEM_TRACING
#ifndef TRACY_SAMPLING_HZ
# if defined _WIN32 || defined __CYGWIN__
# define TRACY_SAMPLING_HZ 8000
# elif defined __linux__
# define TRACY_SAMPLING_HZ 10000
# endif
#endif
namespace tracy
{
static constexpr int GetSamplingFrequency()
{
#if defined _WIN32 || defined __CYGWIN__
return TRACY_SAMPLING_HZ > 8000 ? 8000 : ( TRACY_SAMPLING_HZ < 1 ? 1 : TRACY_SAMPLING_HZ );
#else
return TRACY_SAMPLING_HZ > 1000000 ? 1000000 : ( TRACY_SAMPLING_HZ < 1 ? 1 : TRACY_SAMPLING_HZ );
#endif
}
static constexpr int GetSamplingPeriod()
{
return 1000000000 / GetSamplingFrequency();
}
}
# if defined _WIN32 || defined __CYGWIN__
# ifndef NOMINMAX
@ -330,6 +357,11 @@ static void SetupVsync()
#endif
}
static constexpr int GetSamplingInterval()
{
return GetSamplingPeriod() / 100;
}
bool SysTraceStart( int64_t& samplingPeriod )
{
if( !_GetThreadDescription ) _GetThreadDescription = (t_GetThreadDescription)GetProcAddress( GetModuleHandleA( "kernel32.dll" ), "GetThreadDescription" );
@ -360,10 +392,10 @@ bool SysTraceStart( int64_t& samplingPeriod )
if( isOs64Bit )
{
TRACE_PROFILE_INTERVAL interval = {};
interval.Interval = 1250; // 8 kHz
interval.Interval = GetSamplingInterval();
const auto intervalStatus = TraceSetInformation( 0, TraceSampledProfileIntervalInfo, &interval, sizeof( interval ) );
if( intervalStatus != ERROR_SUCCESS ) return false;
samplingPeriod = 125*1000;
samplingPeriod = GetSamplingPeriod();
}
const auto psz = sizeof( EVENT_TRACE_PROPERTIES ) + sizeof( KERNEL_LOGGER_NAME );
@ -649,7 +681,7 @@ static void SetupSampling( int64_t& samplingPeriod )
return;
#endif
samplingPeriod = 100*1000;
samplingPeriod = GetSamplingPeriod();
s_numCpus = (int)std::thread::hardware_concurrency();
s_ring = (RingBuffer<RingBufSize>*)tracy_malloc( sizeof( RingBuffer<RingBufSize> ) * s_numCpus );
@ -660,7 +692,7 @@ static void SetupSampling( int64_t& samplingPeriod )
pe.size = sizeof( perf_event_attr );
pe.config = PERF_COUNT_SW_CPU_CLOCK;
pe.sample_freq = 10000;
pe.sample_freq = GetSamplingFrequency();
pe.sample_type = PERF_SAMPLE_TID | PERF_SAMPLE_TIME | PERF_SAMPLE_CALLCHAIN;
#if LINUX_VERSION_CODE >= KERNEL_VERSION( 4, 8, 0 )
pe.sample_max_stack = 127;

View File

@ -1839,7 +1839,7 @@ Manual markup of zones doesn't cover every function existing in a program and ca
This feature requires privilege elevation, as described in chapter~\ref{privilegeelevation}. Proper setup of the required program debugging data is described in chapter~\ref{collectingcallstacks}.
On Windows sampling is performed at 8 kHz frequency (which is the maximum possible value), and on Linux and Android it is performed at 10 kHz.
By default sampling is performed at 8 kHz frequency on Windows (which is the maximum possible value). On Linux and Android it is performed at 10 kHz. This value can be changed by providing the sampling frequency (in Hz) through the \texttt{TRACY\_SAMPLING\_HZ} macro.
Call stack sampling may be disabled by using the \texttt{TRACY\_NO\_SAMPLING} define.