mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-23 06:44:35 +00:00
Add cache for last accessed source location zones.
This commit is contained in:
parent
b5419944aa
commit
1d0084aa28
@ -2605,7 +2605,9 @@ int16_t Worker::NewShrinkedSourceLocation( uint64_t srcloc )
|
|||||||
const auto sz = int16_t( m_data.sourceLocationExpand.size() );
|
const auto sz = int16_t( m_data.sourceLocationExpand.size() );
|
||||||
m_data.sourceLocationExpand.push_back( srcloc );
|
m_data.sourceLocationExpand.push_back( srcloc );
|
||||||
#ifndef TRACY_NO_STATISTICS
|
#ifndef TRACY_NO_STATISTICS
|
||||||
m_data.sourceLocationZones.emplace( sz, SourceLocationZones() );
|
auto res = m_data.sourceLocationZones.emplace( sz, SourceLocationZones() );
|
||||||
|
m_data.srclocZonesLast.first = sz;
|
||||||
|
m_data.srclocZonesLast.second = &res.first->second;
|
||||||
#else
|
#else
|
||||||
m_data.sourceLocationZonesCnt.emplace( sz, 0 );
|
m_data.sourceLocationZonesCnt.emplace( sz, 0 );
|
||||||
#endif
|
#endif
|
||||||
@ -2677,6 +2679,17 @@ ThreadData* Worker::RetrieveThreadReal( uint64_t thread )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef TRACY_NO_STATISTICS
|
||||||
|
Worker::SourceLocationZones* Worker::GetSourceLocationZonesReal( uint16_t srcloc )
|
||||||
|
{
|
||||||
|
auto it = m_data.sourceLocationZones.find( srcloc );
|
||||||
|
assert( it != m_data.sourceLocationZones.end() );
|
||||||
|
m_data.srclocZonesLast.first = srcloc;
|
||||||
|
m_data.srclocZonesLast.second = &it->second;
|
||||||
|
return &it->second;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
const ThreadData* Worker::GetThreadData( uint64_t tid ) const
|
const ThreadData* Worker::GetThreadData( uint64_t tid ) const
|
||||||
{
|
{
|
||||||
auto it = m_threadMap.find( tid );
|
auto it = m_threadMap.find( tid );
|
||||||
@ -2703,9 +2716,8 @@ void Worker::NewZone( ZoneEvent* zone, uint64_t thread )
|
|||||||
m_data.zonesCnt++;
|
m_data.zonesCnt++;
|
||||||
|
|
||||||
#ifndef TRACY_NO_STATISTICS
|
#ifndef TRACY_NO_STATISTICS
|
||||||
auto it = m_data.sourceLocationZones.find( zone->SrcLoc() );
|
auto slz = GetSourceLocationZones( zone->SrcLoc() );
|
||||||
assert( it != m_data.sourceLocationZones.end() );
|
auto& ztd = slz->zones.push_next();
|
||||||
auto& ztd = it->second.zones.push_next();
|
|
||||||
ztd.SetZone( zone );
|
ztd.SetZone( zone );
|
||||||
ztd.SetThread( CompressThread( thread ) );
|
ztd.SetThread( CompressThread( thread ) );
|
||||||
#else
|
#else
|
||||||
@ -2876,7 +2888,11 @@ void Worker::AddSourceLocationPayload( uint64_t ptr, char* data, size_t sz )
|
|||||||
m_pendingSourceLocationPayload.emplace( ptr, -int16_t( idx + 1 ) );
|
m_pendingSourceLocationPayload.emplace( ptr, -int16_t( idx + 1 ) );
|
||||||
m_data.sourceLocationPayload.push_back( slptr );
|
m_data.sourceLocationPayload.push_back( slptr );
|
||||||
#ifndef TRACY_NO_STATISTICS
|
#ifndef TRACY_NO_STATISTICS
|
||||||
m_data.sourceLocationZones.emplace( -int16_t( idx + 1 ), SourceLocationZones() );
|
const auto key = -int16_t( idx + 1 );
|
||||||
|
auto res = m_data.sourceLocationZones.emplace( key, SourceLocationZones() );
|
||||||
|
m_data.srclocZonesLast.first = key;
|
||||||
|
m_data.srclocZonesLast.second = &res.first->second;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
m_data.sourceLocationZonesCnt.emplace( -int16_t( idx + 1 ), 0 );
|
m_data.sourceLocationZonesCnt.emplace( -int16_t( idx + 1 ), 0 );
|
||||||
#endif
|
#endif
|
||||||
@ -3500,17 +3516,15 @@ void Worker::ProcessZoneEnd( const QueueZoneEnd& ev )
|
|||||||
const auto timeSpan = timeEnd - zone->Start();
|
const auto timeSpan = timeEnd - zone->Start();
|
||||||
if( timeSpan > 0 )
|
if( timeSpan > 0 )
|
||||||
{
|
{
|
||||||
auto it = m_data.sourceLocationZones.find( zone->SrcLoc() );
|
auto slz = GetSourceLocationZones( zone->SrcLoc() );
|
||||||
assert( it != m_data.sourceLocationZones.end() );
|
if( slz->min > timeSpan ) slz->min = timeSpan;
|
||||||
auto& slz = it->second;
|
if( slz->max < timeSpan ) slz->max = timeSpan;
|
||||||
slz.min = std::min( slz.min, timeSpan );
|
slz->total += timeSpan;
|
||||||
slz.max = std::max( slz.max, timeSpan );
|
slz->sumSq += double( timeSpan ) * timeSpan;
|
||||||
slz.total += timeSpan;
|
|
||||||
slz.sumSq += double( timeSpan ) * timeSpan;
|
|
||||||
const auto selfSpan = timeSpan - td->childTimeStack.back_and_pop();
|
const auto selfSpan = timeSpan - td->childTimeStack.back_and_pop();
|
||||||
slz.selfMin = std::min( slz.selfMin, selfSpan );
|
if( slz->selfMin > selfSpan ) slz->selfMin = selfSpan;
|
||||||
slz.selfMax = std::max( slz.selfMax, selfSpan );
|
if( slz->selfMax < selfSpan ) slz->selfMax = selfSpan;
|
||||||
slz.selfTotal += selfSpan;
|
slz->selfTotal += selfSpan;
|
||||||
if( !td->childTimeStack.empty() )
|
if( !td->childTimeStack.empty() )
|
||||||
{
|
{
|
||||||
td->childTimeStack.back() += timeSpan;
|
td->childTimeStack.back() += timeSpan;
|
||||||
|
@ -216,6 +216,9 @@ private:
|
|||||||
std::pair<uint64_t, ContextSwitch*> ctxSwitchLast = std::make_pair( std::numeric_limits<uint64_t>::max(), nullptr );
|
std::pair<uint64_t, ContextSwitch*> ctxSwitchLast = std::make_pair( std::numeric_limits<uint64_t>::max(), nullptr );
|
||||||
uint64_t checkSrclocLast = 0;
|
uint64_t checkSrclocLast = 0;
|
||||||
std::pair<uint64_t, uint16_t> shrinkSrclocLast = std::make_pair( std::numeric_limits<uint64_t>::max(), 0 );
|
std::pair<uint64_t, uint16_t> shrinkSrclocLast = std::make_pair( std::numeric_limits<uint64_t>::max(), 0 );
|
||||||
|
#ifndef TRACY_NO_STATISTICS
|
||||||
|
std::pair<uint16_t, SourceLocationZones*> srclocZonesLast = std::make_pair( std::numeric_limits<uint16_t>::max(), nullptr );
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MbpsBlock
|
struct MbpsBlock
|
||||||
@ -498,6 +501,15 @@ private:
|
|||||||
return RetrieveThreadReal( thread );
|
return RetrieveThreadReal( thread );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef TRACY_NO_STATISTICS
|
||||||
|
SourceLocationZones* GetSourceLocationZones( uint16_t srcloc )
|
||||||
|
{
|
||||||
|
if( m_data.srclocZonesLast.first == srcloc ) return m_data.srclocZonesLast.second;
|
||||||
|
return GetSourceLocationZonesReal( srcloc );
|
||||||
|
}
|
||||||
|
SourceLocationZones* GetSourceLocationZonesReal( uint16_t srcloc );
|
||||||
|
#endif
|
||||||
|
|
||||||
tracy_force_inline void NewZone( ZoneEvent* zone, uint64_t thread );
|
tracy_force_inline void NewZone( ZoneEvent* zone, uint64_t thread );
|
||||||
|
|
||||||
void InsertLockEvent( LockMap& lockmap, LockEvent* lev, uint64_t thread, int64_t time );
|
void InsertLockEvent( LockMap& lockmap, LockEvent* lev, uint64_t thread, int64_t time );
|
||||||
|
Loading…
Reference in New Issue
Block a user