mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Postpone processing incomplete sampled callstacks.
This commit is contained in:
parent
7e4088ed61
commit
3412d2232f
@ -1737,7 +1737,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks )
|
||||
}
|
||||
}
|
||||
}
|
||||
for( auto& v : counts ) UpdateSampleStatistics( v.first, v.second );
|
||||
for( auto& v : counts ) UpdateSampleStatistics( v.first, v.second, false );
|
||||
}
|
||||
|
||||
std::lock_guard<std::shared_mutex> lock( m_data.lock );
|
||||
@ -4743,7 +4743,7 @@ void Worker::ProcessCallstackSample( const QueueCallstackSample& ev )
|
||||
}
|
||||
|
||||
#ifndef TRACY_NO_STATISTICS
|
||||
UpdateSampleStatistics( m_pendingCallstackId, 1 );
|
||||
UpdateSampleStatistics( m_pendingCallstackId, 1, true );
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -5246,14 +5246,54 @@ void Worker::ReconstructContextSwitchUsage()
|
||||
m_data.ctxUsageReady = true;
|
||||
}
|
||||
|
||||
void Worker::UpdateSampleStatistics( uint32_t callstack, uint32_t count )
|
||||
void Worker::UpdateSampleStatistics( uint32_t callstack, uint32_t count, bool canPostpone )
|
||||
{
|
||||
const auto& cs = GetCallstack( callstack );
|
||||
const auto cssz = cs.size();
|
||||
|
||||
const auto fexcl = GetCallstackFrame( cs[0] );
|
||||
if( fexcl )
|
||||
auto frames = (const CallstackFrameData**)alloca( cssz * sizeof( CallstackFrameData* ) );
|
||||
for( uint8_t i=0; i<cssz; i++ )
|
||||
{
|
||||
auto frame = GetCallstackFrame( cs[i] );
|
||||
if( !frame )
|
||||
{
|
||||
if( canPostpone )
|
||||
{
|
||||
auto it = m_data.postponedSamples.find( callstack );
|
||||
if( it == m_data.postponedSamples.end() )
|
||||
{
|
||||
m_data.postponedSamples.emplace( callstack, count );
|
||||
}
|
||||
else
|
||||
{
|
||||
it->second += count;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
frames[i] = frame;
|
||||
}
|
||||
}
|
||||
|
||||
if( canPostpone )
|
||||
{
|
||||
auto it = m_data.postponedSamples.find( callstack );
|
||||
if( it != m_data.postponedSamples.end() )
|
||||
{
|
||||
count += it->second;
|
||||
m_data.postponedSamples.erase( it );
|
||||
}
|
||||
}
|
||||
|
||||
UpdateSampleStatisticsImpl( frames, cssz, count );
|
||||
}
|
||||
|
||||
void Worker::UpdateSampleStatisticsImpl( const CallstackFrameData** frames, uint8_t framesCount, uint32_t count )
|
||||
{
|
||||
{
|
||||
const auto fexcl = frames[0];
|
||||
const auto fsz = fexcl->size;
|
||||
const auto& frame0 = fexcl->data[0];
|
||||
auto sym = m_data.symbolStats.find( frame0.symAddr );
|
||||
@ -5267,11 +5307,9 @@ void Worker::UpdateSampleStatistics( uint32_t callstack, uint32_t count )
|
||||
sym->second.incl += count;
|
||||
}
|
||||
}
|
||||
for( uint8_t c=1; c<cssz; c++ )
|
||||
{
|
||||
const auto fincl = GetCallstackFrame( cs[c] );
|
||||
if( fincl )
|
||||
for( uint8_t c=1; c<framesCount; c++ )
|
||||
{
|
||||
const auto fincl = frames[c];
|
||||
const auto fsz = fincl->size;
|
||||
for( uint8_t f=0; f<fsz; f++ )
|
||||
{
|
||||
@ -5281,7 +5319,6 @@ void Worker::UpdateSampleStatistics( uint32_t callstack, uint32_t count )
|
||||
sym->second.incl += count;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -227,6 +227,7 @@ private:
|
||||
unordered_flat_map<uint64_t, SymbolStats> symbolStats;
|
||||
|
||||
#ifndef TRACY_NO_STATISTICS
|
||||
unordered_flat_map<uint32_t, uint32_t> postponedSamples;
|
||||
bool callstackSamplesReady = false;
|
||||
#endif
|
||||
|
||||
@ -638,7 +639,8 @@ private:
|
||||
|
||||
#ifndef TRACY_NO_STATISTICS
|
||||
void ReconstructContextSwitchUsage();
|
||||
void UpdateSampleStatistics( uint32_t callstack, uint32_t count );
|
||||
void UpdateSampleStatistics( uint32_t callstack, uint32_t count, bool canPostpone );
|
||||
void UpdateSampleStatisticsImpl( const CallstackFrameData** frames, uint8_t framesCount, uint32_t count );
|
||||
#endif
|
||||
|
||||
tracy_force_inline int64_t ReadTimeline( FileRead& f, ZoneEvent* zone, int64_t refTime, int32_t& childIdx );
|
||||
|
Loading…
Reference in New Issue
Block a user