0
0
mirror of https://github.com/wolfpld/tracy.git synced 2026-01-18 17:11:26 +01:00

Remove queue delay calibration.

This value is not used for anything, it was just a number displayed in
the UI without much meaning to anyone.

Operations on the queue during early init may not work correctly, stopping
some programs from running past the calibration loop.
This commit is contained in:
Bartosz Taudul
2025-07-11 23:19:22 +02:00
parent 33713086b4
commit 880c600506
9 changed files with 8 additions and 53 deletions

View File

@@ -185,7 +185,7 @@ int main( int argc, char** argv )
} }
std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) ); std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) );
} }
printf( "\nQueue delay: %s\nTimer resolution: %s\n", tracy::TimeToString( worker.GetDelay() ), tracy::TimeToString( worker.GetResolution() ) ); printf( "\nTimer resolution: %s\n", tracy::TimeToString( worker.GetResolution() ) );
#ifdef _WIN32 #ifdef _WIN32
signal( SIGINT, SigInt ); signal( SIGINT, SigInt );

View File

@@ -2854,12 +2854,11 @@ If no client is running at the given address, the server will wait until it can
\begin{verbatim} \begin{verbatim}
% ./capture -a 127.0.0.1 -o trace % ./capture -a 127.0.0.1 -o trace
Connecting to 127.0.0.1:8086... Connecting to 127.0.0.1:8086...
Queue delay: 5 ns
Timer resolution: 3 ns Timer resolution: 3 ns
1.33 Mbps / 40.4% = 3.29 Mbps | Net: 64.42 MB | Mem: 283.03 MB | Time: 10.6 s 1.33 Mbps / 40.4% = 3.29 Mbps | Net: 64.42 MB | Mem: 283.03 MB | Time: 10.6 s
\end{verbatim} \end{verbatim}
The \emph{queue delay} and \emph{timer resolution} parameters are calibration results of timers used by the client. The following line is a status bar, which displays: network connection speed, connection compression ratio, and the resulting uncompressed data rate; the total amount of data transferred over the network; memory usage of the capture utility; time extent of the captured data. The \emph{timer resolution} parameter shows the calibration results of timers used by the client. The following line is a status bar, which displays: network connection speed, connection compression ratio, and the resulting uncompressed data rate; the total amount of data transferred over the network; memory usage of the capture utility; time extent of the captured data.
You can disconnect from the client and save the captured trace by pressing \keys{\ctrl + C}. If you prefer to disconnect after a fixed time, use the \texttt{-s seconds} parameter. You can disconnect from the client and save the captured trace by pressing \keys{\ctrl + C}. If you prefer to disconnect after a fixed time, use the \texttt{-s seconds} parameter.

View File

@@ -76,7 +76,6 @@ void View::DrawInfo()
ImGui::SameLine(); ImGui::SameLine();
const auto version = m_worker.GetTraceVersion(); const auto version = m_worker.GetTraceVersion();
ImGui::Text( "%i.%i.%i", version >> 16, ( version >> 8 ) & 0xFF, version & 0xFF ); ImGui::Text( "%i.%i.%i", version >> 16, ( version >> 8 ) & 0xFF, version & 0xFF );
TextFocused( "Queue delay:", TimeToString( m_worker.GetDelay() ) );
TextFocused( "Timer resolution:", TimeToString( m_worker.GetResolution() ) ); TextFocused( "Timer resolution:", TimeToString( m_worker.GetResolution() ) );
TextFocused( "CPU zones:", RealToString( m_worker.GetZoneCount() ) ); TextFocused( "CPU zones:", RealToString( m_worker.GetZoneCount() ) );
ImGui::SameLine(); ImGui::SameLine();

View File

@@ -1771,7 +1771,6 @@ void Profiler::Worker()
MemWrite( &welcome.timerMul, m_timerMul ); MemWrite( &welcome.timerMul, m_timerMul );
MemWrite( &welcome.initBegin, GetInitTime() ); MemWrite( &welcome.initBegin, GetInitTime() );
MemWrite( &welcome.initEnd, m_timeBegin.load( std::memory_order_relaxed ) ); MemWrite( &welcome.initEnd, m_timeBegin.load( std::memory_order_relaxed ) );
MemWrite( &welcome.delay, m_delay );
MemWrite( &welcome.resolution, m_resolution ); MemWrite( &welcome.resolution, m_resolution );
MemWrite( &welcome.epoch, m_epoch ); MemWrite( &welcome.epoch, m_epoch );
MemWrite( &welcome.exectime, m_exectime ); MemWrite( &welcome.exectime, m_exectime );
@@ -3811,43 +3810,6 @@ void Profiler::CalibrateDelay()
if( dti > 0 && dti < mindiff ) mindiff = dti; if( dti > 0 && dti < mindiff ) mindiff = dti;
} }
m_resolution = mindiff; m_resolution = mindiff;
#ifdef TRACY_DELAYED_INIT
m_delay = m_resolution;
#else
constexpr int Events = Iterations * 2; // start + end
static_assert( Events < QueuePrealloc, "Delay calibration loop will allocate memory in queue" );
static const tracy::SourceLocationData __tracy_source_location { nullptr, TracyFunction, TracyFile, (uint32_t)TracyLine, 0 };
const auto t0 = GetTime();
for( int i=0; i<Iterations; i++ )
{
{
TracyLfqPrepare( QueueType::ZoneBegin );
MemWrite( &item->zoneBegin.time, Profiler::GetTime() );
MemWrite( &item->zoneBegin.srcloc, (uint64_t)&__tracy_source_location );
TracyLfqCommit;
}
{
TracyLfqPrepare( QueueType::ZoneEnd );
MemWrite( &item->zoneEnd.time, GetTime() );
TracyLfqCommit;
}
}
const auto t1 = GetTime();
const auto dt = t1 - t0;
m_delay = dt / Events;
moodycamel::ConsumerToken token( GetQueue() );
int left = Events;
while( left != 0 )
{
const auto sz = GetQueue().try_dequeue_bulk_single( token, [](const uint64_t&){}, [](QueueItem* item, size_t sz){} );
assert( sz > 0 );
left -= (int)sz;
}
assert( GetQueue().size_approx() == 0 );
#endif
} }
void Profiler::ReportTopology() void Profiler::ReportTopology()

View File

@@ -991,7 +991,6 @@ private:
double m_timerMul; double m_timerMul;
uint64_t m_resolution; uint64_t m_resolution;
uint64_t m_delay;
std::atomic<int64_t> m_timeBegin; std::atomic<int64_t> m_timeBegin;
uint32_t m_mainThread; uint32_t m_mainThread;
uint64_t m_epoch, m_exectime; uint64_t m_epoch, m_exectime;

View File

@@ -9,7 +9,7 @@ namespace tracy
constexpr unsigned Lz4CompressBound( unsigned isize ) { return isize + ( isize / 255 ) + 16; } constexpr unsigned Lz4CompressBound( unsigned isize ) { return isize + ( isize / 255 ) + 16; }
enum : uint32_t { ProtocolVersion = 74 }; enum : uint32_t { ProtocolVersion = 75 };
enum : uint16_t { BroadcastVersion = 3 }; enum : uint16_t { BroadcastVersion = 3 };
using lz4sz_t = uint32_t; using lz4sz_t = uint32_t;
@@ -95,7 +95,6 @@ struct WelcomeMessage
double timerMul; double timerMul;
int64_t initBegin; int64_t initBegin;
int64_t initEnd; int64_t initEnd;
uint64_t delay;
uint64_t resolution; uint64_t resolution;
uint64_t epoch; uint64_t epoch;
uint64_t exectime; uint64_t exectime;

View File

@@ -7,7 +7,7 @@ namespace Version
{ {
enum { Major = 0 }; enum { Major = 0 };
enum { Minor = 12 }; enum { Minor = 12 };
enum { Patch = 2 }; enum { Patch = 3 };
} }
} }

View File

@@ -301,7 +301,6 @@ Worker::Worker( const char* addr, uint16_t port, int64_t memoryLimit )
Worker::Worker( const char* name, const char* program, const std::vector<ImportEventTimeline>& timeline, const std::vector<ImportEventMessages>& messages, const std::vector<ImportEventPlots>& plots, const std::unordered_map<uint64_t, std::string>& threadNames ) Worker::Worker( const char* name, const char* program, const std::vector<ImportEventTimeline>& timeline, const std::vector<ImportEventMessages>& messages, const std::vector<ImportEventPlots>& plots, const std::unordered_map<uint64_t, std::string>& threadNames )
: m_hasData( true ) : m_hasData( true )
, m_delay( 0 )
, m_resolution( 0 ) , m_resolution( 0 )
, m_captureName( name ) , m_captureName( name )
, m_captureProgram( program ) , m_captureProgram( program )
@@ -576,8 +575,10 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks, bool allow
{ {
throw LegacyVersion( fileVer ); throw LegacyVersion( fileVer );
} }
if( fileVer < FileVersion( 0, 12, 3 ) )
f.Read( m_delay ); {
f.Skip( 8 ); // m_delay
}
} }
else else
{ {
@@ -2757,7 +2758,6 @@ void Worker::Exec()
m_data.framesBase->frames.push_back( FrameEvent{ 0, -1, -1 } ); m_data.framesBase->frames.push_back( FrameEvent{ 0, -1, -1 } );
m_data.framesBase->frames.push_back( FrameEvent{ initEnd, -1, -1 } ); m_data.framesBase->frames.push_back( FrameEvent{ initEnd, -1, -1 } );
m_data.lastTime = initEnd; m_data.lastTime = initEnd;
m_delay = TscPeriod( welcome.delay );
m_resolution = TscPeriod( welcome.resolution ); m_resolution = TscPeriod( welcome.resolution );
m_pid = welcome.pid; m_pid = welcome.pid;
m_samplingPeriod = welcome.samplingPeriod; m_samplingPeriod = welcome.samplingPeriod;
@@ -7820,7 +7820,6 @@ void Worker::Write( FileWrite& f, bool fiDict )
f.Write( FileHeader, sizeof( FileHeader ) ); f.Write( FileHeader, sizeof( FileHeader ) );
f.Write( &m_delay, sizeof( m_delay ) );
f.Write( &m_resolution, sizeof( m_resolution ) ); f.Write( &m_resolution, sizeof( m_resolution ) );
f.Write( &m_timerMul, sizeof( m_timerMul ) ); f.Write( &m_timerMul, sizeof( m_timerMul ) );
f.Write( &m_data.lastTime, sizeof( m_data.lastTime ) ); f.Write( &m_data.lastTime, sizeof( m_data.lastTime ) );

View File

@@ -465,7 +465,6 @@ public:
uint64_t GetCaptureTime() const { return m_captureTime; } uint64_t GetCaptureTime() const { return m_captureTime; }
uint64_t GetExecutableTime() const { return m_executableTime; } uint64_t GetExecutableTime() const { return m_executableTime; }
const std::string& GetHostInfo() const { return m_hostInfo; } const std::string& GetHostInfo() const { return m_hostInfo; }
int64_t GetDelay() const { return m_delay; }
int64_t GetResolution() const { return m_resolution; } int64_t GetResolution() const { return m_resolution; }
uint64_t GetPid() const { return m_pid; }; uint64_t GetPid() const { return m_pid; };
CpuArchitecture GetCpuArch() const { return m_data.cpuArch; } CpuArchitecture GetCpuArch() const { return m_data.cpuArch; }
@@ -982,7 +981,6 @@ private:
std::atomic<bool> m_backgroundDone { true }; std::atomic<bool> m_backgroundDone { true };
std::thread m_threadBackground; std::thread m_threadBackground;
int64_t m_delay;
int64_t m_resolution; int64_t m_resolution;
double m_timerMul; double m_timerMul;
std::string m_captureName; std::string m_captureName;