From 1b824797a96345301a127a313766c1715b36e090 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 7 Apr 2023 22:10:18 +0200 Subject: [PATCH] Do not project running regions end time to last time. Just display known running regions, keeping the unended ones infinitely collapsed. This makes the CPU core usage graph possibly display wrong data at the end of capture. Note that this behavior was also present in previous releases. --- server/TracyTimelineItemCpuData.cpp | 10 +++++----- server/TracyTimelineItemThread.cpp | 8 ++++---- server/TracyView_ContextSwitch.cpp | 4 ++-- server/TracyView_CpuData.cpp | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/server/TracyTimelineItemCpuData.cpp b/server/TracyTimelineItemCpuData.cpp index b06c2f6c..619e8ba6 100644 --- a/server/TracyTimelineItemCpuData.cpp +++ b/server/TracyTimelineItemCpuData.cpp @@ -109,7 +109,7 @@ void TimelineItemCpuData::PreprocessCpuCtxSwitches( const TimelineContext& ctx, const auto vEnd = ctx.vEnd; const auto nspx = ctx.nspx; - auto it = std::lower_bound( cs.begin(), cs.end(), std::max( 0, vStart ), [this] ( const auto& l, const auto& r ) { return ( l.IsEndValid() ? l.End() : m_worker.GetLastTime() ) < r; } ); + auto it = std::lower_bound( cs.begin(), cs.end(), std::max( 0, vStart ), [] ( const auto& l, const auto& r ) { return ( l.IsEndValid() ? l.End() : l.Start() ) < r; } ); if( it == cs.end() ) return; auto eit = std::lower_bound( it, cs.end(), vEnd, [] ( const auto& l, const auto& r ) { return l.Start() < r; } ); if( it == eit ) return; @@ -118,7 +118,7 @@ void TimelineItemCpuData::PreprocessCpuCtxSwitches( const TimelineContext& ctx, while( it < eit ) { - const auto end = it->IsEndValid() ? it->End() : m_worker.GetLastTime(); + const auto end = it->IsEndValid() ? it->End() : it->Start(); const auto zsz = end - it->Start(); if( zsz < MinVisNs ) { @@ -126,11 +126,11 @@ void TimelineItemCpuData::PreprocessCpuCtxSwitches( const TimelineContext& ctx, auto next = it + 1; for(;;) { - next = std::lower_bound( next, eit, nextTime, [this] ( const auto& l, const auto& r ) { return ( l.IsEndValid() ? l.End() : m_worker.GetLastTime() ) < r; } ); + next = std::lower_bound( next, eit, nextTime, [] ( const auto& l, const auto& r ) { return ( l.IsEndValid() ? l.End() : l.Start() ) < r; } ); if( next == eit ) break; auto prev = next - 1; - const auto pt = prev->IsEndValid() ? prev->End() : m_worker.GetLastTime(); - const auto nt = next->IsEndValid() ? next->End() : m_worker.GetLastTime(); + const auto pt = prev->IsEndValid() ? prev->End() : prev->Start(); + const auto nt = next->IsEndValid() ? next->End() : next->Start(); if( nt - pt >= MinVisNs ) break; nextTime = nt + MinVisNs; } diff --git a/server/TracyTimelineItemThread.cpp b/server/TracyTimelineItemThread.cpp index 0ae0c934..96853523 100644 --- a/server/TracyTimelineItemThread.cpp +++ b/server/TracyTimelineItemThread.cpp @@ -507,7 +507,7 @@ void TimelineItemThread::PreprocessContextSwitches( const TimelineContext& ctx, m_ctxDraw.emplace_back( ContextSwitchDraw { ContextSwitchDrawType::Waiting, uint32_t( it - vec.begin() ), waitStack } ); } - const auto end = ev.IsEndValid() ? ev.End() : m_worker.GetLastTime(); + const auto end = ev.IsEndValid() ? ev.End() : ev.Start(); const auto zsz = end - ev.Start(); if( zsz < MinCtxNs ) { @@ -515,11 +515,11 @@ void TimelineItemThread::PreprocessContextSwitches( const TimelineContext& ctx, auto next = it + 1; for(;;) { - next = std::lower_bound( next, citend, nextTime, [this] ( const auto& l, const auto& r ) { return ( l.IsEndValid() ? l.End() : m_worker.GetLastTime() ) < r; } ); + next = std::lower_bound( next, citend, nextTime, [] ( const auto& l, const auto& r ) { return ( l.IsEndValid() ? l.End() : l.Start() ) < r; } ); if( next == citend ) break; auto prev = next - 1; - const auto pt = prev->IsEndValid() ? prev->End() : m_worker.GetLastTime(); - const auto nt = next->IsEndValid() ? next->End() : m_worker.GetLastTime(); + const auto pt = prev->IsEndValid() ? prev->End() : prev->Start(); + const auto nt = next->IsEndValid() ? next->End() : next->Start(); if( nt - pt >= MinCtxNs ) break; nextTime = nt + MinCtxNs; } diff --git a/server/TracyView_ContextSwitch.cpp b/server/TracyView_ContextSwitch.cpp index b43769ef..a0aa6d4e 100644 --- a/server/TracyView_ContextSwitch.cpp +++ b/server/TracyView_ContextSwitch.cpp @@ -260,7 +260,7 @@ void View::DrawContextSwitchList( const TimelineContext& ctx, const std::vector< const auto num = v.data; const auto px0 = std::max( ( ev.Start() - vStart ) * pxns, -10.0 ); const auto eit = it + num - 1; - const auto end = eit->IsEndValid() ? eit->End() : m_worker.GetLastTime(); + const auto end = eit->IsEndValid() ? eit->End() : eit->Start(); const auto px1ns = end - vStart; minpx = std::min( std::max( px1ns * pxns, px0+MinCtxSize ), double( w + 10 ) ); if( num == 1 ) @@ -313,7 +313,7 @@ void View::DrawContextSwitchList( const TimelineContext& ctx, const std::vector< } case ContextSwitchDrawType::Running: { - const auto end = ev.IsEndValid() ? ev.End() : m_worker.GetLastTime(); + const auto end = ev.IsEndValid() ? ev.End() : ev.Start(); const auto px0 = std::max( { ( ev.Start() - vStart ) * pxns, -10.0, double( minpx ) } ); const auto px1 = std::min( ( end - vStart ) * pxns, w + 10.0 ); DrawLine( draw, dpos + ImVec2( px0, offset + ty05 - 0.5f ), dpos + ImVec2( px1, offset + ty05 - 0.5f ), 0xFF22DD22, lineSize ); diff --git a/server/TracyView_CpuData.cpp b/server/TracyView_CpuData.cpp index 1808fe5a..bd388e1b 100644 --- a/server/TracyView_CpuData.cpp +++ b/server/TracyView_CpuData.cpp @@ -160,7 +160,7 @@ bool View::DrawCpuData( const TimelineContext& ctx, const std::vector 0 ) { const auto& eev = cs[v.idx + v.num - 1]; - const auto t1 = eev.IsEndValid() ? eev.End() : m_worker.GetLastTime(); + const auto t1 = eev.IsEndValid() ? eev.End() : eev.Start(); const auto px1 = ( t1 - vStart ) * pxns; DrawZigZag( draw, wpos + ImVec2( 0, offset + sty/2 ), std::max( px0, -10.0 ), std::min( std::max( px1, px0+MinVisSize ), double( w + 10 ) ), sty/4, 0xFF888888 ); @@ -194,7 +194,7 @@ bool View::DrawCpuData( const TimelineContext& ctx, const std::vector