diff --git a/profiler/src/main.cpp b/profiler/src/main.cpp index 0b27109a..2c07a995 100644 --- a/profiler/src/main.cpp +++ b/profiler/src/main.cpp @@ -626,6 +626,9 @@ int main( int argc, char** argv ) case tracy::LoadProgress::ContextSwitches: ImGui::TextUnformatted( "Context switches..." ); break; + case tracy::LoadProgress::ContextSwitchesPerCpu: + ImGui::TextUnformatted( "CPU context switches..." ); + break; default: assert( false ); break; diff --git a/server/TracyVersion.hpp b/server/TracyVersion.hpp index fd4ff7b7..b8671501 100644 --- a/server/TracyVersion.hpp +++ b/server/TracyVersion.hpp @@ -7,7 +7,7 @@ namespace Version { enum { Major = 0 }; enum { Minor = 5 }; -enum { Patch = 2 }; +enum { Patch = 3 }; } } diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index b8870817..c8472c53 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -307,10 +307,14 @@ Worker::Worker( FileRead& f, EventType::Type eventMask ) { s_loadProgress.total.store( 9, std::memory_order_relaxed ); } - else + else if( fileVer <= FileVersion( 0, 5, 2 ) ) { s_loadProgress.total.store( 10, std::memory_order_relaxed ); } + else + { + s_loadProgress.total.store( 11, std::memory_order_relaxed ); + } s_loadProgress.subTotal.store( 0, std::memory_order_relaxed ); s_loadProgress.progress.store( LoadProgress::Initialization, std::memory_order_relaxed ); @@ -1429,6 +1433,44 @@ Worker::Worker( FileRead& f, EventType::Type eventMask ) } } + if( fileVer >= FileVersion( 0, 5, 3 ) ) + { + s_loadProgress.subTotal.store( 0, std::memory_order_relaxed ); + s_loadProgress.progress.store( LoadProgress::ContextSwitchesPerCpu, std::memory_order_relaxed ); + f.Read( sz ); + s_loadProgress.subTotal.store( sz, std::memory_order_relaxed ); + if( eventMask & EventType::ContextSwitches ) + { + uint64_t cnt = 0; + for( int i=0; i<256; i++ ) + { + int64_t refTime = 0; + f.Read( sz ); + m_data.cpuData[i].cs.reserve_exact( sz, m_slab ); + auto ptr = m_data.cpuData[i].cs.data(); + for( uint64_t j=0; jSetStart( ReadTimeOffset( f, refTime ) ); + ptr->SetEnd( ReadTimeOffset( f, refTime ) ); + uint64_t thread; + f.Read( thread ); + ptr->SetThread( thread ); + ptr++; + } + cnt += sz; + s_loadProgress.subProgress.store( cnt, std::memory_order_relaxed ); + } + } + else + { + for( int i=0; i<256; i++ ) + { + f.Read( sz ); + f.Skip( sizeof( uint64_t ) * 3 * sz ); + } + } + } + s_loadProgress.total.store( 0, std::memory_order_relaxed ); m_loadTime = std::chrono::duration_cast( std::chrono::high_resolution_clock::now() - loadStart ).count(); @@ -4826,6 +4868,24 @@ void Worker::Write( FileWrite& f ) f.Write( &state, sizeof( state ) ); } } + + sz = GetContextSwitchPerCpuCount(); + f.Write( &sz, sizeof( sz ) ); + for( int i=0; i<256; i++ ) + { + sz = m_data.cpuData[i].cs.size(); + f.Write( &sz, sizeof( sz ) ); + int64_t refTime = 0; + for( auto& cx : m_data.cpuData[i].cs ) + { + WriteTimeOffset( f, refTime, cx.Start() ); + WriteTimeOffset( f, refTime, cx.End() ); + uint64_t thread = cx.Thread(); + // Don't care about external thread identifiers + if( m_data.threadMap.find( thread ) == m_data.threadMap.end() ) thread = 0; + f.Write( &thread, sizeof( thread ) ); + } + } } void Worker::WriteTimeline( FileWrite& f, const Vector& vec, int64_t& refTime ) diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index fa8b1cc7..46f0429b 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -67,7 +67,8 @@ struct LoadProgress Memory, CallStacks, FrameImages, - ContextSwitches + ContextSwitches, + ContextSwitchesPerCpu }; LoadProgress() : total( 0 ), progress( 0 ), subTotal( 0 ), subProgress( 0 ) {}