Don't add ghost zones if full callstack data isn't available.

This commit is contained in:
Bartosz Taudul 2020-05-31 14:17:54 +02:00
parent de5f8df9d3
commit 1154343a20
3 changed files with 83 additions and 70 deletions

View File

@ -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;
}; };

View File

@ -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,6 +5605,13 @@ void Worker::ProcessCallstackSample( const QueueCallstackSampleLean& ev )
} }
} }
} }
const auto framesKnown = UpdateSampleStatistics( m_pendingCallstackId, 1, true );
assert( td->samples.size() > td->ghostIdx );
if( framesKnown && td->ghostIdx + 1 == td->samples.size() )
{
td->ghostIdx++;
int gcnt = 0; int gcnt = 0;
int idx = cs.size() - 1; int idx = cs.size() - 1;
auto vec = &td->ghostZones; auto vec = &td->ghostZones;
@ -5689,8 +5697,11 @@ void Worker::ProcessCallstackSample( const QueueCallstackSampleLean& ev )
} }
while( idx-- > 0 ); while( idx-- > 0 );
m_data.ghostCnt += gcnt; m_data.ghostCnt += gcnt;
}
UpdateSampleStatistics( m_pendingCallstackId, 1, true ); else
{
m_data.ghostZonesPostponed = true;
}
#endif #endif
} }

View File

@ -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;