Also calculate sample parents without inlines.

This commit is contained in:
Bartosz Taudul 2021-11-27 17:47:09 +01:00
parent 687d4defc0
commit d8a611e952
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
2 changed files with 75 additions and 32 deletions

View File

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

View File

@ -7386,55 +7386,97 @@ void Worker::UpdateSampleStatisticsImpl( const CallstackFrameData** frames, uint
} }
} }
const auto sz = framesCount - ( fxsz == 1 ); uint32_t parentIdx;
const auto memsize = sizeof( VarArray<CallstackFrameId> ) + sz * sizeof( CallstackFrameId );
auto mem = (char*)m_slab.AllocRaw( memsize );
auto data = (CallstackFrameId*)mem;
auto dst = data;
if( fxsz == 1 )
{ {
for( int i=0; i<sz; i++ ) const auto sz = framesCount - ( fxsz == 1 );
const auto memsize = sizeof( VarArray<CallstackFrameId> ) + sz * sizeof( CallstackFrameId );
auto mem = (char*)m_slab.AllocRaw( memsize );
auto data = (CallstackFrameId*)mem;
auto dst = data;
if( fxsz == 1 )
{ {
*dst++ = cs[i+1]; for( int i=0; i<sz; i++ )
{
*dst++ = cs[i+1];
}
} }
} else
else
{
*dst++ = parentFrameId;
for( int i=1; i<sz; i++ )
{ {
*dst++ = cs[i]; *dst++ = parentFrameId;
for( int i=1; i<sz; i++ )
{
*dst++ = cs[i];
}
} }
}
auto arr = (VarArray<CallstackFrameId>*)( mem + sz * sizeof( CallstackFrameId ) ); auto arr = (VarArray<CallstackFrameId>*)( mem + sz * sizeof( CallstackFrameId ) );
new(arr) VarArray<CallstackFrameId>( sz, data ); new(arr) VarArray<CallstackFrameId>( sz, data );
uint32_t idx; auto it = m_data.parentCallstackMap.find( arr );
auto it = m_data.parentCallstackMap.find( arr ); if( it == m_data.parentCallstackMap.end() )
if( it == m_data.parentCallstackMap.end() ) {
{ parentIdx = m_data.parentCallstackPayload.size();
idx = m_data.parentCallstackPayload.size(); m_data.parentCallstackMap.emplace( arr, parentIdx );
m_data.parentCallstackMap.emplace( arr, idx ); m_data.parentCallstackPayload.push_back( arr );
m_data.parentCallstackPayload.push_back( arr ); }
} else
else {
{ parentIdx = it->second;
idx = it->second; m_slab.Unalloc( memsize );
m_slab.Unalloc( memsize ); }
} }
sym0 = m_data.symbolStats.find( frame0.symAddr ); sym0 = m_data.symbolStats.find( frame0.symAddr );
auto sit = sym0->second.parents.find( idx ); auto sit = sym0->second.parents.find( parentIdx );
if( sit == sym0->second.parents.end() ) if( sit == sym0->second.parents.end() )
{ {
sym0->second.parents.emplace( idx, count ); sym0->second.parents.emplace( parentIdx, count );
} }
else else
{ {
sit->second += count; sit->second += count;
} }
uint32_t baseParentIdx;
{
const auto sz = framesCount - 1;
const auto memsize = sizeof( VarArray<CallstackFrameId> ) + sz * sizeof( CallstackFrameId );
auto mem = (char*)m_slab.AllocRaw( memsize );
auto data = (CallstackFrameId*)mem;
auto dst = data;
for( int i=0; i<sz; i++ )
{
*dst++ = cs[i+1];
}
auto arr = (VarArray<CallstackFrameId>*)( mem + sz * sizeof( CallstackFrameId ) );
new(arr) VarArray<CallstackFrameId>( sz, data );
auto it = m_data.parentCallstackMap.find( arr );
if( it == m_data.parentCallstackMap.end() )
{
baseParentIdx = m_data.parentCallstackPayload.size();
m_data.parentCallstackMap.emplace( arr, baseParentIdx );
m_data.parentCallstackPayload.push_back( arr );
}
else
{
baseParentIdx = it->second;
m_slab.Unalloc( memsize );
}
}
auto bit = sym0->second.baseParents.find( baseParentIdx );
if( bit == sym0->second.baseParents.end() )
{
sym0->second.baseParents.emplace( baseParentIdx, count );
}
else
{
bit->second += count;
}
} }
#endif #endif