Implement range limit for child samples.

This commit is contained in:
Bartosz Taudul 2021-05-19 20:26:50 +02:00
parent 6d8abfe640
commit efc1777051
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -3569,50 +3569,91 @@ void SourceView::GatherIpStats( uint64_t baseAddr, AddrStat& iptotalSrc, AddrSta
void SourceView::GatherAdditionalIpStats( uint64_t baseAddr, AddrStat& iptotalSrc, AddrStat& iptotalAsm, unordered_flat_map<uint64_t, AddrStat>& ipcountSrc, unordered_flat_map<uint64_t, AddrStat>& ipcountAsm, AddrStat& ipmaxSrc, AddrStat& ipmaxAsm, const Worker& worker, bool limitView, const View& view ) void SourceView::GatherAdditionalIpStats( uint64_t baseAddr, AddrStat& iptotalSrc, AddrStat& iptotalAsm, unordered_flat_map<uint64_t, AddrStat>& ipcountSrc, unordered_flat_map<uint64_t, AddrStat>& ipcountAsm, AddrStat& ipmaxSrc, AddrStat& ipmaxAsm, const Worker& worker, bool limitView, const View& view )
{ {
if( !worker.AreSourceLocationZonesReady() ) return; if( !worker.AreSourceLocationZonesReady() ) return;
auto sym = worker.GetSymbolData( baseAddr );
if( !sym ) return;
auto filename = m_source.filename(); auto filename = m_source.filename();
if( limitView ) if( limitView )
{ {
for( uint64_t ip = baseAddr; ip < baseAddr + sym->size.Val(); ip++ )
{
if( ipcountAsm.find( ip ) != 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; } );
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; } );
const auto ccnt = uint32_t( end - it );
ipcountAsm.emplace( ip, AddrStat { 0, ccnt } );
iptotalAsm.ext += ccnt;
if( ipmaxAsm.ext < ccnt ) ipmaxAsm.ext = ccnt;
if( filename )
{
auto frame = worker.GetCallstackFrame( worker.PackPointer( ip ) );
if( frame )
{
auto ffn = worker.GetString( frame->data[0].file );
if( strcmp( ffn, filename ) == 0 )
{
const auto line = frame->data[0].line;
if( line != 0 )
{
auto it = ipcountSrc.find( line );
if( it == ipcountSrc.end() )
{
ipcountSrc.emplace( line, AddrStat{ 0, ccnt } );
if( ipmaxSrc.ext < ccnt ) ipmaxSrc.ext = ccnt;
}
else
{
const auto csum = it->second.ext + ccnt;
it->second.ext = csum;
if( ipmaxSrc.ext < csum ) ipmaxSrc.ext = csum;
}
iptotalSrc.ext += ccnt;
}
}
}
}
}
} }
else else
{ {
auto sym = worker.GetSymbolData( baseAddr ); for( uint64_t ip = baseAddr; ip < baseAddr + sym->size.Val(); ip++ )
if( sym )
{ {
for( uint64_t ip = baseAddr; ip < baseAddr + sym->size.Val(); ip++ ) if( ipcountAsm.find( ip ) != ipcountAsm.end() ) continue;
{ auto cp = worker.GetChildSamples( ip );
if( ipcountAsm.find( ip ) != ipcountAsm.end() ) continue; if( !cp ) continue;
auto cp = worker.GetChildSamples( ip ); const auto ccnt = (uint32_t)cp->size();
if( !cp ) continue; ipcountAsm.emplace( ip, AddrStat { 0, ccnt } );
const auto ccnt = (uint32_t)cp->size(); iptotalAsm.ext += ccnt;
ipcountAsm.emplace( ip, AddrStat { 0, ccnt } ); if( ipmaxAsm.ext < ccnt ) ipmaxAsm.ext = ccnt;
iptotalAsm.ext += ccnt;
if( ipmaxAsm.ext < ccnt ) ipmaxAsm.ext = ccnt;
if( filename ) if( filename )
{
auto frame = worker.GetCallstackFrame( worker.PackPointer( ip ) );
if( frame )
{ {
auto frame = worker.GetCallstackFrame( worker.PackPointer( ip ) ); auto ffn = worker.GetString( frame->data[0].file );
if( frame ) if( strcmp( ffn, filename ) == 0 )
{ {
auto ffn = worker.GetString( frame->data[0].file ); const auto line = frame->data[0].line;
if( strcmp( ffn, filename ) == 0 ) if( line != 0 )
{ {
const auto line = frame->data[0].line; auto it = ipcountSrc.find( line );
if( line != 0 ) if( it == ipcountSrc.end() )
{ {
auto it = ipcountSrc.find( line ); ipcountSrc.emplace( line, AddrStat{ 0, ccnt } );
if( it == ipcountSrc.end() ) if( ipmaxSrc.ext < ccnt ) ipmaxSrc.ext = ccnt;
{
ipcountSrc.emplace( line, AddrStat{ 0, ccnt } );
if( ipmaxSrc.ext < ccnt ) ipmaxSrc.ext = ccnt;
}
else
{
const auto csum = it->second.ext + ccnt;
it->second.ext = csum;
if( ipmaxSrc.ext < csum ) ipmaxSrc.ext = csum;
}
iptotalSrc.ext += ccnt;
} }
else
{
const auto csum = it->second.ext + ccnt;
it->second.ext = csum;
if( ipmaxSrc.ext < csum ) ipmaxSrc.ext = csum;
}
iptotalSrc.ext += ccnt;
} }
} }
} }