mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-26 07:54:36 +00:00
Process postponed samples when new frame data is available.
This commit is contained in:
parent
0d112e20a5
commit
bdc86f5338
@ -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<std::shared_mutex> 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; i<cssz; i++ )
|
||||
{
|
||||
auto frame = GetCallstackFrame( cs[i] );
|
||||
if( !frame )
|
||||
{
|
||||
++it;
|
||||
return;
|
||||
}
|
||||
frames[i] = frame;
|
||||
}
|
||||
|
||||
UpdateSampleStatisticsImpl( frames, cssz, it->second );
|
||||
it = m_data.postponedSamples.erase( it );
|
||||
}
|
||||
|
||||
void Worker::UpdateSampleStatisticsImpl( const CallstackFrameData** frames, uint8_t framesCount, uint32_t count )
|
||||
{
|
||||
{
|
||||
|
@ -228,6 +228,7 @@ private:
|
||||
|
||||
#ifndef TRACY_NO_STATISTICS
|
||||
unordered_flat_map<uint32_t, uint32_t> 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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user