From e4ce9f0f4136127dd359edb3e23412de60c769fd Mon Sep 17 00:00:00 2001 From: xavier Date: Sat, 4 Sep 2021 16:11:41 +0200 Subject: [PATCH] Include threadid in SampleDataRange TODO: maybe make lists per thread to avoid increasing the packed structure by 2 bytes? --- server/TracyEvent.hpp | 1 + server/TracyWorker.cpp | 17 ++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/server/TracyEvent.hpp b/server/TracyEvent.hpp index edb5ba67..499778ea 100644 --- a/server/TracyEvent.hpp +++ b/server/TracyEvent.hpp @@ -268,6 +268,7 @@ enum { SampleDataSize = sizeof( SampleData ) }; struct SampleDataRange { Int48 time; + uint16_t thread; CallstackFrameId ip; }; diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 754c403a..306f9d27 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -1931,6 +1931,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks ) jobs.emplace_back( std::thread( [this] { for( auto& t : m_data.threads ) { + uint16_t tid = CompressThread( t->id ); for( auto& v : t->samples ) { const auto& time = v.time; @@ -1944,11 +1945,11 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks ) auto it = m_data.symbolSamples.find( symAddr ); if( it == m_data.symbolSamples.end() ) { - m_data.symbolSamples.emplace( symAddr, Vector( SampleDataRange { time, ip } ) ); + m_data.symbolSamples.emplace( symAddr, Vector( SampleDataRange { time, tid, ip } ) ); } else { - it->second.push_back_non_empty( SampleDataRange { time, ip } ); + it->second.push_back_non_empty( SampleDataRange { time, tid, ip } ); } } for( uint16_t i=1; i( SampleDataRange { sd.time, ip } ) ); + m_data.symbolSamples.emplace( symAddr, Vector( SampleDataRange { sd.time, tid, ip } ) ); } else { if( sit->second.back().time.Val() <= sd.time.Val() ) { - sit->second.push_back_non_empty( SampleDataRange { sd.time, ip } ); + sit->second.push_back_non_empty( SampleDataRange { sd.time, tid, ip } ); } else { auto iit = std::upper_bound( sit->second.begin(), sit->second.end(), sd.time.Val(), [] ( const auto& lhs, const auto& rhs ) { return lhs < rhs.time.Val(); } ); - sit->second.insert( iit, SampleDataRange { sd.time, ip } ); + sit->second.insert( iit, SampleDataRange { sd.time, tid, ip } ); } } } @@ -6023,11 +6026,11 @@ void Worker::ProcessCallstackSampleImpl( const SampleData& sd, ThreadData& td, i auto sit = m_data.pendingSymbolSamples.find( ip ); if( sit == m_data.pendingSymbolSamples.end() ) { - m_data.pendingSymbolSamples.emplace( ip, Vector( SampleDataRange { sd.time, ip } ) ); + m_data.pendingSymbolSamples.emplace( ip, Vector( SampleDataRange { sd.time, tid, ip } ) ); } else { - sit->second.push_back_non_empty( SampleDataRange { sd.time, ip } ); + sit->second.push_back_non_empty( SampleDataRange { sd.time, tid, ip } ); } } }