From 48e4d33bea1afd31dc1943719db6c7ff182f92f4 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 28 Mar 2020 18:04:33 +0100 Subject: [PATCH] Support call stacks longer than 255 entries. --- server/TracyVarArray.hpp | 6 ++--- server/TracyVersion.hpp | 2 +- server/TracyView.cpp | 16 ++++++------- server/TracyView.hpp | 2 +- server/TracyWorker.cpp | 52 ++++++++++++++++++++++++++++------------ server/TracyWorker.hpp | 2 +- 6 files changed, 51 insertions(+), 29 deletions(-) diff --git a/server/TracyVarArray.hpp b/server/TracyVarArray.hpp index 5fa54f5e..fb0b6f20 100644 --- a/server/TracyVarArray.hpp +++ b/server/TracyVarArray.hpp @@ -23,7 +23,7 @@ template class VarArray { public: - VarArray( uint8_t size, const T* data ) + VarArray( uint16_t size, const T* data ) : m_size( size ) , m_ptr( data ) { @@ -39,7 +39,7 @@ public: tracy_force_inline uint32_t get_hash() const { return m_hash; } tracy_force_inline bool empty() const { return m_size == 0; } - tracy_force_inline uint8_t size() const { return m_size; } + tracy_force_inline uint16_t size() const { return m_size; } tracy_force_inline const T* data() const { return m_ptr; }; @@ -54,7 +54,7 @@ public: private: tracy_force_inline void CalcHash(); - uint8_t m_size; + uint16_t m_size; uint32_t m_hash; const short_ptr m_ptr; }; diff --git a/server/TracyVersion.hpp b/server/TracyVersion.hpp index e578e09c..d2e9b40d 100644 --- a/server/TracyVersion.hpp +++ b/server/TracyVersion.hpp @@ -7,7 +7,7 @@ namespace Version { enum { Major = 0 }; enum { Minor = 6 }; -enum { Patch = 7 }; +enum { Patch = 8 }; } } diff --git a/server/TracyView.cpp b/server/TracyView.cpp index d59e897e..b08dc9e6 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -5959,8 +5959,8 @@ void DrawZoneTrace( T zone, const std::vector& trace, const Worker& worker, B auto& prevCs = worker.GetCallstack( pcv ); auto& currCs = worker.GetCallstack( ccv ); - const auto psz = int8_t( prevCs.size() ); - int8_t idx; + const auto psz = int( prevCs.size() ); + int idx; for( idx=0; idx& trace, const Worker& worker, B } if( found ) break; } - for( int8_t j=1; jdata + frameData->size - 1; @@ -6034,7 +6034,7 @@ void DrawZoneTrace( T zone, const std::vector& trace, const Worker& worker, B { auto& cs = worker.GetCallstack( lcv ); const auto csz = cs.size(); - for( uint8_t i=1; idata + frameData->size - 1; @@ -14083,7 +14083,7 @@ unordered_flat_map View::GetCallstackFrameTreeTopD treePtr->alloc += path.second.mem; treePtr->callstacks.emplace( path.first ); - for( int i = 1; i < cs.size(); i++ ) + for( uint16_t i = 1; i < cs.size(); i++ ) { treePtr = GetFrameTreeItemGroup( treePtr->children, cs[i], m_worker ); if( !treePtr ) break; @@ -14106,7 +14106,7 @@ unordered_flat_map View::GetCallstackFrameTreeTopD treePtr->alloc += path.second.mem; treePtr->callstacks.emplace( path.first ); - for( int i = 1; i < cs.size(); i++ ) + for( uint16_t i = 1; i < cs.size(); i++ ) { treePtr = GetFrameTreeItemNoGroup( treePtr->children, cs[i], m_worker ); treePtr->count += path.second.cnt; @@ -15597,12 +15597,12 @@ void View::SmallCallstackButton( const char* name, uint32_t callstack, int& idx, } } -void View::DrawCallstackCalls( uint32_t callstack, uint8_t limit ) const +void View::DrawCallstackCalls( uint32_t callstack, uint16_t limit ) const { const auto& csdata = m_worker.GetCallstack( callstack ); const auto cssz = std::min( csdata.size(), limit ); bool first = true; - for( uint8_t i=0; i= FileVersion( 0, 6, 8 ) ) { - uint8_t csz; - f.Read( csz ); + for( uint64_t i=0; i ) + csz * sizeof( CallstackFrameId ); - auto mem = (char*)m_slab.AllocRaw( memsize ); + const auto memsize = sizeof( VarArray ) + csz * sizeof( CallstackFrameId ); + auto mem = (char*)m_slab.AllocRaw( memsize ); - auto data = (CallstackFrameId*)mem; - f.Read( data, csz * sizeof( CallstackFrameId ) ); + auto data = (CallstackFrameId*)mem; + f.Read( data, csz * sizeof( CallstackFrameId ) ); - auto arr = (VarArray*)( mem + csz * sizeof( CallstackFrameId ) ); - new(arr) VarArray( csz, data ); + auto arr = (VarArray*)( mem + csz * sizeof( CallstackFrameId ) ); + new(arr) VarArray( csz, data ); - m_data.callstackPayload.push_back_no_space_check( arr ); + m_data.callstackPayload.push_back_no_space_check( arr ); + } + } + else + { + for( uint64_t i=0; i ) + csz * sizeof( CallstackFrameId ); + auto mem = (char*)m_slab.AllocRaw( memsize ); + + auto data = (CallstackFrameId*)mem; + f.Read( data, csz * sizeof( CallstackFrameId ) ); + + auto arr = (VarArray*)( mem + csz * sizeof( CallstackFrameId ) ); + new(arr) VarArray( csz, data ); + + m_data.callstackPayload.push_back_no_space_check( arr ); + } } if( fileVer >= FileVersion( 0, 6, 5 ) ) @@ -5720,7 +5742,7 @@ void Worker::UpdateSampleStatistics( uint32_t callstack, uint32_t count, bool ca const auto cssz = cs.size(); auto frames = (const CallstackFrameData**)alloca( cssz * sizeof( CallstackFrameData* ) ); - for( uint8_t i=0; i& cs ) +void Worker::UpdateSampleStatisticsImpl( const CallstackFrameData** frames, uint16_t framesCount, uint32_t count, const VarArray& cs ) { const auto fexcl = frames[0]; const auto fxsz = fexcl->size; @@ -5794,7 +5816,7 @@ void Worker::UpdateSampleStatisticsImpl( const CallstackFrameData** frames, uint if( sym == m_data.symbolStats.end() ) sym = m_data.symbolStats.emplace( frame.symAddr, SymbolStats { 0, 0, unordered_flat_map() } ).first; sym->second.incl += count; } - for( uint8_t c=1; csize; @@ -6591,7 +6613,7 @@ void Worker::Write( FileWrite& f ) for( size_t i=1; i<=sz; i++ ) { auto cs = m_data.callstackPayload[i]; - uint8_t csz = cs->size(); + uint16_t csz = cs->size(); f.Write( &csz, sizeof( csz ) ); f.Write( cs->data(), sizeof( CallstackFrameId ) * csz ); } diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index bf402d52..9cd7317b 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -697,7 +697,7 @@ private: void ReconstructContextSwitchUsage(); void UpdateSampleStatistics( uint32_t callstack, uint32_t count, bool canPostpone ); void UpdateSampleStatisticsPostponed( decltype(Worker::DataBlock::postponedSamples.begin())& it ); - void UpdateSampleStatisticsImpl( const CallstackFrameData** frames, uint8_t framesCount, uint32_t count, const VarArray& cs ); + void UpdateSampleStatisticsImpl( const CallstackFrameData** frames, uint16_t framesCount, uint32_t count, const VarArray& cs ); #endif tracy_force_inline int64_t ReadTimeline( FileRead& f, ZoneEvent* zone, int64_t refTime, int32_t& childIdx );