mirror of
https://github.com/wolfpld/tracy
synced 2025-04-30 12:53:51 +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 );
|
std::lock_guard<std::shared_mutex> lock( m_data.lock );
|
||||||
@ -4743,7 +4743,7 @@ void Worker::ProcessCallstackSample( const QueueCallstackSample& ev )
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TRACY_NO_STATISTICS
|
#ifndef TRACY_NO_STATISTICS
|
||||||
UpdateSampleStatistics( m_pendingCallstackId, 1 );
|
UpdateSampleStatistics( m_pendingCallstackId, 1, true );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5246,14 +5246,54 @@ void Worker::ReconstructContextSwitchUsage()
|
|||||||
m_data.ctxUsageReady = true;
|
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& cs = GetCallstack( callstack );
|
||||||
const auto cssz = cs.size();
|
const auto cssz = cs.size();
|
||||||
|
|
||||||
const auto fexcl = GetCallstackFrame( cs[0] );
|
auto frames = (const CallstackFrameData**)alloca( cssz * sizeof( CallstackFrameData* ) );
|
||||||
if( fexcl )
|
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 fsz = fexcl->size;
|
||||||
const auto& frame0 = fexcl->data[0];
|
const auto& frame0 = fexcl->data[0];
|
||||||
auto sym = m_data.symbolStats.find( frame0.symAddr );
|
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;
|
sym->second.incl += count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for( uint8_t c=1; c<cssz; c++ )
|
for( uint8_t c=1; c<framesCount; c++ )
|
||||||
{
|
|
||||||
const auto fincl = GetCallstackFrame( cs[c] );
|
|
||||||
if( fincl )
|
|
||||||
{
|
{
|
||||||
|
const auto fincl = frames[c];
|
||||||
const auto fsz = fincl->size;
|
const auto fsz = fincl->size;
|
||||||
for( uint8_t f=0; f<fsz; f++ )
|
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;
|
sym->second.incl += count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -227,6 +227,7 @@ private:
|
|||||||
unordered_flat_map<uint64_t, SymbolStats> symbolStats;
|
unordered_flat_map<uint64_t, SymbolStats> symbolStats;
|
||||||
|
|
||||||
#ifndef TRACY_NO_STATISTICS
|
#ifndef TRACY_NO_STATISTICS
|
||||||
|
unordered_flat_map<uint32_t, uint32_t> postponedSamples;
|
||||||
bool callstackSamplesReady = false;
|
bool callstackSamplesReady = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -638,7 +639,8 @@ private:
|
|||||||
|
|
||||||
#ifndef TRACY_NO_STATISTICS
|
#ifndef TRACY_NO_STATISTICS
|
||||||
void ReconstructContextSwitchUsage();
|
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
|
#endif
|
||||||
|
|
||||||
tracy_force_inline int64_t ReadTimeline( FileRead& f, ZoneEvent* zone, int64_t refTime, int32_t& childIdx );
|
tracy_force_inline int64_t ReadTimeline( FileRead& f, ZoneEvent* zone, int64_t refTime, int32_t& childIdx );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user