Merge callstack samples with the same timestamp.

This commit is contained in:
Bartosz Taudul 2021-11-27 15:29:10 +01:00
parent 4f735e1ae2
commit 355a179678
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -6270,22 +6270,38 @@ void Worker::ProcessCallstack()
void Worker::ProcessCallstackSampleImpl( const SampleData& sd, ThreadData& td ) void Worker::ProcessCallstackSampleImpl( const SampleData& sd, ThreadData& td )
{ {
const auto t = sd.time.Val(); const auto t = sd.time.Val();
const auto callstack = sd.callstack.Val();
m_data.samplesCnt++;
const auto& cs = GetCallstack( callstack );
const auto& ip = cs[0];
if( GetCanonicalPointer( ip ) >> 63 != 0 ) td.kernelSampleCnt++;
if( td.samples.empty() ) if( td.samples.empty() )
{ {
td.samples.push_back( sd ); td.samples.push_back( sd );
} }
else else if( td.samples.back().time.Val() >= t )
{
m_inconsistentSamples = true;
auto it = std::lower_bound( td.samples.begin(), td.samples.end(), t, []( const auto& lhs, const auto& rhs ) { return lhs.time.Val() < rhs; } );
assert( it != td.samples.end() );
if( it->time.Val() != t )
{ {
if( !m_inconsistentSamples && td.samples.back().time.Val() >= t ) m_inconsistentSamples = true;
td.samples.push_back_non_empty( sd ); td.samples.push_back_non_empty( sd );
} }
else
{
const auto mcs = MergeCallstacks( it->callstack.Val(), sd.callstack.Val() );
it->callstack.SetVal( mcs );
// This is a fixup of an already processed sample. Fixing stats is non-trivial, so just exit here.
return;
}
}
else
{
td.samples.push_back_non_empty( sd );
}
const auto callstack = sd.callstack.Val();
const auto& cs = GetCallstack( callstack );
const auto& ip = cs[0];
if( GetCanonicalPointer( ip ) >> 63 != 0 ) td.kernelSampleCnt++;
m_data.samplesCnt++;
#ifndef TRACY_NO_STATISTICS #ifndef TRACY_NO_STATISTICS
bool postpone = false; bool postpone = false;