mirror of
https://github.com/wolfpld/tracy
synced 2025-04-29 12:23:53 +00:00
Cache samples statistics in the "find zone" window
This commit is contained in:
parent
ed42c2388c
commit
0089c832f7
@ -10862,6 +10862,7 @@ void View::DrawFindZone()
|
|||||||
threadZones->reserve( 1024 );
|
threadZones->reserve( 1024 );
|
||||||
}
|
}
|
||||||
threadZones->push_back_non_empty(ev.Zone());
|
threadZones->push_back_non_empty(ev.Zone());
|
||||||
|
m_findZone.samplesCache.scheduleUpdate = true;
|
||||||
}
|
}
|
||||||
m_findZone.processed = zptr - zones.data();
|
m_findZone.processed = zptr - zones.data();
|
||||||
|
|
||||||
@ -11099,50 +11100,75 @@ void View::DrawFindZone()
|
|||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::Checkbox( ICON_FA_HAT_WIZARD " Include kernel", &m_statShowKernel );
|
if( ImGui::Checkbox( ICON_FA_HAT_WIZARD " Include kernel", &m_statShowKernel ))
|
||||||
|
{
|
||||||
|
m_findZone.samplesCache.scheduleUpdate = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& t: m_findZone.threads) {
|
if (m_findZone.samplesCache.scheduleUpdate && !m_findZone.scheduleResetMatch) {
|
||||||
pdqsort_branchless( t.second.begin(), t.second.end(), []( const auto& lhs, const auto& rhs ) { return (*lhs).Start() < (*rhs).Start(); } );
|
m_findZone.samplesCache.scheduleUpdate = false;
|
||||||
}
|
|
||||||
|
|
||||||
const auto& symMap = m_worker.GetSymbolMap();
|
m_findZone.samplesCache.timeRange = 0;
|
||||||
Vector<SymList> data;
|
for (auto& t: m_findZone.samplesCache.threads) {
|
||||||
data.reserve( symMap.size() );
|
pdqsort_branchless( t.second.begin(), t.second.end(), []( const auto& lhs, const auto& rhs ) { return (*lhs).Start() < (*rhs).Start(); } );
|
||||||
for( auto& v : symMap )
|
int64_t prevEnd = 0;
|
||||||
{
|
for (const auto& it : t.second)
|
||||||
bool pass = ( m_statShowKernel || ( v.first >> 63 ) == 0 );
|
|
||||||
if( !pass && v.second.size.Val() == 0 )
|
|
||||||
{
|
|
||||||
const auto parentAddr = m_worker.GetSymbolForAddress( v.first );
|
|
||||||
if( parentAddr != 0 )
|
|
||||||
{
|
{
|
||||||
auto pit = symMap.find( parentAddr );
|
int64_t start = (*it).Start();
|
||||||
if( pit != symMap.end() )
|
int64_t end = (*it).End();
|
||||||
{
|
if (start < prevEnd) start = prevEnd;
|
||||||
pass = ( m_statShowKernel || ( parentAddr >> 63 ) == 0 );
|
if (start < end) {
|
||||||
|
prevEnd = end;
|
||||||
|
m_findZone.samplesCache.timeRange += end - start;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!pass) continue;
|
|
||||||
|
|
||||||
auto samples = m_worker.GetSamplesForSymbol( v.first );
|
const auto& symMap = m_worker.GetSymbolMap();
|
||||||
if( !samples ) continue;
|
m_findZone.samplesCache.counts.clear();
|
||||||
|
m_findZone.samplesCache.counts.reserve( symMap.size() );
|
||||||
|
|
||||||
uint32_t count = 0;
|
for( auto& v : symMap )
|
||||||
for (auto it: *samples) {
|
{
|
||||||
const auto time = it.time.Val();
|
bool pass = ( m_statShowKernel || ( v.first >> 63 ) == 0 );
|
||||||
const auto& zones = m_findZone.threads[it.thread];
|
if( !pass && v.second.size.Val() == 0 )
|
||||||
auto z = std::lower_bound( zones.begin(), zones.end(), time, [] ( const auto& l, const auto& r ) { return l->Start() < r; } );
|
{
|
||||||
if( z == zones.end() ) continue;
|
const auto parentAddr = m_worker.GetSymbolForAddress( v.first );
|
||||||
if (z != zones.begin()) --z;
|
if( parentAddr != 0 )
|
||||||
if (time >= (*z)->Start() && time < (*z)->End())
|
{
|
||||||
count++;
|
auto pit = symMap.find( parentAddr );
|
||||||
|
if( pit != symMap.end() )
|
||||||
|
{
|
||||||
|
pass = ( m_statShowKernel || ( parentAddr >> 63 ) == 0 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!pass) continue;
|
||||||
|
|
||||||
|
auto samples = m_worker.GetSamplesForSymbol( v.first );
|
||||||
|
if( !samples ) continue;
|
||||||
|
|
||||||
|
uint32_t count = 0;
|
||||||
|
for (auto it: *samples) {
|
||||||
|
const auto time = it.time.Val();
|
||||||
|
const auto& zones = m_findZone.samplesCache.threads[it.thread];
|
||||||
|
auto z = std::lower_bound( zones.begin(), zones.end(), time, [] ( const auto& l, const auto& r ) { return l->Start() < r; } );
|
||||||
|
if( z == zones.end() ) continue;
|
||||||
|
if (z != zones.begin()) --z;
|
||||||
|
if (time >= (*z)->Start() && time < (*z)->End())
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
if (count > 0)
|
||||||
|
m_findZone.samplesCache.counts.push_back_no_space_check( SymList { v.first, 0, count } );
|
||||||
}
|
}
|
||||||
if (count > 0)
|
|
||||||
data.push_back_no_space_check( SymList { v.first, 0, count } );
|
|
||||||
}
|
}
|
||||||
DrawSamplesStatistics(data, m_worker.GetLastTime(), AccumulationMode::SelfOnly);
|
|
||||||
|
Vector<SymList> data;
|
||||||
|
data.reserve(m_findZone.samplesCache.counts.size());
|
||||||
|
for (auto it: m_findZone.samplesCache.counts) data.push_back_no_space_check(it);
|
||||||
|
DrawSamplesStatistics(data, m_findZone.samplesCache.timeRange, AccumulationMode::SelfOnly);
|
||||||
|
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -523,7 +523,6 @@ private:
|
|||||||
bool ignoreCase = false;
|
bool ignoreCase = false;
|
||||||
std::vector<int16_t> match;
|
std::vector<int16_t> match;
|
||||||
unordered_flat_map<uint64_t, Group> groups;
|
unordered_flat_map<uint64_t, Group> groups;
|
||||||
unordered_flat_map<uint16_t, Vector<short_ptr<ZoneEvent>> > threads;
|
|
||||||
size_t processed;
|
size_t processed;
|
||||||
uint16_t groupId;
|
uint16_t groupId;
|
||||||
int selMatch = 0;
|
int selMatch = 0;
|
||||||
@ -563,6 +562,13 @@ private:
|
|||||||
ptrdiff_t distEnd;
|
ptrdiff_t distEnd;
|
||||||
} binCache;
|
} binCache;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
unordered_flat_map<uint16_t, Vector<short_ptr<ZoneEvent>> > threads;
|
||||||
|
Vector<SymList> counts;
|
||||||
|
int64_t timeRange = 0;
|
||||||
|
bool scheduleUpdate = false;
|
||||||
|
} samplesCache;
|
||||||
|
|
||||||
void Reset()
|
void Reset()
|
||||||
{
|
{
|
||||||
ResetMatch();
|
ResetMatch();
|
||||||
@ -588,7 +594,8 @@ private:
|
|||||||
{
|
{
|
||||||
ResetSelection();
|
ResetSelection();
|
||||||
groups.clear();
|
groups.clear();
|
||||||
threads.clear();
|
samplesCache.threads.clear();
|
||||||
|
samplesCache.counts.clear();
|
||||||
processed = 0;
|
processed = 0;
|
||||||
groupId = 0;
|
groupId = 0;
|
||||||
selCs = 0;
|
selCs = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user