diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index a33f528e..e6cc3bc2 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -764,10 +764,24 @@ const Worker::SourceLocationZones& Worker::GetZonesForSourceLocation( int32_t sr #endif uint16_t Worker::CompressThread( uint64_t thread ) +{ + if( m_data.threadLast.first == thread ) + { + return m_data.threadLast.second; + } + else + { + return CompressThreadReal( thread ); + } +} + +uint16_t Worker::CompressThreadReal( uint64_t thread ) { auto it = m_data.threadMap.find( thread ); if( it != m_data.threadMap.end() ) { + m_data.threadLast.first = thread; + m_data.threadLast.second = it->second; return it->second; } else @@ -781,6 +795,8 @@ uint16_t Worker::CompressThreadNew( uint64_t thread ) auto sz = m_data.threadExpand.size(); m_data.threadExpand.push_back( thread ); m_data.threadMap.emplace( thread, sz ); + m_data.threadLast.first = thread; + m_data.threadLast.second = sz; return sz; } diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index 82a0f188..02f10ac6 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -70,7 +70,7 @@ class Worker struct DataBlock { - DataBlock() : zonesCnt( 0 ), lastTime( 0 ) {} + DataBlock() : zonesCnt( 0 ), lastTime( 0 ), threadLast( std::numeric_limits::max(), 0 ) {} NonRecursiveBenaphore lock; Vector frames; @@ -100,6 +100,7 @@ class Worker flat_hash_map> threadMap; Vector threadExpand; + std::pair threadLast; }; struct MbpsBlock @@ -239,6 +240,7 @@ private: void HandlePostponedPlots(); StringLocation StoreString( char* str, size_t sz ); + uint16_t CompressThreadReal( uint64_t thread ); uint16_t CompressThreadNew( uint64_t thread ); tracy_force_inline void ReadTimeline( FileRead& f, Vector& vec, uint16_t thread );