Separate message for zone begin with alloc src loc and callstack.

This commit is contained in:
Bartosz Taudul 2019-03-03 17:47:26 +01:00
parent 66b8a13e77
commit bef31ba073
5 changed files with 29 additions and 5 deletions

View File

@ -227,7 +227,7 @@ static inline int LuaZoneBeginS( lua_State* L )
auto token = GetToken(); auto token = GetToken();
auto& tail = token->get_tail_index(); auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic ); auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
MemWrite( &item->hdr.type, QueueType::ZoneBeginAllocSrcLoc ); MemWrite( &item->hdr.type, QueueType::ZoneBeginAllocSrcLocCallstack );
#ifdef TRACY_RDTSCP_OPT #ifdef TRACY_RDTSCP_OPT
MemWrite( &item->zoneBegin.time, Profiler::GetTime( item->zoneBegin.cpu ) ); MemWrite( &item->zoneBegin.time, Profiler::GetTime( item->zoneBegin.cpu ) );
#else #else
@ -293,7 +293,7 @@ static inline int LuaZoneBeginNS( lua_State* L )
auto token = GetToken(); auto token = GetToken();
auto& tail = token->get_tail_index(); auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic ); auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
MemWrite( &item->hdr.type, QueueType::ZoneBeginAllocSrcLoc ); MemWrite( &item->hdr.type, QueueType::ZoneBeginAllocSrcLocCallstack );
#ifdef TRACY_RDTSCP_OPT #ifdef TRACY_RDTSCP_OPT
MemWrite( &item->zoneBegin.time, Profiler::GetTime( item->zoneBegin.cpu ) ); MemWrite( &item->zoneBegin.time, Profiler::GetTime( item->zoneBegin.cpu ) );
#else #else

View File

@ -1316,6 +1316,7 @@ static void FreeAssociatedMemory( const QueueItem& item )
tracy_free( (void*)ptr ); tracy_free( (void*)ptr );
break; break;
case QueueType::ZoneBeginAllocSrcLoc: case QueueType::ZoneBeginAllocSrcLoc:
case QueueType::ZoneBeginAllocSrcLocCallstack:
ptr = MemRead<uint64_t>( &item.zoneBegin.srcloc ); ptr = MemRead<uint64_t>( &item.zoneBegin.srcloc );
tracy_free( (void*)ptr ); tracy_free( (void*)ptr );
break; break;
@ -1392,6 +1393,7 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token )
tracy_free( (void*)ptr ); tracy_free( (void*)ptr );
break; break;
case QueueType::ZoneBeginAllocSrcLoc: case QueueType::ZoneBeginAllocSrcLoc:
case QueueType::ZoneBeginAllocSrcLocCallstack:
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 );

View File

@ -12,6 +12,7 @@ enum class QueueType : uint8_t
ZoneName, ZoneName,
Message, Message,
ZoneBeginAllocSrcLoc, ZoneBeginAllocSrcLoc,
ZoneBeginAllocSrcLocCallstack,
CallstackMemory, CallstackMemory,
Callstack, Callstack,
CallstackAlloc, CallstackAlloc,
@ -327,6 +328,7 @@ static const size_t QueueDataSize[] = {
sizeof( QueueHeader ) + sizeof( QueueZoneText ), // zone name sizeof( QueueHeader ) + sizeof( QueueZoneText ), // zone name
sizeof( QueueHeader ) + sizeof( QueueMessage ), sizeof( QueueHeader ) + sizeof( QueueMessage ),
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // allocated source location sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // allocated source location
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // allocated source location, callstack
sizeof( QueueHeader ) + sizeof( QueueCallstackMemory ), sizeof( QueueHeader ) + sizeof( QueueCallstackMemory ),
sizeof( QueueHeader ) + sizeof( QueueCallstack ), sizeof( QueueHeader ) + sizeof( QueueCallstack ),
sizeof( QueueHeader ) + sizeof( QueueCallstack ), // callstack alloc sizeof( QueueHeader ) + sizeof( QueueCallstack ), // callstack alloc

View File

@ -2316,6 +2316,9 @@ bool Worker::Process( const QueueItem& ev )
case QueueType::ZoneBeginAllocSrcLoc: case QueueType::ZoneBeginAllocSrcLoc:
ProcessZoneBeginAllocSrcLoc( ev.zoneBegin ); ProcessZoneBeginAllocSrcLoc( ev.zoneBegin );
break; break;
case QueueType::ZoneBeginAllocSrcLocCallstack:
ProcessZoneBeginAllocSrcLocCallstack( ev.zoneBegin );
break;
case QueueType::ZoneEnd: case QueueType::ZoneEnd:
ProcessZoneEnd( ev.zoneEnd ); ProcessZoneEnd( ev.zoneEnd );
break; break;
@ -2407,6 +2410,7 @@ bool Worker::Process( const QueueItem& ev )
ProcessCallstackMemory( ev.callstackMemory ); ProcessCallstackMemory( ev.callstackMemory );
break; break;
case QueueType::Callstack: case QueueType::Callstack:
case QueueType::CallstackAlloc:
ProcessCallstack( ev.callstack ); ProcessCallstack( ev.callstack );
break; break;
case QueueType::CallstackFrameSize: case QueueType::CallstackFrameSize:
@ -2470,13 +2474,11 @@ void Worker::ProcessZoneBeginCallstack( const QueueZoneBegin& ev )
next.zone = zone; next.zone = zone;
} }
void Worker::ProcessZoneBeginAllocSrcLoc( const QueueZoneBegin& ev ) void Worker::ProcessZoneBeginAllocSrcLocImpl( ZoneEvent* zone, const QueueZoneBegin& ev )
{ {
auto it = m_pendingSourceLocationPayload.find( ev.srcloc ); auto it = m_pendingSourceLocationPayload.find( ev.srcloc );
assert( it != m_pendingSourceLocationPayload.end() ); assert( it != m_pendingSourceLocationPayload.end() );
auto zone = m_slab.AllocInit<ZoneEvent>();
zone->start = TscTime( ev.time ); zone->start = TscTime( ev.time );
zone->end = -1; zone->end = -1;
zone->srcloc = it->second; zone->srcloc = it->second;
@ -2492,6 +2494,22 @@ void Worker::ProcessZoneBeginAllocSrcLoc( const QueueZoneBegin& ev )
m_pendingSourceLocationPayload.erase( it ); m_pendingSourceLocationPayload.erase( it );
} }
void Worker::ProcessZoneBeginAllocSrcLoc( const QueueZoneBegin& ev )
{
auto zone = m_slab.AllocInit<ZoneEvent>();
ProcessZoneBeginAllocSrcLocImpl( zone, ev );
}
void Worker::ProcessZoneBeginAllocSrcLocCallstack( const QueueZoneBegin& ev )
{
auto zone = m_slab.AllocInit<ZoneEvent>();
ProcessZoneBeginAllocSrcLocImpl( zone, ev );
auto& next = m_nextCallstack[ev.thread];
next.type = NextCallstackType::Zone;
next.zone = zone;
}
void Worker::ProcessZoneEnd( const QueueZoneEnd& ev ) void Worker::ProcessZoneEnd( const QueueZoneEnd& ev )
{ {
auto tit = m_threadMap.find( ev.thread ); auto tit = m_threadMap.find( ev.thread );

View File

@ -351,6 +351,7 @@ private:
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 QueueZoneBegin& ev );
tracy_force_inline void ProcessZoneBeginAllocSrcLocCallstack( const QueueZoneBegin& 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 );
@ -387,6 +388,7 @@ private:
tracy_force_inline void ProcessSysTime( const QueueSysTime& ev ); tracy_force_inline void ProcessSysTime( const QueueSysTime& ev );
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 ProcessGpuZoneBeginImpl( GpuEvent* zone, const QueueGpuZoneBegin& ev ); tracy_force_inline void ProcessGpuZoneBeginImpl( GpuEvent* zone, const QueueGpuZoneBegin& ev );
void ZoneStackFailure( uint64_t thread, const ZoneEvent* ev ); void ZoneStackFailure( uint64_t thread, const ZoneEvent* ev );