mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-26 16:04:34 +00:00
Send lean allocated source locations.
This commit is contained in:
parent
94d0232ed3
commit
2dc07fca0b
@ -1773,7 +1773,7 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token )
|
||||
while( sz-- > 0 )
|
||||
{
|
||||
uint64_t ptr;
|
||||
const auto idx = MemRead<uint8_t>( &item->hdr.idx );
|
||||
auto idx = MemRead<uint8_t>( &item->hdr.idx );
|
||||
if( idx < (int)QueueType::Terminate )
|
||||
{
|
||||
switch( (QueueType)idx )
|
||||
@ -1809,6 +1809,8 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token )
|
||||
ptr = MemRead<uint64_t>( &item->zoneBegin.srcloc );
|
||||
SendSourceLocationPayload( ptr );
|
||||
tracy_free( (void*)ptr );
|
||||
idx++;
|
||||
MemWrite( &item->hdr.idx, idx );
|
||||
break;
|
||||
}
|
||||
case QueueType::Callstack:
|
||||
|
@ -16,7 +16,9 @@ enum class QueueType : uint8_t
|
||||
MessageColorCallstack,
|
||||
MessageAppInfo,
|
||||
ZoneBeginAllocSrcLoc,
|
||||
ZoneBeginAllocSrcLocLean,
|
||||
ZoneBeginAllocSrcLocCallstack,
|
||||
ZoneBeginAllocSrcLocCallstackLean,
|
||||
CallstackMemory,
|
||||
Callstack,
|
||||
CallstackAlloc,
|
||||
@ -96,9 +98,13 @@ struct QueueThreadContext
|
||||
uint64_t thread;
|
||||
};
|
||||
|
||||
struct QueueZoneBegin
|
||||
struct QueueZoneBeginLean
|
||||
{
|
||||
int64_t time;
|
||||
};
|
||||
|
||||
struct QueueZoneBegin : public QueueZoneBeginLean
|
||||
{
|
||||
uint64_t srcloc; // ptr
|
||||
};
|
||||
|
||||
@ -417,6 +423,7 @@ struct QueueItem
|
||||
{
|
||||
QueueThreadContext threadCtx;
|
||||
QueueZoneBegin zoneBegin;
|
||||
QueueZoneBeginLean zoneBeginLean;
|
||||
QueueZoneEnd zoneEnd;
|
||||
QueueZoneValidation zoneValidation;
|
||||
QueueStringTransfer stringTransfer;
|
||||
@ -471,8 +478,10 @@ static constexpr size_t QueueDataSize[] = {
|
||||
sizeof( QueueHeader ) + sizeof( QueueMessage ), // callstack
|
||||
sizeof( QueueHeader ) + sizeof( QueueMessageColor ), // callstack
|
||||
sizeof( QueueHeader ) + sizeof( QueueMessage ), // app info
|
||||
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // allocated source location
|
||||
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // allocated source location, callstack
|
||||
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // allocated source location, not for network transfer
|
||||
sizeof( QueueHeader ) + sizeof( QueueZoneBeginLean ), // lean allocated source location
|
||||
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // allocated source location, callstack, not for network transfer
|
||||
sizeof( QueueHeader ) + sizeof( QueueZoneBeginLean ), // lean allocated source location, callstack
|
||||
sizeof( QueueHeader ) + sizeof( QueueCallstackMemory ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueCallstack ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueCallstackAlloc ),
|
||||
|
@ -3031,7 +3031,7 @@ void Worker::Exec()
|
||||
!m_pendingCustomStrings.empty() || m_data.plots.IsPending() || m_pendingCallstackPtr != 0 ||
|
||||
m_pendingExternalNames != 0 || m_pendingCallstackSubframes != 0 || !m_pendingFrameImageData.empty() ||
|
||||
!m_pendingSymbols.empty() || !m_pendingSymbolCode.empty() || m_pendingCodeInformation != 0 ||
|
||||
!m_serverQueryQueue.empty() )
|
||||
!m_serverQueryQueue.empty() || m_pendingSourceLocationPayload != 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -3604,7 +3604,7 @@ void Worker::AddSourceLocationPayload( uint64_t ptr, const char* data, size_t sz
|
||||
{
|
||||
const auto start = data;
|
||||
|
||||
assert( m_pendingSourceLocationPayload.find( ptr ) == m_pendingSourceLocationPayload.end() );
|
||||
assert( m_pendingSourceLocationPayload == 0 );
|
||||
|
||||
uint32_t color, line;
|
||||
memcpy( &color, data, 4 );
|
||||
@ -3635,7 +3635,7 @@ void Worker::AddSourceLocationPayload( uint64_t ptr, const char* data, size_t sz
|
||||
memcpy( slptr, &srcloc, sizeof( srcloc ) );
|
||||
uint32_t idx = m_data.sourceLocationPayload.size();
|
||||
m_data.sourceLocationPayloadMap.emplace( slptr, idx );
|
||||
m_pendingSourceLocationPayload.emplace( ptr, -int16_t( idx + 1 ) );
|
||||
m_pendingSourceLocationPayload = -int16_t( idx + 1 );
|
||||
m_data.sourceLocationPayload.push_back( slptr );
|
||||
const auto key = -int16_t( idx + 1 );
|
||||
#ifndef TRACY_NO_STATISTICS
|
||||
@ -3651,7 +3651,7 @@ void Worker::AddSourceLocationPayload( uint64_t ptr, const char* data, size_t sz
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pendingSourceLocationPayload.emplace( ptr, -int16_t( it->second + 1 ) );
|
||||
m_pendingSourceLocationPayload = -int16_t( it->second + 1 );
|
||||
}
|
||||
}
|
||||
|
||||
@ -4049,11 +4049,11 @@ bool Worker::Process( const QueueItem& ev )
|
||||
case QueueType::ZoneBeginCallstack:
|
||||
ProcessZoneBeginCallstack( ev.zoneBegin );
|
||||
break;
|
||||
case QueueType::ZoneBeginAllocSrcLoc:
|
||||
ProcessZoneBeginAllocSrcLoc( ev.zoneBegin );
|
||||
case QueueType::ZoneBeginAllocSrcLocLean:
|
||||
ProcessZoneBeginAllocSrcLoc( ev.zoneBeginLean );
|
||||
break;
|
||||
case QueueType::ZoneBeginAllocSrcLocCallstack:
|
||||
ProcessZoneBeginAllocSrcLocCallstack( ev.zoneBegin );
|
||||
case QueueType::ZoneBeginAllocSrcLocCallstackLean:
|
||||
ProcessZoneBeginAllocSrcLocCallstack( ev.zoneBeginLean );
|
||||
break;
|
||||
case QueueType::ZoneEnd:
|
||||
ProcessZoneEnd( ev.zoneEnd );
|
||||
@ -4310,15 +4310,14 @@ void Worker::ProcessZoneBeginCallstack( const QueueZoneBegin& ev )
|
||||
next.zone = zone;
|
||||
}
|
||||
|
||||
void Worker::ProcessZoneBeginAllocSrcLocImpl( ZoneEvent* zone, const QueueZoneBegin& ev )
|
||||
void Worker::ProcessZoneBeginAllocSrcLocImpl( ZoneEvent* zone, const QueueZoneBeginLean& ev )
|
||||
{
|
||||
auto it = m_pendingSourceLocationPayload.find( ev.srcloc );
|
||||
assert( it != m_pendingSourceLocationPayload.end() );
|
||||
assert( m_pendingSourceLocationPayload != 0 );
|
||||
|
||||
const auto refTime = m_refTimeThread + ev.time;
|
||||
m_refTimeThread = refTime;
|
||||
const auto start = TscTime( refTime - m_data.baseTime );
|
||||
zone->SetStartSrcLoc( start, it->second );
|
||||
zone->SetStartSrcLoc( start, m_pendingSourceLocationPayload );
|
||||
zone->SetEnd( -1 );
|
||||
zone->SetChild( -1 );
|
||||
|
||||
@ -4326,16 +4325,16 @@ void Worker::ProcessZoneBeginAllocSrcLocImpl( ZoneEvent* zone, const QueueZoneBe
|
||||
|
||||
NewZone( zone, m_threadCtx );
|
||||
|
||||
m_pendingSourceLocationPayload.erase( it );
|
||||
m_pendingSourceLocationPayload = 0;
|
||||
}
|
||||
|
||||
void Worker::ProcessZoneBeginAllocSrcLoc( const QueueZoneBegin& ev )
|
||||
void Worker::ProcessZoneBeginAllocSrcLoc( const QueueZoneBeginLean& ev )
|
||||
{
|
||||
auto zone = AllocZoneEvent();
|
||||
ProcessZoneBeginAllocSrcLocImpl( zone, ev );
|
||||
}
|
||||
|
||||
void Worker::ProcessZoneBeginAllocSrcLocCallstack( const QueueZoneBegin& ev )
|
||||
void Worker::ProcessZoneBeginAllocSrcLocCallstack( const QueueZoneBeginLean& ev )
|
||||
{
|
||||
auto zone = AllocZoneEvent();
|
||||
ProcessZoneBeginAllocSrcLocImpl( zone, ev );
|
||||
|
@ -559,8 +559,8 @@ private:
|
||||
tracy_force_inline void ProcessThreadContext( const QueueThreadContext& ev );
|
||||
tracy_force_inline void ProcessZoneBegin( const QueueZoneBegin& ev );
|
||||
tracy_force_inline void ProcessZoneBeginCallstack( const QueueZoneBegin& ev );
|
||||
tracy_force_inline void ProcessZoneBeginAllocSrcLoc( const QueueZoneBegin& ev );
|
||||
tracy_force_inline void ProcessZoneBeginAllocSrcLocCallstack( const QueueZoneBegin& ev );
|
||||
tracy_force_inline void ProcessZoneBeginAllocSrcLoc( const QueueZoneBeginLean& ev );
|
||||
tracy_force_inline void ProcessZoneBeginAllocSrcLocCallstack( const QueueZoneBeginLean& ev );
|
||||
tracy_force_inline void ProcessZoneEnd( const QueueZoneEnd& ev );
|
||||
tracy_force_inline void ProcessZoneValidation( const QueueZoneValidation& ev );
|
||||
tracy_force_inline void ProcessFrameMark( const QueueFrameMark& ev );
|
||||
@ -617,7 +617,7 @@ private:
|
||||
|
||||
tracy_force_inline ZoneEvent* AllocZoneEvent();
|
||||
tracy_force_inline void ProcessZoneBeginImpl( ZoneEvent* zone, const QueueZoneBegin& ev );
|
||||
tracy_force_inline void ProcessZoneBeginAllocSrcLocImpl( ZoneEvent* zone, const QueueZoneBegin& ev );
|
||||
tracy_force_inline void ProcessZoneBeginAllocSrcLocImpl( ZoneEvent* zone, const QueueZoneBeginLean& ev );
|
||||
tracy_force_inline void ProcessGpuZoneBeginImpl( GpuEvent* zone, const QueueGpuZoneBegin& ev, bool serial );
|
||||
|
||||
void ZoneStackFailure( uint64_t thread, const ZoneEvent* ev );
|
||||
@ -794,7 +794,7 @@ private:
|
||||
unordered_flat_map<uint64_t, StringLocation> m_pendingCustomStrings;
|
||||
uint64_t m_pendingCallstackPtr = 0;
|
||||
uint32_t m_pendingCallstackId;
|
||||
unordered_flat_map<uint64_t, int16_t> m_pendingSourceLocationPayload;
|
||||
int16_t m_pendingSourceLocationPayload = 0;
|
||||
Vector<uint64_t> m_sourceLocationQueue;
|
||||
unordered_flat_map<uint64_t, int16_t> m_sourceLocationShrink;
|
||||
unordered_flat_map<uint64_t, ThreadData*> m_threadMap;
|
||||
|
Loading…
Reference in New Issue
Block a user