From bcf2bf1c5cd562018729507ecb907a7f09875052 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 10 Dec 2017 22:04:49 +0100 Subject: [PATCH] Shared lock events (still using old functionality). --- client/TracyLock.hpp | 8 +++---- common/TracyQueue.hpp | 6 ++++++ server/TracyView.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++ server/TracyView.hpp | 3 +++ 4 files changed, 62 insertions(+), 4 deletions(-) diff --git a/client/TracyLock.hpp b/client/TracyLock.hpp index b16c4adb..59e3bead 100644 --- a/client/TracyLock.hpp +++ b/client/TracyLock.hpp @@ -211,7 +211,7 @@ public: auto& token = s_token.ptr; auto& tail = token->get_tail_index(); auto item = token->enqueue_begin( magic ); - item->hdr.type = QueueType::LockWait; + item->hdr.type = QueueType::LockSharedWait; item->lockWait.id = m_id; item->lockWait.thread = thread; item->lockWait.time = Profiler::GetTime(); @@ -225,7 +225,7 @@ public: auto& token = s_token.ptr; auto& tail = token->get_tail_index(); auto item = token->enqueue_begin( magic ); - item->hdr.type = QueueType::LockObtain; + item->hdr.type = QueueType::LockSharedObtain; item->lockObtain.id = m_id; item->lockObtain.thread = thread; item->lockObtain.time = Profiler::GetTime(); @@ -241,7 +241,7 @@ public: auto& token = s_token.ptr; auto& tail = token->get_tail_index(); auto item = token->enqueue_begin( magic ); - item->hdr.type = QueueType::LockRelease; + item->hdr.type = QueueType::LockSharedRelease; item->lockRelease.id = m_id; item->lockRelease.thread = GetThreadHandle(); item->lockRelease.time = Profiler::GetTime(); @@ -257,7 +257,7 @@ public: auto& token = s_token.ptr; auto& tail = token->get_tail_index(); auto item = token->enqueue_begin( magic ); - item->hdr.type = QueueType::LockObtain; + item->hdr.type = QueueType::LockSharedObtain; item->lockObtain.id = (uint64_t)&m_lockable; item->lockObtain.thread = GetThreadHandle(); item->lockObtain.time = Profiler::GetTime(); diff --git a/common/TracyQueue.hpp b/common/TracyQueue.hpp index f861ff1d..d2e95ebc 100644 --- a/common/TracyQueue.hpp +++ b/common/TracyQueue.hpp @@ -20,6 +20,9 @@ enum class QueueType : uint8_t LockWait, LockObtain, LockRelease, + LockSharedWait, + LockSharedObtain, + LockSharedRelease, LockMark, PlotData, MessageLiteral, @@ -236,6 +239,9 @@ static const size_t QueueDataSize[] = { sizeof( QueueHeader ) + sizeof( QueueLockWait ), sizeof( QueueHeader ) + sizeof( QueueLockObtain ), sizeof( QueueHeader ) + sizeof( QueueLockRelease ), + sizeof( QueueHeader ) + sizeof( QueueLockWait ), + sizeof( QueueHeader ) + sizeof( QueueLockObtain ), + sizeof( QueueHeader ) + sizeof( QueueLockRelease ), sizeof( QueueHeader ) + sizeof( QueueLockMark ), sizeof( QueueHeader ) + sizeof( QueuePlotData ), sizeof( QueueHeader ) + sizeof( QueueMessage ), // literal diff --git a/server/TracyView.cpp b/server/TracyView.cpp index ecb1a7b6..28c288d7 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -602,6 +602,15 @@ void View::Process( const QueueItem& ev ) case QueueType::LockRelease: ProcessLockRelease( ev.lockRelease ); break; + case QueueType::LockSharedWait: + ProcessLockSharedWait( ev.lockWait ); + break; + case QueueType::LockSharedObtain: + ProcessLockSharedObtain( ev.lockObtain ); + break; + case QueueType::LockSharedRelease: + ProcessLockSharedRelease( ev.lockRelease ); + break; case QueueType::LockMark: ProcessLockMark( ev.lockMark ); break; @@ -780,6 +789,46 @@ void View::ProcessLockRelease( const QueueLockRelease& ev ) InsertLockEvent( m_lockMap[ev.id], lev, ev.thread ); } +void View::ProcessLockSharedWait( const QueueLockWait& ev ) +{ + auto lev = m_slab.Alloc(); + lev->time = ev.time * m_timerMul; + lev->type = (uint8_t)LockEvent::Type::Wait; + lev->srcloc = 0; + + auto it = m_lockMap.find( ev.id ); + if( it == m_lockMap.end() ) + { + LockMap lm; + lm.valid = false; + it = m_lockMap.emplace( ev.id, std::move( lm ) ).first; + } + + InsertLockEvent( it->second, lev, ev.thread ); +} + +void View::ProcessLockSharedObtain( const QueueLockObtain& ev ) +{ + auto lev = m_slab.Alloc(); + lev->time = ev.time * m_timerMul; + lev->type = (uint8_t)LockEvent::Type::Obtain; + lev->srcloc = 0; + + assert( m_lockMap.find( ev.id ) != m_lockMap.end() ); + InsertLockEvent( m_lockMap[ev.id], lev, ev.thread ); +} + +void View::ProcessLockSharedRelease( const QueueLockRelease& ev ) +{ + auto lev = m_slab.Alloc(); + lev->time = ev.time * m_timerMul; + lev->type = (uint8_t)LockEvent::Type::Release; + lev->srcloc = 0; + + assert( m_lockMap.find( ev.id ) != m_lockMap.end() ); + InsertLockEvent( m_lockMap[ev.id], lev, ev.thread ); +} + void View::ProcessLockMark( const QueueLockMark& ev ) { CheckSourceLocation( ev.srcloc ); diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 22b6c364..c283b327 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -78,6 +78,9 @@ private: tracy_force_inline void ProcessLockWait( const QueueLockWait& ev ); tracy_force_inline void ProcessLockObtain( const QueueLockObtain& ev ); tracy_force_inline void ProcessLockRelease( const QueueLockRelease& ev ); + tracy_force_inline void ProcessLockSharedWait( const QueueLockWait& ev ); + tracy_force_inline void ProcessLockSharedObtain( const QueueLockObtain& ev ); + tracy_force_inline void ProcessLockSharedRelease( const QueueLockRelease& ev ); tracy_force_inline void ProcessLockMark( const QueueLockMark& ev ); tracy_force_inline void ProcessPlotData( const QueuePlotData& ev ); tracy_force_inline void ProcessMessage( const QueueMessage& ev );