Merge pull request #257 from xxxbxxx/filter-by-srcloc

Filter samples by zones source locations
This commit is contained in:
Bartosz Taudul 2021-09-23 22:12:42 +02:00 committed by GitHub
commit b6eee83463
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 581 additions and 393 deletions

View File

@ -268,6 +268,7 @@ enum { SampleDataSize = sizeof( SampleData ) };
struct SampleDataRange
{
Int48 time;
uint16_t thread;
CallstackFrameId ip;
};

File diff suppressed because it is too large Load Diff

View File

@ -153,6 +153,13 @@ private:
bool highlight;
};
struct SymList
{
uint64_t symAddr;
uint32_t incl, excl;
uint32_t count;
};
void InitMemory();
void InitTextEditor( ImFont* font );
@ -196,6 +203,7 @@ private:
void DrawFindZone();
void AccumulationModeComboBox();
void DrawStatistics();
void DrawSamplesStatistics(Vector<SymList>& data, int64_t timeRange, AccumulationMode accumulationMode);
void DrawMemory();
void DrawAllocList();
void DrawCompare();
@ -508,6 +516,7 @@ private:
{
uint16_t id;
Vector<short_ptr<ZoneEvent>> zones;
Vector<uint16_t> zonesTids;
int64_t time = 0;
};
@ -554,6 +563,12 @@ private:
ptrdiff_t distEnd;
} binCache;
struct {
Vector<SymList> counts;
bool scheduleUpdate = false;
bool enabled = false;
} samples;
void Reset()
{
ResetMatch();
@ -561,6 +576,7 @@ private:
selMatch = 0;
selGroup = Unselected;
highlight.active = false;
samples.counts.clear();
}
void ResetMatch()
@ -595,6 +611,7 @@ private:
selTotal = 0;
selTime = 0;
binCache.numBins = -1;
samples.scheduleUpdate = true;
}
void ShowZone( int16_t srcloc, const char* name )

View File

@ -1931,6 +1931,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks )
jobs.emplace_back( std::thread( [this] {
for( auto& t : m_data.threads )
{
uint16_t tid = CompressThread( t->id );
for( auto& v : t->samples )
{
const auto& time = v.time;
@ -1944,11 +1945,11 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks )
auto it = m_data.symbolSamples.find( symAddr );
if( it == m_data.symbolSamples.end() )
{
m_data.symbolSamples.emplace( symAddr, Vector<SampleDataRange>( SampleDataRange { time, ip } ) );
m_data.symbolSamples.emplace( symAddr, Vector<SampleDataRange>( SampleDataRange { time, tid, ip } ) );
}
else
{
it->second.push_back_non_empty( SampleDataRange { time, ip } );
it->second.push_back_non_empty( SampleDataRange { time, tid, ip } );
}
}
for( uint16_t i=1; i<callstack.size(); i++ )
@ -5970,6 +5971,8 @@ void Worker::ProcessCallstackSampleImpl( const SampleData& sd, ThreadData& td, i
#ifndef TRACY_NO_STATISTICS
{
uint16_t tid = CompressThread( td.id );
auto frame = GetCallstackFrame( ip );
if( frame )
{
@ -5994,18 +5997,18 @@ void Worker::ProcessCallstackSampleImpl( const SampleData& sd, ThreadData& td, i
auto sit = m_data.symbolSamples.find( symAddr );
if( sit == m_data.symbolSamples.end() )
{
m_data.symbolSamples.emplace( symAddr, Vector<SampleDataRange>( SampleDataRange { sd.time, ip } ) );
m_data.symbolSamples.emplace( symAddr, Vector<SampleDataRange>( SampleDataRange { sd.time, tid, ip } ) );
}
else
{
if( sit->second.back().time.Val() <= sd.time.Val() )
{
sit->second.push_back_non_empty( SampleDataRange { sd.time, ip } );
sit->second.push_back_non_empty( SampleDataRange { sd.time, tid, ip } );
}
else
{
auto iit = std::upper_bound( sit->second.begin(), sit->second.end(), sd.time.Val(), [] ( const auto& lhs, const auto& rhs ) { return lhs < rhs.time.Val(); } );
sit->second.insert( iit, SampleDataRange { sd.time, ip } );
sit->second.insert( iit, SampleDataRange { sd.time, tid, ip } );
}
}
}
@ -6023,11 +6026,11 @@ void Worker::ProcessCallstackSampleImpl( const SampleData& sd, ThreadData& td, i
auto sit = m_data.pendingSymbolSamples.find( ip );
if( sit == m_data.pendingSymbolSamples.end() )
{
m_data.pendingSymbolSamples.emplace( ip, Vector<SampleDataRange>( SampleDataRange { sd.time, ip } ) );
m_data.pendingSymbolSamples.emplace( ip, Vector<SampleDataRange>( SampleDataRange { sd.time, tid, ip } ) );
}
else
{
sit->second.push_back_non_empty( SampleDataRange { sd.time, ip } );
sit->second.push_back_non_empty( SampleDataRange { sd.time, tid, ip } );
}
}
}