Collect parent call stacks for symbols.

This commit is contained in:
Bartosz Taudul 2020-02-29 16:41:22 +01:00
parent 90f5ae536c
commit 4843a1d458
2 changed files with 21 additions and 12 deletions

View File

@ -668,6 +668,7 @@ struct Parameter
struct SymbolStats struct SymbolStats
{ {
uint32_t incl, excl; uint32_t incl, excl;
unordered_flat_map<uint32_t, uint32_t> parents;
}; };
enum { SymbolStatsSize = sizeof( SymbolStats ) }; enum { SymbolStatsSize = sizeof( SymbolStats ) };

View File

@ -5334,19 +5334,17 @@ void Worker::UpdateSampleStatisticsImpl( const CallstackFrameData** frames, uint
{ {
const auto fexcl = frames[0]; const auto fexcl = frames[0];
const auto fxsz = fexcl->size; const auto fxsz = fexcl->size;
{
const auto& frame0 = fexcl->data[0]; const auto& frame0 = fexcl->data[0];
auto sym = m_data.symbolStats.find( frame0.symAddr ); auto sym0 = m_data.symbolStats.find( frame0.symAddr );
if( sym == m_data.symbolStats.end() ) sym = m_data.symbolStats.emplace( frame0.symAddr, SymbolStats {} ).first; if( sym0 == m_data.symbolStats.end() ) sym0 = m_data.symbolStats.emplace( frame0.symAddr, SymbolStats { 0, 0, unordered_flat_map<uint32_t, uint32_t>() } ).first;
sym->second.excl += count; sym0->second.excl += count;
for( uint8_t f=1; f<fxsz; f++ ) for( uint8_t f=1; f<fxsz; f++ )
{ {
const auto& frame = fexcl->data[f]; const auto& frame = fexcl->data[f];
sym = m_data.symbolStats.find( frame.symAddr ); auto sym = m_data.symbolStats.find( frame.symAddr );
if( sym == m_data.symbolStats.end() ) sym = m_data.symbolStats.emplace( frame.symAddr, SymbolStats {} ).first; if( sym == m_data.symbolStats.end() ) sym = m_data.symbolStats.emplace( frame.symAddr, SymbolStats { 0, 0, unordered_flat_map<uint32_t, uint32_t>() } ).first;
sym->second.incl += count; sym->second.incl += count;
} }
}
for( uint8_t c=1; c<framesCount; c++ ) for( uint8_t c=1; c<framesCount; c++ )
{ {
const auto fincl = frames[c]; const auto fincl = frames[c];
@ -5355,7 +5353,7 @@ void Worker::UpdateSampleStatisticsImpl( const CallstackFrameData** frames, uint
{ {
const auto& frame = fincl->data[f]; const auto& frame = fincl->data[f];
auto sym = m_data.symbolStats.find( frame.symAddr ); auto sym = m_data.symbolStats.find( frame.symAddr );
if( sym == m_data.symbolStats.end() ) sym = m_data.symbolStats.emplace( frame.symAddr, SymbolStats {} ).first; if( sym == m_data.symbolStats.end() ) sym = m_data.symbolStats.emplace( frame.symAddr, SymbolStats { 0, 0, unordered_flat_map<uint32_t, uint32_t>() } ).first;
sym->second.incl += count; sym->second.incl += count;
} }
} }
@ -5431,6 +5429,16 @@ void Worker::UpdateSampleStatisticsImpl( const CallstackFrameData** frames, uint
idx = it->second; idx = it->second;
m_slab.Unalloc( memsize ); m_slab.Unalloc( memsize );
} }
auto sit = sym0->second.parents.find( idx );
if( sit == sym0->second.parents.end() )
{
sym0->second.parents.emplace( idx, 1 );
}
else
{
sit->second++;
}
} }
#endif #endif