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