From bef31ba073f57407d01b5c49a974211c5a31a40e Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 3 Mar 2019 17:47:26 +0100 Subject: [PATCH] Separate message for zone begin with alloc src loc and callstack. --- TracyLua.hpp | 4 ++-- client/TracyProfiler.cpp | 2 ++ common/TracyQueue.hpp | 2 ++ server/TracyWorker.cpp | 24 +++++++++++++++++++++--- server/TracyWorker.hpp | 2 ++ 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/TracyLua.hpp b/TracyLua.hpp index a3ba92c0..ed23abf5 100644 --- a/TracyLua.hpp +++ b/TracyLua.hpp @@ -227,7 +227,7 @@ static inline int LuaZoneBeginS( lua_State* L ) auto token = GetToken(); auto& tail = token->get_tail_index(); auto item = token->enqueue_begin( magic ); - MemWrite( &item->hdr.type, QueueType::ZoneBeginAllocSrcLoc ); + MemWrite( &item->hdr.type, QueueType::ZoneBeginAllocSrcLocCallstack ); #ifdef TRACY_RDTSCP_OPT MemWrite( &item->zoneBegin.time, Profiler::GetTime( item->zoneBegin.cpu ) ); #else @@ -293,7 +293,7 @@ static inline int LuaZoneBeginNS( lua_State* L ) auto token = GetToken(); auto& tail = token->get_tail_index(); auto item = token->enqueue_begin( magic ); - MemWrite( &item->hdr.type, QueueType::ZoneBeginAllocSrcLoc ); + MemWrite( &item->hdr.type, QueueType::ZoneBeginAllocSrcLocCallstack ); #ifdef TRACY_RDTSCP_OPT MemWrite( &item->zoneBegin.time, Profiler::GetTime( item->zoneBegin.cpu ) ); #else diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index ccc94d2f..3b4d847b 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -1316,6 +1316,7 @@ static void FreeAssociatedMemory( const QueueItem& item ) tracy_free( (void*)ptr ); break; case QueueType::ZoneBeginAllocSrcLoc: + case QueueType::ZoneBeginAllocSrcLocCallstack: ptr = MemRead( &item.zoneBegin.srcloc ); tracy_free( (void*)ptr ); break; @@ -1392,6 +1393,7 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token ) tracy_free( (void*)ptr ); break; case QueueType::ZoneBeginAllocSrcLoc: + case QueueType::ZoneBeginAllocSrcLocCallstack: ptr = MemRead( &item->zoneBegin.srcloc ); SendSourceLocationPayload( ptr ); tracy_free( (void*)ptr ); diff --git a/common/TracyQueue.hpp b/common/TracyQueue.hpp index 8dc010dc..bcc15efe 100644 --- a/common/TracyQueue.hpp +++ b/common/TracyQueue.hpp @@ -12,6 +12,7 @@ enum class QueueType : uint8_t ZoneName, Message, ZoneBeginAllocSrcLoc, + ZoneBeginAllocSrcLocCallstack, CallstackMemory, Callstack, CallstackAlloc, @@ -327,6 +328,7 @@ static const size_t QueueDataSize[] = { sizeof( QueueHeader ) + sizeof( QueueZoneText ), // zone name sizeof( QueueHeader ) + sizeof( QueueMessage ), sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // allocated source location + sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // allocated source location, callstack sizeof( QueueHeader ) + sizeof( QueueCallstackMemory ), sizeof( QueueHeader ) + sizeof( QueueCallstack ), sizeof( QueueHeader ) + sizeof( QueueCallstack ), // callstack alloc diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 4b9b45ec..06f42080 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -2316,6 +2316,9 @@ bool Worker::Process( const QueueItem& ev ) case QueueType::ZoneBeginAllocSrcLoc: ProcessZoneBeginAllocSrcLoc( ev.zoneBegin ); break; + case QueueType::ZoneBeginAllocSrcLocCallstack: + ProcessZoneBeginAllocSrcLocCallstack( ev.zoneBegin ); + break; case QueueType::ZoneEnd: ProcessZoneEnd( ev.zoneEnd ); break; @@ -2407,6 +2410,7 @@ bool Worker::Process( const QueueItem& ev ) ProcessCallstackMemory( ev.callstackMemory ); break; case QueueType::Callstack: + case QueueType::CallstackAlloc: ProcessCallstack( ev.callstack ); break; case QueueType::CallstackFrameSize: @@ -2470,13 +2474,11 @@ void Worker::ProcessZoneBeginCallstack( const QueueZoneBegin& ev ) next.zone = zone; } -void Worker::ProcessZoneBeginAllocSrcLoc( const QueueZoneBegin& ev ) +void Worker::ProcessZoneBeginAllocSrcLocImpl( ZoneEvent* zone, const QueueZoneBegin& ev ) { auto it = m_pendingSourceLocationPayload.find( ev.srcloc ); assert( it != m_pendingSourceLocationPayload.end() ); - auto zone = m_slab.AllocInit(); - zone->start = TscTime( ev.time ); zone->end = -1; zone->srcloc = it->second; @@ -2492,6 +2494,22 @@ void Worker::ProcessZoneBeginAllocSrcLoc( const QueueZoneBegin& ev ) m_pendingSourceLocationPayload.erase( it ); } +void Worker::ProcessZoneBeginAllocSrcLoc( const QueueZoneBegin& ev ) +{ + auto zone = m_slab.AllocInit(); + ProcessZoneBeginAllocSrcLocImpl( zone, ev ); +} + +void Worker::ProcessZoneBeginAllocSrcLocCallstack( const QueueZoneBegin& ev ) +{ + auto zone = m_slab.AllocInit(); + ProcessZoneBeginAllocSrcLocImpl( zone, ev ); + + auto& next = m_nextCallstack[ev.thread]; + next.type = NextCallstackType::Zone; + next.zone = zone; +} + void Worker::ProcessZoneEnd( const QueueZoneEnd& ev ) { auto tit = m_threadMap.find( ev.thread ); diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index f69e7570..6455f891 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -351,6 +351,7 @@ private: 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 ProcessZoneEnd( const QueueZoneEnd& ev ); tracy_force_inline void ProcessZoneValidation( const QueueZoneValidation& 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 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 ); void ZoneStackFailure( uint64_t thread, const ZoneEvent* ev );