mirror of
https://github.com/wolfpld/tracy
synced 2025-04-30 20:53:52 +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
|
#ifndef TRACY_NO_STATISTICS
|
||||||
Vector<int64_t> childTimeStack;
|
Vector<int64_t> childTimeStack;
|
||||||
Vector<GhostZone> ghostZones;
|
Vector<GhostZone> ghostZones;
|
||||||
|
uint64_t ghostIdx;
|
||||||
#endif
|
#endif
|
||||||
Vector<SampleData> samples;
|
Vector<SampleData> samples;
|
||||||
};
|
};
|
||||||
|
@ -3522,6 +3522,7 @@ ThreadData* Worker::NewThread( uint64_t thread )
|
|||||||
td->id = thread;
|
td->id = thread;
|
||||||
td->count = 0;
|
td->count = 0;
|
||||||
td->nextZoneId = 0;
|
td->nextZoneId = 0;
|
||||||
|
td->ghostIdx = 0;
|
||||||
m_data.threads.push_back( td );
|
m_data.threads.push_back( td );
|
||||||
m_threadMap.emplace( thread, td );
|
m_threadMap.emplace( thread, td );
|
||||||
m_data.threadDataLast.first = thread;
|
m_data.threadDataLast.first = thread;
|
||||||
@ -5604,93 +5605,103 @@ void Worker::ProcessCallstackSample( const QueueCallstackSampleLean& ev )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int gcnt = 0;
|
|
||||||
int idx = cs.size() - 1;
|
const auto framesKnown = UpdateSampleStatistics( m_pendingCallstackId, 1, true );
|
||||||
auto vec = &td->ghostZones;
|
|
||||||
do
|
assert( td->samples.size() > td->ghostIdx );
|
||||||
|
if( framesKnown && td->ghostIdx + 1 == td->samples.size() )
|
||||||
{
|
{
|
||||||
auto& entry = cs[idx];
|
td->ghostIdx++;
|
||||||
uint32_t fid;
|
int gcnt = 0;
|
||||||
auto it = m_data.ghostFramesMap.find( entry.data );
|
int idx = cs.size() - 1;
|
||||||
if( it == m_data.ghostFramesMap.end() )
|
auto vec = &td->ghostZones;
|
||||||
|
do
|
||||||
{
|
{
|
||||||
fid = uint32_t( m_data.ghostFrames.size() );
|
auto& entry = cs[idx];
|
||||||
m_data.ghostFrames.push_back( entry );
|
uint32_t fid;
|
||||||
m_data.ghostFramesMap.emplace( entry.data, fid );
|
auto it = m_data.ghostFramesMap.find( entry.data );
|
||||||
}
|
if( it == m_data.ghostFramesMap.end() )
|
||||||
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 )
|
|
||||||
{
|
{
|
||||||
match = backFrame->size == thisFrame->size;
|
fid = uint32_t( m_data.ghostFrames.size() );
|
||||||
if( match )
|
m_data.ghostFrames.push_back( entry );
|
||||||
{
|
m_data.ghostFramesMap.emplace( entry.data, fid );
|
||||||
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
|
else
|
||||||
|
{
|
||||||
|
fid = it->second;
|
||||||
|
}
|
||||||
|
if( vec->empty() )
|
||||||
{
|
{
|
||||||
gcnt++;
|
gcnt++;
|
||||||
auto ptr = &back;
|
auto& zone = vec->push_next();
|
||||||
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.start.SetVal( t );
|
||||||
zone.end.SetVal( t + m_samplingPeriod );
|
zone.end.SetVal( t + m_samplingPeriod );
|
||||||
zone.frame.SetVal( fid );
|
zone.frame.SetVal( fid );
|
||||||
zone.child = -1;
|
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
|
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,6 +253,7 @@ private:
|
|||||||
bool newFramesWereReceived = false;
|
bool newFramesWereReceived = false;
|
||||||
bool callstackSamplesReady = false;
|
bool callstackSamplesReady = false;
|
||||||
bool ghostZonesReady = false;
|
bool ghostZonesReady = false;
|
||||||
|
bool ghostZonesPostponed = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
unordered_flat_map<uint32_t, LockMap*> lockMap;
|
unordered_flat_map<uint32_t, LockMap*> lockMap;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user