From f8edd3a37b1070b1ccbfe166ae7e70abf07bdcf1 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 9 Nov 2019 23:39:28 +0100 Subject: [PATCH] Zone statistics reconstructions has to use magic vectors. --- server/TracyWorker.cpp | 27 ++++++++++++++++----------- server/TracyWorker.hpp | 2 +- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index d8da0cde..5ca602d7 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -1728,15 +1728,17 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks ) #ifndef TRACY_NO_STATISTICS m_threadBackground = std::thread( [this, reconstructMemAllocPlot] { std::function>&, uint16_t)> ProcessTimeline; - ProcessTimeline = [this, &ProcessTimeline] ( Vector>& vec, uint16_t thread ) + ProcessTimeline = [this, &ProcessTimeline] ( Vector>& _vec, uint16_t thread ) { if( m_shutdown.load( std::memory_order_relaxed ) ) return; + assert( _vec.is_magic() ); + auto& vec = *(Vector*)( &_vec ); for( auto& zone : vec ) { ReconstructZoneStatistics( zone, thread ); - if( zone->Child() >= 0 ) + if( zone.Child() >= 0 ) { - ProcessTimeline( GetZoneChildrenMutable( zone->Child() ), thread ); + ProcessTimeline( GetZoneChildrenMutable( zone.Child() ), thread ); } } }; @@ -5072,29 +5074,32 @@ void Worker::ReadTimelinePre0510( FileRead& f, GpuEvent* zone, int64_t& refTime, } #ifndef TRACY_NO_STATISTICS -void Worker::ReconstructZoneStatistics( ZoneEvent* zone, uint16_t thread ) +void Worker::ReconstructZoneStatistics( ZoneEvent& zone, uint16_t thread ) { - auto it = m_data.sourceLocationZones.find( zone->SrcLoc() ); + auto it = m_data.sourceLocationZones.find( zone.SrcLoc() ); assert( it != m_data.sourceLocationZones.end() ); auto& slz = it->second; auto& ztd = slz.zones.push_next(); - ztd.SetZone( zone ); + ztd.SetZone( &zone ); ztd.SetThread( thread ); - if( zone->End() >= 0 ) + if( zone.End() >= 0 ) { - auto timeSpan = zone->End() - zone->Start(); + auto timeSpan = zone.End() - zone.Start(); if( timeSpan > 0 ) { if( slz.min > timeSpan ) slz.min = timeSpan; if( slz.max < timeSpan ) slz.max = timeSpan; slz.total += timeSpan; slz.sumSq += double( timeSpan ) * timeSpan; - if( zone->Child() >= 0 ) + if( zone.Child() >= 0 ) { - for( auto& v : GetZoneChildren( zone->Child() ) ) + auto& children = GetZoneChildren( zone.Child() ); + assert( children.is_magic() ); + auto& c = *(Vector*)( &children ); + for( auto& v : c ) { - const auto childSpan = std::max( int64_t( 0 ), v->End() - v->Start() ); + const auto childSpan = std::max( int64_t( 0 ), v.End() - v.Start() ); timeSpan -= childSpan; } } diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index 74b3d069..3c193a7c 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -578,7 +578,7 @@ private: tracy_force_inline void ReadTimelinePre0510( FileRead& f, GpuEvent* zone, int64_t& refTime, int64_t& refGpuTime, int fileVer ); #ifndef TRACY_NO_STATISTICS - tracy_force_inline void ReconstructZoneStatistics( ZoneEvent* zone, uint16_t thread ); + tracy_force_inline void ReconstructZoneStatistics( ZoneEvent& zone, uint16_t thread ); #else tracy_force_inline void CountZoneStatistics( ZoneEvent* zone ); #endif