From 1fe76be955f7ba0915f66c89070c4007f803e43a Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Thu, 24 Oct 2019 23:25:04 +0200 Subject: [PATCH] Don't reconstruct lock event time on insert. --- server/TracyWorker.cpp | 39 ++++++++++++++++++++++----------------- server/TracyWorker.hpp | 2 +- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index dde5d7ac..5ae4073e 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -2743,10 +2743,9 @@ void Worker::NewZone( ZoneEvent* zone, uint64_t thread ) td->nextZoneId = 0; } -void Worker::InsertLockEvent( LockMap& lockmap, LockEvent* lev, uint64_t thread ) +void Worker::InsertLockEvent( LockMap& lockmap, LockEvent* lev, uint64_t thread, int64_t time ) { - const auto lt = lev->Time(); - m_data.lastTime = std::max( m_data.lastTime, lt ); + if( m_data.lastTime < time ) m_data.lastTime = time; NoticeThread( thread ); @@ -2773,8 +2772,8 @@ void Worker::InsertLockEvent( LockMap& lockmap, LockEvent* lev, uint64_t thread } auto& range = lockmap.range[it->second]; - if( range.start > lt ) range.start = lt; - if( range.end < lt ) range.end = lt; + if( range.start > time ) range.start = time; + if( range.end < time ) range.end = time; } void Worker::CheckString( uint64_t ptr ) @@ -3803,11 +3802,12 @@ void Worker::ProcessLockWait( const QueueLockWait& ev ) auto lev = ev.type == LockType::Lockable ? m_slab.Alloc() : m_slab.Alloc(); const auto refTime = m_refTimeSerial + ev.time; m_refTimeSerial = refTime; - lev->SetTime( TscTime( refTime - m_data.baseTime ) ); + const auto time = TscTime( refTime - m_data.baseTime ); + lev->SetTime( time ); lev->SetSrcLoc( 0 ); lev->type = LockEvent::Type::Wait; - InsertLockEvent( *it->second, lev, ev.thread ); + InsertLockEvent( *it->second, lev, ev.thread, time ); } void Worker::ProcessLockObtain( const QueueLockObtain& ev ) @@ -3819,11 +3819,12 @@ void Worker::ProcessLockObtain( const QueueLockObtain& ev ) auto lev = lock.type == LockType::Lockable ? m_slab.Alloc() : m_slab.Alloc(); const auto refTime = m_refTimeSerial + ev.time; m_refTimeSerial = refTime; - lev->SetTime( TscTime( refTime - m_data.baseTime ) ); + const auto time = TscTime( refTime - m_data.baseTime ); + lev->SetTime( time ); lev->SetSrcLoc( 0 ); lev->type = LockEvent::Type::Obtain; - InsertLockEvent( lock, lev, ev.thread ); + InsertLockEvent( lock, lev, ev.thread, time ); } void Worker::ProcessLockRelease( const QueueLockRelease& ev ) @@ -3835,11 +3836,12 @@ void Worker::ProcessLockRelease( const QueueLockRelease& ev ) auto lev = lock.type == LockType::Lockable ? m_slab.Alloc() : m_slab.Alloc(); const auto refTime = m_refTimeSerial + ev.time; m_refTimeSerial = refTime; - lev->SetTime( TscTime( refTime - m_data.baseTime ) ); + const auto time = TscTime( refTime - m_data.baseTime ); + lev->SetTime( time ); lev->SetSrcLoc( 0 ); lev->type = LockEvent::Type::Release; - InsertLockEvent( lock, lev, ev.thread ); + InsertLockEvent( lock, lev, ev.thread, time ); } void Worker::ProcessLockSharedWait( const QueueLockWait& ev ) @@ -3858,11 +3860,12 @@ void Worker::ProcessLockSharedWait( const QueueLockWait& ev ) auto lev = m_slab.Alloc(); const auto refTime = m_refTimeSerial + ev.time; m_refTimeSerial = refTime; - lev->SetTime( TscTime( refTime - m_data.baseTime ) ); + const auto time = TscTime( refTime - m_data.baseTime ); + lev->SetTime( time ); lev->SetSrcLoc( 0 ); lev->type = LockEvent::Type::WaitShared; - InsertLockEvent( *it->second, lev, ev.thread ); + InsertLockEvent( *it->second, lev, ev.thread, time ); } void Worker::ProcessLockSharedObtain( const QueueLockObtain& ev ) @@ -3875,11 +3878,12 @@ void Worker::ProcessLockSharedObtain( const QueueLockObtain& ev ) auto lev = m_slab.Alloc(); const auto refTime = m_refTimeSerial + ev.time; m_refTimeSerial = refTime; - lev->SetTime( TscTime( refTime - m_data.baseTime ) ); + const auto time = TscTime( refTime - m_data.baseTime ); + lev->SetTime( time ); lev->SetSrcLoc( 0 ); lev->type = LockEvent::Type::ObtainShared; - InsertLockEvent( lock, lev, ev.thread ); + InsertLockEvent( lock, lev, ev.thread, time ); } void Worker::ProcessLockSharedRelease( const QueueLockRelease& ev ) @@ -3892,11 +3896,12 @@ void Worker::ProcessLockSharedRelease( const QueueLockRelease& ev ) auto lev = m_slab.Alloc(); const auto refTime = m_refTimeSerial + ev.time; m_refTimeSerial = refTime; - lev->SetTime( TscTime( refTime - m_data.baseTime ) ); + const auto time = TscTime( refTime - m_data.baseTime ); + lev->SetTime( time ); lev->SetSrcLoc( 0 ); lev->type = LockEvent::Type::ReleaseShared; - InsertLockEvent( lock, lev, ev.thread ); + InsertLockEvent( lock, lev, ev.thread, time ); } void Worker::ProcessLockMark( const QueueLockMark& ev ) diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index 0dd236d6..d7378429 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -497,7 +497,7 @@ private: tracy_force_inline void NewZone( ZoneEvent* zone, uint64_t thread ); - void InsertLockEvent( LockMap& lockmap, LockEvent* lev, uint64_t thread ); + void InsertLockEvent( LockMap& lockmap, LockEvent* lev, uint64_t thread, int64_t time ); void CheckString( uint64_t ptr ); void CheckThreadString( uint64_t id );