Collect child sample addresses.

This commit is contained in:
Bartosz Taudul 2021-11-27 02:03:59 +01:00
parent 2462e6cc7c
commit a02575322f
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
4 changed files with 23 additions and 10 deletions

View File

@ -619,6 +619,15 @@ struct GhostZone
enum { GhostZoneSize = sizeof( GhostZone ) };
struct ChildSample
{
Int48 time;
uint64_t addr;
};
enum { ChildSampleSize = sizeof( ChildSample ) };
#pragma pack()

View File

@ -4507,9 +4507,9 @@ void SourceView::GatherAdditionalIpStats( uint64_t baseAddr, AddrStatData& as, c
if( as.ipCountAsm.find( ip ) != as.ipCountAsm.end() ) continue;
auto cp = worker.GetChildSamples( ip );
if( !cp ) continue;
auto it = std::lower_bound( cp->begin(), cp->end(), view.m_statRange.min, [] ( const auto& lhs, const auto& rhs ) { return lhs.Val() < rhs; } );
auto it = std::lower_bound( cp->begin(), cp->end(), view.m_statRange.min, [] ( const auto& lhs, const auto& rhs ) { return lhs.time.Val() < rhs; } );
if( it == cp->end() ) continue;
auto end = std::lower_bound( it, cp->end(), view.m_statRange.max, [] ( const auto& lhs, const auto& rhs ) { return lhs.Val() < rhs; } );
auto end = std::lower_bound( it, cp->end(), view.m_statRange.max, [] ( const auto& lhs, const auto& rhs ) { return lhs.time.Val() < rhs; } );
const auto ccnt = uint64_t( end - it );
as.ipCountAsm.emplace( ip, AddrStat { 0, ccnt } );
as.ipTotalAsm.ext += ccnt;

View File

@ -2067,18 +2067,20 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks )
it->second.push_back_non_empty( SampleDataRange { time, tid, ip } );
}
}
auto childAddr = GetCanonicalPointer( callstack[0] );
for( uint16_t i=1; i<callstack.size(); i++ )
{
auto addr = GetCanonicalPointer( callstack[i] );
auto it = m_data.childSamples.find( addr );
if( it == m_data.childSamples.end() )
{
m_data.childSamples.emplace( addr, Vector<Int48>( time ) );
m_data.childSamples.emplace( addr, Vector<ChildSample>( ChildSample { time, childAddr } ) );
}
else
{
it->second.push_back_non_empty( time );
it->second.push_back_non_empty( ChildSample { time, childAddr } );
}
childAddr = addr;
}
}
}
@ -2088,7 +2090,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks )
}
for( auto& v : m_data.childSamples )
{
pdqsort_branchless( v.second.begin(), v.second.end(), []( const auto& lhs, const auto& rhs ) { return lhs.Val() < rhs.Val(); } );
pdqsort_branchless( v.second.begin(), v.second.end(), []( const auto& lhs, const auto& rhs ) { return lhs.time.Val() < rhs.time.Val(); } );
}
std::lock_guard<std::mutex> lock( m_data.lock );
m_data.symbolSamplesReady = true;
@ -2501,7 +2503,7 @@ const Vector<SampleDataRange>* Worker::GetSamplesForSymbol( uint64_t symAddr ) c
return &it->second;
}
const Vector<Int48>* Worker::GetChildSamples( uint64_t addr ) const
const Vector<ChildSample>* Worker::GetChildSamples( uint64_t addr ) const
{
assert( m_data.symbolSamplesReady );
auto it = m_data.childSamples.find( addr );
@ -6353,18 +6355,20 @@ void Worker::ProcessCallstackSampleImplStats( const SampleData& sd, ThreadData&
}
}
auto childAddr = GetCanonicalPointer( cs[0] );
for( uint16_t i=1; i<cs.size(); i++ )
{
auto addr = GetCanonicalPointer( cs[i] );
auto it = m_data.childSamples.find( addr );
if( it == m_data.childSamples.end() )
{
m_data.childSamples.emplace( addr, Vector<Int48>( sd.time ) );
m_data.childSamples.emplace( addr, Vector<ChildSample>( ChildSample { sd.time, childAddr } ) );
}
else
{
it->second.push_back_non_empty( sd.time );
it->second.push_back_non_empty( ChildSample { sd.time, childAddr } );
}
childAddr = addr;
}
const auto framesKnown = UpdateSampleStatistics( callstack, 1, true );

View File

@ -301,7 +301,7 @@ private:
unordered_flat_map<uint64_t, unordered_flat_map<CallstackFrameId, uint32_t, CallstackFrameIdHash, CallstackFrameIdCompare>> instructionPointersMap;
unordered_flat_map<uint64_t, Vector<SampleDataRange>> symbolSamples;
unordered_flat_map<CallstackFrameId, Vector<SampleDataRange>, CallstackFrameIdHash, CallstackFrameIdCompare> pendingSymbolSamples;
unordered_flat_map<uint64_t, Vector<Int48>> childSamples;
unordered_flat_map<uint64_t, Vector<ChildSample>> childSamples;
bool newFramesWereReceived = false;
bool callstackSamplesReady = false;
bool newContextSwitchesReceived = false;
@ -523,7 +523,7 @@ public:
const VarArray<CallstackFrameId>& GetParentCallstack( uint32_t idx ) const { return *m_data.parentCallstackPayload[idx]; }
const CallstackFrameData* GetParentCallstackFrame( const CallstackFrameId& ptr ) const;
const Vector<SampleDataRange>* GetSamplesForSymbol( uint64_t symAddr ) const;
const Vector<Int48>* GetChildSamples( uint64_t addr ) const;
const Vector<ChildSample>* GetChildSamples( uint64_t addr ) const;
#endif
const CrashEvent& GetCrashEvent() const { return m_data.crashEvent; }