From c2bccf7126bbf3f4a61fd2469b2caec41cdcfd9f Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Wed, 4 Oct 2017 18:17:31 +0200 Subject: [PATCH] Move towards proper data structures. --- server/TracyEvent.hpp | 20 +++++++++++++++++++- server/TracyView.cpp | 9 ++------- server/TracyView.hpp | 9 +++++++-- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/server/TracyEvent.hpp b/server/TracyEvent.hpp index 561d9e56..6784d444 100755 --- a/server/TracyEvent.hpp +++ b/server/TracyEvent.hpp @@ -32,11 +32,29 @@ enum { EventSize = sizeof( Event ) }; struct LockEvent { - uint64_t srcloc; + enum class Type : uint8_t + { + Wait, + Obtain, + Release + }; + + int64_t time; + uint64_t thread; + Type type; }; enum { LockEventSize = sizeof( LockEvent ) }; + +struct LockTimeline +{ + uint64_t id; + Vector timeline; +}; + +enum { LockTimelineSize = sizeof( LockTimeline ) }; + #pragma pack() } diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 67879292..51d3cf55 100755 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -454,14 +454,9 @@ void View::ProcessLockAnnounce( const QueueLockAnnounce& ev ) { CheckSourceLocation( ev.srcloc ); - auto ptr = m_slab.Alloc(); - ptr->srcloc = ev.srcloc; - - assert( m_lockMap.find( ev.id ) == m_lockMap.end() ); - m_lockMap.emplace( ev.id, ptr ); - std::lock_guard lock( m_lock ); - m_locks.push_back( ptr ); + assert( m_lockMap.find( ev.id ) == m_lockMap.end() ); + m_lockMap.emplace( ev.id, LockMap { ev.srcloc } ); } void View::CheckString( uint64_t ptr ) diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 48589507..b8a59673 100755 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -44,6 +44,12 @@ private: Vector timeline; }; + struct LockMap + { + uint64_t srcloc; + LockTimeline ev; + }; + void Worker(); void DispatchProcess( const QueueItem& ev ); @@ -117,11 +123,11 @@ private: std::mutex m_lock; Vector m_frames; Vector m_threads; - Vector m_locks; std::unordered_map m_strings; std::unordered_map m_threadNames; std::unordered_set m_customStrings; std::unordered_map m_sourceLocation; + std::unordered_map m_lockMap; uint64_t m_zonesCnt; std::mutex m_mbpslock; @@ -134,7 +140,6 @@ private: std::unordered_set m_pendingSourceLocation; std::unordered_map m_pendingCustomStrings; std::unordered_map m_threadMap; - std::unordered_map m_lockMap; Slab m_slab;