From 82790f904fd500e79beabed075d340075faafc87 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Wed, 9 Sep 2026 01:52:09 +0200 Subject: [PATCH] Save context switches of all threads. Per-thread lists were dropped for threads without zones or samples, a rule from when only profiled threads consumed them; the CPU data graph uses them for any visible thread, so saved traces silently lost wake and wait data. --- server/TracyWorker.cpp | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index d075a3cb..fd11c512 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -8777,26 +8777,15 @@ void Worker::Write( FileWrite& f, bool fiDict ) } } - // Only save context switches relevant to active threads. - std::vector::const_iterator> ctxValid; - ctxValid.reserve( m_data.ctxSwitch.size() ); - for( auto it = m_data.ctxSwitch.begin(); it != m_data.ctxSwitch.end(); ++it ) - { - auto td = RetrieveThread( it->first, m_data.threadDataLast ); - if( td && ( td->count > 0 || !td->samples.empty() ) ) - { - ctxValid.emplace_back( it ); - } - } - sz = ctxValid.size(); + sz = m_data.ctxSwitch.size(); f.Write( &sz, sizeof( sz ) ); - for( auto& ctx : ctxValid ) + for( auto& ctx : m_data.ctxSwitch ) { - f.Write( &ctx->first, sizeof( ctx->first ) ); - sz = ctx->second->v.size(); + f.Write( &ctx.first, sizeof( ctx.first ) ); + sz = ctx.second->v.size(); f.Write( &sz, sizeof( sz ) ); int64_t refTime = 0; - for( auto& cs : ctx->second->v ) + for( auto& cs : ctx.second->v ) { WriteTimeOffset( f, refTime, cs.WakeupVal() ); WriteTimeOffset( f, refTime, cs.Start() );