From d522af99b92451c4fba212fa773d803c2f02a405 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Tue, 2 Nov 2021 01:51:54 +0100 Subject: [PATCH] Threads may be mapped to fibers. --- server/TracyWorker.cpp | 48 +++++++++++++++++++++++++++++++----------- server/TracyWorker.hpp | 2 ++ 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 53842e85..9cb78abc 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -3558,31 +3558,55 @@ void Worker::InsertMessageData( MessageData* msg ) ThreadData* Worker::NoticeThreadReal( uint64_t thread ) { - auto it = m_threadMap.find( thread ); - if( it != m_threadMap.end() ) + auto fit = m_data.threadToFiberMap.find( thread ); + if( fit == m_data.threadToFiberMap.end() ) { - m_data.threadDataLast.first = thread; - m_data.threadDataLast.second = it->second; - return it->second; + auto it = m_threadMap.find( thread ); + if( it != m_threadMap.end() ) + { + m_data.threadDataLast.first = thread; + m_data.threadDataLast.second = it->second; + return it->second; + } + else + { + return NewThread( thread, false ); + } } else { - return NewThread( thread, false ); + auto it = m_threadMap.find( fit->second ); + assert( it != m_threadMap.end() ); + m_data.threadDataLast.first = thread; + m_data.threadDataLast.second = it->second; + return it->second; } } ThreadData* Worker::RetrieveThreadReal( uint64_t thread ) { - auto it = m_threadMap.find( thread ); - if( it != m_threadMap.end() ) + auto fit = m_data.threadToFiberMap.find( thread ); + if( fit == m_data.threadToFiberMap.end() ) { - m_data.threadDataLast.first = thread; - m_data.threadDataLast.second = it->second; - return it->second; + auto it = m_threadMap.find( thread ); + if( it != m_threadMap.end() ) + { + m_data.threadDataLast.first = thread; + m_data.threadDataLast.second = it->second; + return it->second; + } + else + { + return nullptr; + } } else { - return nullptr; + auto it = m_threadMap.find( fit->second ); + assert( it != m_threadMap.end() ); + m_data.threadDataLast.first = thread; + m_data.threadDataLast.second = it->second; + return it->second; } } diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index 8e39db17..88e8291a 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -363,6 +363,8 @@ private: unordered_flat_map sourceFileCache; unordered_flat_map hwSamples; + + unordered_flat_map threadToFiberMap; }; struct MbpsBlock