diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index d3614edc..a01de767 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -1773,7 +1773,7 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token ) while( sz-- > 0 ) { uint64_t ptr; - const auto idx = MemRead( &item->hdr.idx ); + auto idx = MemRead( &item->hdr.idx ); if( idx < (int)QueueType::Terminate ) { switch( (QueueType)idx ) @@ -1809,6 +1809,8 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token ) ptr = MemRead( &item->zoneBegin.srcloc ); SendSourceLocationPayload( ptr ); tracy_free( (void*)ptr ); + idx++; + MemWrite( &item->hdr.idx, idx ); break; } case QueueType::Callstack: diff --git a/common/TracyQueue.hpp b/common/TracyQueue.hpp index 194d5085..833ace4c 100644 --- a/common/TracyQueue.hpp +++ b/common/TracyQueue.hpp @@ -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 ), diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index bc8d1112..bc86f759 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -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 ); diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index e31e7dc9..daf1cf75 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -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 m_pendingCustomStrings; uint64_t m_pendingCallstackPtr = 0; uint32_t m_pendingCallstackId; - unordered_flat_map m_pendingSourceLocationPayload; + int16_t m_pendingSourceLocationPayload = 0; Vector m_sourceLocationQueue; unordered_flat_map m_sourceLocationShrink; unordered_flat_map m_threadMap;