diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 0e4e7c76..2c3e01a5 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -2511,6 +2511,7 @@ void Worker::Exec() const char* ptr = m_buffer + netbuf.bufferOffset; const char* end = ptr + netbuf.size; + m_data.newFramesWereReceived = false; { std::lock_guard lock( m_data.lock ); @@ -2531,6 +2532,7 @@ void Worker::Exec() } HandlePostponedPlots(); + HandlePostponedSamples(); while( !m_serverQueryQueue.empty() && m_serverQuerySpaceLeft > 0 ) { @@ -3337,6 +3339,18 @@ void Worker::HandlePostponedPlots() } } +void Worker::HandlePostponedSamples() +{ + if( !m_data.newFramesWereReceived ) return; + if( m_data.postponedSamples.empty() ) return; + auto it = m_data.postponedSamples.begin(); + do + { + UpdateSampleStatisticsPostponed( it ); + } + while( it != m_data.postponedSamples.end() ); +} + StringLocation Worker::StoreString( const char* str, size_t sz ) { StringLocation ret; @@ -4754,6 +4768,7 @@ void Worker::ProcessCallstackFrameSize( const QueueCallstackFrameSize& ev ) assert( m_pendingCallstackFrames > 0 ); m_pendingCallstackFrames--; m_pendingCallstackSubframes = ev.size; + m_data.newFramesWereReceived = true; auto iit = m_pendingCustomStrings.find( ev.imageName ); assert( iit != m_pendingCustomStrings.end() ); @@ -5292,6 +5307,27 @@ void Worker::UpdateSampleStatistics( uint32_t callstack, uint32_t count, bool ca UpdateSampleStatisticsImpl( frames, cssz, count ); } +void Worker::UpdateSampleStatisticsPostponed( decltype(Worker::DataBlock::postponedSamples.begin())& it ) +{ + const auto& cs = GetCallstack( it->first ); + const auto cssz = cs.size(); + + auto frames = (const CallstackFrameData**)alloca( cssz * sizeof( CallstackFrameData* ) ); + for( uint8_t i=0; isecond ); + it = m_data.postponedSamples.erase( it ); +} + void Worker::UpdateSampleStatisticsImpl( const CallstackFrameData** frames, uint8_t framesCount, uint32_t count ) { { diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index 2895126f..773a15eb 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -228,6 +228,7 @@ private: #ifndef TRACY_NO_STATISTICS unordered_flat_map postponedSamples; + bool newFramesWereReceived = false; bool callstackSamplesReady = false; #endif @@ -631,6 +632,7 @@ private: void HandleFrameName( uint64_t name, const char* str, size_t sz ); void HandlePostponedPlots(); + void HandlePostponedSamples(); StringLocation StoreString( const char* str, size_t sz ); const ContextSwitch* const GetContextSwitchDataImpl( uint64_t thread ); @@ -640,6 +642,7 @@ private: #ifndef TRACY_NO_STATISTICS void ReconstructContextSwitchUsage(); void UpdateSampleStatistics( uint32_t callstack, uint32_t count, bool canPostpone ); + void UpdateSampleStatisticsPostponed( decltype(Worker::DataBlock::postponedSamples.begin())& it ); void UpdateSampleStatisticsImpl( const CallstackFrameData** frames, uint8_t framesCount, uint32_t count ); #endif