Detect context switch samples during reconstruction.

This commit is contained in:
Bartosz Taudul 2021-11-13 03:15:20 +01:00
parent 484ed84252
commit 0ab73e2aa7
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -1953,7 +1953,25 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks )
for( auto& t : m_data.threads ) for( auto& t : m_data.threads )
{ {
if( m_shutdown.load( std::memory_order_relaxed ) ) return; if( m_shutdown.load( std::memory_order_relaxed ) ) return;
auto ctx = GetContextSwitchData( t->id );
Vector<ContextSwitchData>::const_iterator cit = nullptr;
if( ctx ) cit = ctx->v.begin();
for( auto& sd : t->samples ) for( auto& sd : t->samples )
{
bool isCtxSwitch = false;
if( ctx )
{
cit = std::lower_bound( cit, ctx->v.end(), sd.time.Val(), [] ( const auto& l, const auto& r ) { return (uint64_t)l.End() < (uint64_t)r; } );
if( cit != ctx->v.end() )
{
if( sd.time.Val() == cit->Start() )
{
isCtxSwitch = true;
t->ctxSwitchSamples.push_back( sd );
}
}
}
if( !isCtxSwitch )
{ {
const auto cs = sd.callstack.Val(); const auto cs = sd.callstack.Val();
auto it = counts.find( cs ); auto it = counts.find( cs );
@ -1992,6 +2010,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks )
} }
} }
} }
}
for( auto& v : counts ) UpdateSampleStatistics( v.first, v.second, false ); for( auto& v : counts ) UpdateSampleStatistics( v.first, v.second, false );
} }
std::lock_guard<std::mutex> lock( m_data.lock ); std::lock_guard<std::mutex> lock( m_data.lock );