Context switch usage reconstruction skeleton.

This commit is contained in:
Bartosz Taudul 2019-11-05 00:40:41 +01:00
parent a62c4135ad
commit 50b96c757e
2 changed files with 21 additions and 0 deletions

View File

@ -259,6 +259,7 @@ Worker::Worker( const char* addr, int port )
#ifndef TRACY_NO_STATISTICS
m_data.sourceLocationZonesReady = true;
m_data.ctxUsageReady = true;
#endif
m_thread = std::thread( [this] { SetThreadName( "Tracy Worker" ); Exec(); } );
@ -1787,6 +1788,8 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks )
m_data.sourceLocationZonesReady = true;
}
if( m_shutdown.load( std::memory_order_relaxed ) ) return;
if( !m_data.ctxSwitch.empty() ) ReconstructContextSwitchUsage();
if( m_shutdown.load( std::memory_order_relaxed ) ) return;
if( reconstructMemAllocPlot ) ReconstructMemAllocPlot();
m_backgroundDone.store( true, std::memory_order_relaxed );
} );
@ -4862,6 +4865,14 @@ void Worker::ReconstructMemAllocPlot()
m_data.memory.plot = plot;
}
#ifndef TRACY_NO_STATISTICS
void Worker::ReconstructContextSwitchUsage()
{
std::lock_guard<std::shared_mutex> lock( m_data.lock );
m_data.ctxUsageReady = true;
}
#endif
void Worker::ReadTimeline( FileRead& f, ZoneEvent* zone, uint16_t thread, int64_t& refTime, int32_t& childIdx )
{
uint64_t sz;

View File

@ -224,6 +224,11 @@ private:
#else
std::pair<uint16_t, uint64_t*> srclocCntLast = std::make_pair( std::numeric_limits<uint16_t>::max(), nullptr );
#endif
#ifndef TRACY_NO_STATISTICS
Vector<ContextSwitchUsage> ctxUsage;
bool ctxUsageReady = false;
#endif
};
struct MbpsBlock
@ -373,6 +378,7 @@ public:
const SourceLocationZones& GetZonesForSourceLocation( int16_t srcloc ) const;
const flat_hash_map<int16_t, SourceLocationZones, nohash<int16_t>>& GetSourceLocationZones() const { return m_data.sourceLocationZones; }
bool AreSourceLocationZonesReady() const { return m_data.sourceLocationZonesReady; }
bool IsCpuUsageReady() const { return m_data.ctxUsageReady; }
#endif
tracy_force_inline uint16_t CompressThread( uint64_t thread ) { return m_data.localThreadCompress.CompressThread( thread ); }
@ -555,6 +561,10 @@ private:
tracy_force_inline Vector<short_ptr<ZoneEvent>>& GetZoneChildrenMutable( int32_t idx ) { return m_data.zoneChildren[idx]; }
#ifndef TRACY_NO_STATISTICS
void ReconstructContextSwitchUsage();
#endif
tracy_force_inline void ReadTimeline( FileRead& f, ZoneEvent* zone, uint16_t thread, int64_t& refTime, int32_t& childIdx );
tracy_force_inline void ReadTimelinePre042( FileRead& f, ZoneEvent* zone, uint16_t thread, int fileVer );
tracy_force_inline void ReadTimelinePre0510( FileRead& f, ZoneEvent* zone, uint16_t thread, int64_t& refTime, int fileVer );