diff --git a/server/TracyEvent.hpp b/server/TracyEvent.hpp index 182d5573..8f3c6ef9 100644 --- a/server/TracyEvent.hpp +++ b/server/TracyEvent.hpp @@ -20,7 +20,7 @@ struct ZoneEvent { int64_t start; int64_t end; - uint64_t srcloc; + uint32_t srcloc; int8_t cpu_start; int8_t cpu_end; @@ -41,7 +41,7 @@ struct LockEvent }; int64_t time; - uint64_t srcloc; + uint32_t srcloc; uint64_t waitList; uint8_t thread; uint8_t lockingThread; diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 23f1797c..59a3760d 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -156,6 +156,7 @@ View::View( const char* addr ) , m_onlyContendedLocks( false ) , m_namespace( Namespace::Full ) , m_terminate( false ) + , m_sourceLocationExpand( { 0 } ) { assert( s_instance == nullptr ); s_instance = this; @@ -268,6 +269,15 @@ View::View( FileRead& f ) m_sourceLocation.emplace( ptr, srcloc ); } + f.Read( &sz, sizeof( sz ) ); + m_sourceLocationExpand.reserve( sz ); + for( uint64_t i=0; istart = ev.time * m_timerMul; zone->end = -1; - zone->srcloc = ev.srcloc; + zone->srcloc = ShrinkSourceLocation( ev.srcloc ); assert( ev.cpu == 0xFFFFFFFF || ev.cpu <= std::numeric_limits::max() ); zone->cpu_start = ev.cpu == 0xFFFFFFFF ? -1 : (int8_t)ev.cpu; zone->text = -1; @@ -731,14 +741,14 @@ void View::ProcessLockWait( const QueueLockWait& ev ) if( it == m_lockMap.end() ) { LockMap lm; - lm.srcloc = ev.lckloc; + lm.srcloc = ShrinkSourceLocation( ev.lckloc ); lm.visible = true; it = m_lockMap.emplace( ev.id, std::move( lm ) ).first; CheckSourceLocation( ev.lckloc ); } else if( it->second.srcloc == 0 ) { - it->second.srcloc = ev.lckloc; + it->second.srcloc = ShrinkSourceLocation( ev.lckloc ); CheckSourceLocation( ev.lckloc ); } InsertLockEvent( it->second, lev, ev.thread ); @@ -786,7 +796,7 @@ void View::ProcessLockMark( const QueueLockMark& ev ) { case LockEvent::Type::Obtain: case LockEvent::Type::Wait: - (*it)->srcloc = ev.srcloc; + (*it)->srcloc = ShrinkSourceLocation( ev.srcloc ); return; default: break; @@ -965,6 +975,22 @@ void View::AddMessageData( uint64_t ptr, const char* str, size_t sz ) m_pendingMessages.erase( it ); } +uint32_t View::ShrinkSourceLocation( uint64_t srcloc ) +{ + auto it = m_sourceLocationShrink.find( srcloc ); + if( it != m_sourceLocationShrink.end() ) + { + return it->second; + } + else + { + const auto sz = m_sourceLocationExpand.size(); + m_sourceLocationExpand.push_back( srcloc ); + m_sourceLocationShrink.emplace( srcloc, sz ); + return sz; + } +} + void View::InsertMessageData( MessageData* msg, uint64_t thread ) { std::lock_guard lock( m_lock ); @@ -1285,10 +1311,10 @@ const char* View::GetThreadString( uint64_t id ) const } } -const QueueSourceLocation& View::GetSourceLocation( uint64_t srcloc ) const +const QueueSourceLocation& View::GetSourceLocation( uint32_t srcloc ) const { static const QueueSourceLocation empty = {}; - const auto it = m_sourceLocation.find( srcloc ); + const auto it = m_sourceLocation.find( m_sourceLocationExpand[srcloc] ); if( it == m_sourceLocation.end() ) return empty; return it->second; } @@ -2430,7 +2456,7 @@ int View::DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos, ImGui::Text( "Time: %s", TimeToString( t1 - t0 ) ); ImGui::Separator(); - uint64_t markloc = 0; + uint32_t markloc = 0; auto it = vbegin; for(;;) { @@ -3154,6 +3180,13 @@ void View::Write( FileWrite& f ) f.Write( &v.second, sizeof( v.second ) ); } + sz = m_sourceLocationExpand.size(); + f.Write( &sz, sizeof( sz ) ); + for( auto& v : m_sourceLocationExpand ) + { + f.Write( &v, sizeof( v ) ); + } + sz = m_lockMap.size(); f.Write( &sz, sizeof( sz ) ); for( auto& v : m_lockMap ) diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 8c9a4fc9..d342bd07 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -81,7 +81,7 @@ private: struct LockMap { - uint64_t srcloc; + uint32_t srcloc; Vector timeline; std::unordered_map threadMap; std::vector threadList; @@ -147,6 +147,8 @@ private: void AddSourceLocation( const QueueSourceLocation& srcloc ); void AddMessageData( uint64_t ptr, const char* str, size_t sz ); + uint32_t ShrinkSourceLocation( uint64_t srcloc ); + void InsertMessageData( MessageData* msg, uint64_t thread ); ThreadData* NoticeThread( uint64_t thread ); @@ -171,7 +173,7 @@ private: int64_t GetZoneEnd( const ZoneEvent& ev ) const; const char* GetString( uint64_t ptr ) const; const char* GetThreadString( uint64_t id ) const; - const QueueSourceLocation& GetSourceLocation( uint64_t srcloc ) const; + const QueueSourceLocation& GetSourceLocation( uint32_t srcloc ) const; const char* ShortenNamespace( const char* name ) const; @@ -226,6 +228,7 @@ private: std::unordered_map m_threadNames; std::unordered_set m_customStrings; std::unordered_map m_sourceLocation; + std::vector m_sourceLocationExpand; std::map m_lockMap; uint64_t m_zonesCnt; @@ -243,6 +246,7 @@ private: std::unordered_map m_plotRev; std::unordered_map m_pendingPlots; std::unordered_map m_pendingMessages; + std::unordered_map m_sourceLocationShrink; Slab<64*1024*1024> m_slab;