Use separate messages for transfer of different plot value types.

This commit is contained in:
Bartosz Taudul 2022-07-24 13:00:36 +02:00
parent aeedf7de2d
commit 810f1573ac
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
6 changed files with 75 additions and 69 deletions

View File

@ -2400,12 +2400,14 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token )
tracy_free_fast( (void*)ptr );
#endif
break;
case QueueType::PlotData:
case QueueType::PlotDataInt:
case QueueType::PlotDataFloat:
case QueueType::PlotDataDouble:
{
int64_t t = MemRead<int64_t>( &item->plotData.time );
int64_t t = MemRead<int64_t>( &item->plotDataInt.time );
int64_t dt = t - refThread;
refThread = t;
MemWrite( &item->plotData.time, dt );
MemWrite( &item->plotDataInt.time, dt );
break;
}
case QueueType::ContextSwitch:

View File

@ -311,11 +311,10 @@ public:
#ifdef TRACY_ON_DEMAND
if( !GetProfiler().IsConnected() ) return;
#endif
TracyLfqPrepare( QueueType::PlotData );
MemWrite( &item->plotData.name, (uint64_t)name );
MemWrite( &item->plotData.time, GetTime() );
MemWrite( &item->plotData.type, PlotDataType::Int );
MemWrite( &item->plotData.data.i, val );
TracyLfqPrepare( QueueType::PlotDataInt );
MemWrite( &item->plotDataInt.name, (uint64_t)name );
MemWrite( &item->plotDataInt.time, GetTime() );
MemWrite( &item->plotDataInt.val, val );
TracyLfqCommit;
}
@ -324,11 +323,10 @@ public:
#ifdef TRACY_ON_DEMAND
if( !GetProfiler().IsConnected() ) return;
#endif
TracyLfqPrepare( QueueType::PlotData );
MemWrite( &item->plotData.name, (uint64_t)name );
MemWrite( &item->plotData.time, GetTime() );
MemWrite( &item->plotData.type, PlotDataType::Float );
MemWrite( &item->plotData.data.f, val );
TracyLfqPrepare( QueueType::PlotDataFloat );
MemWrite( &item->plotDataFloat.name, (uint64_t)name );
MemWrite( &item->plotDataFloat.time, GetTime() );
MemWrite( &item->plotDataFloat.val, val );
TracyLfqCommit;
}
@ -337,11 +335,10 @@ public:
#ifdef TRACY_ON_DEMAND
if( !GetProfiler().IsConnected() ) return;
#endif
TracyLfqPrepare( QueueType::PlotData );
MemWrite( &item->plotData.name, (uint64_t)name );
MemWrite( &item->plotData.time, GetTime() );
MemWrite( &item->plotData.type, PlotDataType::Double );
MemWrite( &item->plotData.data.d, val );
TracyLfqPrepare( QueueType::PlotDataDouble );
MemWrite( &item->plotDataDouble.name, (uint64_t)name );
MemWrite( &item->plotDataDouble.time, GetTime() );
MemWrite( &item->plotDataDouble.val, val );
TracyLfqCommit;
}

View File

@ -9,7 +9,7 @@ namespace tracy
constexpr unsigned Lz4CompressBound( unsigned isize ) { return isize + ( isize / 255 ) + 16; }
enum : uint32_t { ProtocolVersion = 58 };
enum : uint32_t { ProtocolVersion = 59 };
enum : uint16_t { BroadcastVersion = 2 };
using lz4sz_t = uint32_t;

View File

@ -52,7 +52,9 @@ enum class QueueType : uint8_t
GpuZoneBeginAllocSrcLocSerial,
GpuZoneBeginAllocSrcLocCallstackSerial,
GpuZoneEndSerial,
PlotData,
PlotDataInt,
PlotDataFloat,
PlotDataDouble,
ContextSwitch,
ThreadWakeup,
GpuTime,
@ -305,24 +307,25 @@ struct QueueLockNameFat : public QueueLockName
uint16_t size;
};
enum class PlotDataType : uint8_t
{
Float,
Double,
Int
};
struct QueuePlotData
struct QueuePlotDataBase
{
uint64_t name; // ptr
int64_t time;
PlotDataType type;
union
};
struct QueuePlotDataInt : public QueuePlotDataBase
{
double d;
float f;
int64_t i;
} data;
int64_t val;
};
struct QueuePlotDataFloat : public QueuePlotDataBase
{
float val;
};
struct QueuePlotDataDouble : public QueuePlotDataBase
{
double val;
};
struct QueueMessage
@ -678,7 +681,9 @@ struct QueueItem
QueueLockMark lockMark;
QueueLockName lockName;
QueueLockNameFat lockNameFat;
QueuePlotData plotData;
QueuePlotDataInt plotDataInt;
QueuePlotDataFloat plotDataFloat;
QueuePlotDataDouble plotDataDouble;
QueueMessage message;
QueueMessageColor messageColor;
QueueMessageLiteral messageLiteral;
@ -778,7 +783,9 @@ static constexpr size_t QueueDataSize[] = {
sizeof( QueueHeader ) + sizeof( QueueGpuZoneBeginLean ),// serial, allocated source location
sizeof( QueueHeader ) + sizeof( QueueGpuZoneBeginLean ),// serial, allocated source location, callstack
sizeof( QueueHeader ) + sizeof( QueueGpuZoneEnd ), // serial
sizeof( QueueHeader ) + sizeof( QueuePlotData ),
sizeof( QueueHeader ) + sizeof( QueuePlotDataInt ),
sizeof( QueueHeader ) + sizeof( QueuePlotDataFloat ),
sizeof( QueueHeader ) + sizeof( QueuePlotDataDouble ),
sizeof( QueueHeader ) + sizeof( QueueContextSwitch ),
sizeof( QueueHeader ) + sizeof( QueueThreadWakeup ),
sizeof( QueueHeader ) + sizeof( QueueGpuTime ),

View File

@ -4718,8 +4718,14 @@ bool Worker::Process( const QueueItem& ev )
case QueueType::LockName:
ProcessLockName( ev.lockName );
break;
case QueueType::PlotData:
ProcessPlotData( ev.plotData );
case QueueType::PlotDataInt:
ProcessPlotDataInt( ev.plotDataInt );
break;
case QueueType::PlotDataFloat:
ProcessPlotDataFloat( ev.plotDataFloat );
break;
case QueueType::PlotDataDouble:
ProcessPlotDataDouble( ev.plotDataDouble );
break;
case QueueType::PlotConfig:
ProcessPlotConfig( ev.plotConfig );
@ -5637,21 +5643,26 @@ void Worker::ProcessLockName( const QueueLockName& ev )
lit->second->customName = StringIdx( GetSingleStringIdx() );
}
void Worker::ProcessPlotData( const QueuePlotData& ev )
void Worker::ProcessPlotDataInt( const QueuePlotDataInt& ev )
{
switch( ev.type )
{
case PlotDataType::Double:
if( !isfinite( ev.data.d ) ) return;
break;
case PlotDataType::Float:
if( !isfinite( ev.data.f ) ) return;
break;
default:
break;
ProcessPlotDataImpl( ev.name, ev.time, (double)ev.val );
}
PlotData* plot = m_data.plots.Retrieve( ev.name, [this] ( uint64_t name ) {
void Worker::ProcessPlotDataFloat( const QueuePlotDataFloat& ev )
{
if( !isfinite( ev.val ) ) return;
ProcessPlotDataImpl( ev.name, ev.time, (double)ev.val );
}
void Worker::ProcessPlotDataDouble( const QueuePlotDataDouble& ev )
{
if( !isfinite( ev.val ) ) return;
ProcessPlotDataImpl( ev.name, ev.time, ev.val );
}
void Worker::ProcessPlotDataImpl( uint64_t name, int64_t evTime, double val )
{
PlotData* plot = m_data.plots.Retrieve( name, [this] ( uint64_t name ) {
auto plot = m_slab.AllocInit<PlotData>();
plot->name = name;
plot->type = PlotType::User;
@ -5662,23 +5673,9 @@ void Worker::ProcessPlotData( const QueuePlotData& ev )
Query( ServerQueryPlotName, name );
} );
const auto time = TscTime( RefTime( m_refTimeThread, ev.time ) );
const auto time = TscTime( RefTime( m_refTimeThread, evTime ) );
if( m_data.lastTime < time ) m_data.lastTime = time;
switch( ev.type )
{
case PlotDataType::Double:
InsertPlot( plot, time, ev.data.d );
break;
case PlotDataType::Float:
InsertPlot( plot, time, (double)ev.data.f );
break;
case PlotDataType::Int:
InsertPlot( plot, time, (double)ev.data.i );
break;
default:
assert( false );
break;
}
InsertPlot( plot, time, val );
}
void Worker::ProcessPlotConfig( const QueuePlotConfig& ev )

View File

@ -698,7 +698,9 @@ private:
tracy_force_inline void ProcessLockSharedRelease( const QueueLockReleaseShared& ev );
tracy_force_inline void ProcessLockMark( const QueueLockMark& ev );
tracy_force_inline void ProcessLockName( const QueueLockName& ev );
tracy_force_inline void ProcessPlotData( const QueuePlotData& ev );
tracy_force_inline void ProcessPlotDataInt( const QueuePlotDataInt& ev );
tracy_force_inline void ProcessPlotDataFloat( const QueuePlotDataFloat& ev );
tracy_force_inline void ProcessPlotDataDouble( const QueuePlotDataDouble& ev );
tracy_force_inline void ProcessPlotConfig( const QueuePlotConfig& ev );
tracy_force_inline void ProcessMessage( const QueueMessage& ev );
tracy_force_inline void ProcessMessageLiteral( const QueueMessageLiteral& ev );
@ -757,6 +759,7 @@ private:
tracy_force_inline void ProcessGpuZoneBeginImpl( GpuEvent* zone, const QueueGpuZoneBegin& ev, bool serial );
tracy_force_inline void ProcessGpuZoneBeginAllocSrcLocImpl( GpuEvent* zone, const QueueGpuZoneBeginLean& ev, bool serial );
tracy_force_inline void ProcessGpuZoneBeginImplCommon( GpuEvent* zone, const QueueGpuZoneBeginLean& ev, bool serial );
tracy_force_inline void ProcessPlotDataImpl( uint64_t name, int64_t evTime, double val );
tracy_force_inline MemEvent* ProcessMemAllocImpl( uint64_t memname, MemData& memdata, const QueueMemAlloc& ev );
tracy_force_inline MemEvent* ProcessMemFreeImpl( uint64_t memname, MemData& memdata, const QueueMemFree& ev );
tracy_force_inline void ProcessCallstackSampleImpl( const SampleData& sd, ThreadData& td );