diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 2291cf40..049d4fad 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -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 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; diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index 9c170858..c2a1d431 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -224,6 +224,11 @@ private: #else std::pair srclocCntLast = std::make_pair( std::numeric_limits::max(), nullptr ); #endif + +#ifndef TRACY_NO_STATISTICS + Vector ctxUsage; + bool ctxUsageReady = false; +#endif }; struct MbpsBlock @@ -373,6 +378,7 @@ public: const SourceLocationZones& GetZonesForSourceLocation( int16_t srcloc ) const; const flat_hash_map>& 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>& 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 );