mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Don't add ghost zones if full callstack data isn't available.
This commit is contained in:
parent
de5f8df9d3
commit
1154343a20
@ -553,6 +553,7 @@ struct ThreadData
|
||||
#ifndef TRACY_NO_STATISTICS
|
||||
Vector<int64_t> childTimeStack;
|
||||
Vector<GhostZone> ghostZones;
|
||||
uint64_t ghostIdx;
|
||||
#endif
|
||||
Vector<SampleData> samples;
|
||||
};
|
||||
|
@ -3522,6 +3522,7 @@ ThreadData* Worker::NewThread( uint64_t thread )
|
||||
td->id = thread;
|
||||
td->count = 0;
|
||||
td->nextZoneId = 0;
|
||||
td->ghostIdx = 0;
|
||||
m_data.threads.push_back( td );
|
||||
m_threadMap.emplace( thread, td );
|
||||
m_data.threadDataLast.first = thread;
|
||||
@ -5604,93 +5605,103 @@ void Worker::ProcessCallstackSample( const QueueCallstackSampleLean& ev )
|
||||
}
|
||||
}
|
||||
}
|
||||
int gcnt = 0;
|
||||
int idx = cs.size() - 1;
|
||||
auto vec = &td->ghostZones;
|
||||
do
|
||||
|
||||
const auto framesKnown = UpdateSampleStatistics( m_pendingCallstackId, 1, true );
|
||||
|
||||
assert( td->samples.size() > td->ghostIdx );
|
||||
if( framesKnown && td->ghostIdx + 1 == td->samples.size() )
|
||||
{
|
||||
auto& entry = cs[idx];
|
||||
uint32_t fid;
|
||||
auto it = m_data.ghostFramesMap.find( entry.data );
|
||||
if( it == m_data.ghostFramesMap.end() )
|
||||
td->ghostIdx++;
|
||||
int gcnt = 0;
|
||||
int idx = cs.size() - 1;
|
||||
auto vec = &td->ghostZones;
|
||||
do
|
||||
{
|
||||
fid = uint32_t( m_data.ghostFrames.size() );
|
||||
m_data.ghostFrames.push_back( entry );
|
||||
m_data.ghostFramesMap.emplace( entry.data, fid );
|
||||
}
|
||||
else
|
||||
{
|
||||
fid = it->second;
|
||||
}
|
||||
if( vec->empty() )
|
||||
{
|
||||
gcnt++;
|
||||
auto& zone = vec->push_next();
|
||||
zone.start.SetVal( t );
|
||||
zone.end.SetVal( t + m_samplingPeriod );
|
||||
zone.frame.SetVal( fid );
|
||||
zone.child = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto& back = vec->back();
|
||||
const auto backFrame = GetCallstackFrame( m_data.ghostFrames[back.frame.Val()] );
|
||||
const auto thisFrame = GetCallstackFrame( entry );
|
||||
bool match = false;
|
||||
if( backFrame && thisFrame )
|
||||
auto& entry = cs[idx];
|
||||
uint32_t fid;
|
||||
auto it = m_data.ghostFramesMap.find( entry.data );
|
||||
if( it == m_data.ghostFramesMap.end() )
|
||||
{
|
||||
match = backFrame->size == thisFrame->size;
|
||||
if( match )
|
||||
{
|
||||
for( uint8_t i=0; i<thisFrame->size; i++ )
|
||||
{
|
||||
if( backFrame->data[i].symAddr != thisFrame->data[i].symAddr )
|
||||
{
|
||||
match = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if( match )
|
||||
{
|
||||
back.end.SetVal( t + m_samplingPeriod );
|
||||
fid = uint32_t( m_data.ghostFrames.size() );
|
||||
m_data.ghostFrames.push_back( entry );
|
||||
m_data.ghostFramesMap.emplace( entry.data, fid );
|
||||
}
|
||||
else
|
||||
{
|
||||
fid = it->second;
|
||||
}
|
||||
if( vec->empty() )
|
||||
{
|
||||
gcnt++;
|
||||
auto ptr = &back;
|
||||
for(;;)
|
||||
{
|
||||
ptr->end.SetVal( t );
|
||||
if( ptr->child < 0 ) break;
|
||||
ptr = &GetGhostChildrenMutable( ptr->child ).back();
|
||||
}
|
||||
auto& zone = vec->push_next_non_empty();
|
||||
auto& zone = vec->push_next();
|
||||
zone.start.SetVal( t );
|
||||
zone.end.SetVal( t + m_samplingPeriod );
|
||||
zone.frame.SetVal( fid );
|
||||
zone.child = -1;
|
||||
}
|
||||
}
|
||||
if( idx > 0 )
|
||||
{
|
||||
auto& zone = vec->back();
|
||||
if( zone.child < 0 )
|
||||
{
|
||||
zone.child = m_data.ghostChildren.size();
|
||||
vec = &m_data.ghostChildren.push_next();
|
||||
}
|
||||
else
|
||||
{
|
||||
vec = &m_data.ghostChildren[zone.child];
|
||||
auto& back = vec->back();
|
||||
const auto backFrame = GetCallstackFrame( m_data.ghostFrames[back.frame.Val()] );
|
||||
const auto thisFrame = GetCallstackFrame( entry );
|
||||
bool match = false;
|
||||
if( backFrame && thisFrame )
|
||||
{
|
||||
match = backFrame->size == thisFrame->size;
|
||||
if( match )
|
||||
{
|
||||
for( uint8_t i=0; i<thisFrame->size; i++ )
|
||||
{
|
||||
if( backFrame->data[i].symAddr != thisFrame->data[i].symAddr )
|
||||
{
|
||||
match = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if( match )
|
||||
{
|
||||
back.end.SetVal( t + m_samplingPeriod );
|
||||
}
|
||||
else
|
||||
{
|
||||
gcnt++;
|
||||
auto ptr = &back;
|
||||
for(;;)
|
||||
{
|
||||
ptr->end.SetVal( t );
|
||||
if( ptr->child < 0 ) break;
|
||||
ptr = &GetGhostChildrenMutable( ptr->child ).back();
|
||||
}
|
||||
auto& zone = vec->push_next_non_empty();
|
||||
zone.start.SetVal( t );
|
||||
zone.end.SetVal( t + m_samplingPeriod );
|
||||
zone.frame.SetVal( fid );
|
||||
zone.child = -1;
|
||||
}
|
||||
}
|
||||
if( idx > 0 )
|
||||
{
|
||||
auto& zone = vec->back();
|
||||
if( zone.child < 0 )
|
||||
{
|
||||
zone.child = m_data.ghostChildren.size();
|
||||
vec = &m_data.ghostChildren.push_next();
|
||||
}
|
||||
else
|
||||
{
|
||||
vec = &m_data.ghostChildren[zone.child];
|
||||
}
|
||||
}
|
||||
}
|
||||
while( idx-- > 0 );
|
||||
m_data.ghostCnt += gcnt;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_data.ghostZonesPostponed = true;
|
||||
}
|
||||
while( idx-- > 0 );
|
||||
m_data.ghostCnt += gcnt;
|
||||
|
||||
UpdateSampleStatistics( m_pendingCallstackId, 1, true );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -253,6 +253,7 @@ private:
|
||||
bool newFramesWereReceived = false;
|
||||
bool callstackSamplesReady = false;
|
||||
bool ghostZonesReady = false;
|
||||
bool ghostZonesPostponed = false;
|
||||
#endif
|
||||
|
||||
unordered_flat_map<uint32_t, LockMap*> lockMap;
|
||||
|
Loading…
Reference in New Issue
Block a user