From 5b9fcddfb3336a4a43e537afc4b551d40e6bb37c Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 15 Oct 2017 13:06:49 +0200 Subject: [PATCH] String literal message transfer. --- client/Tracy.hpp | 2 ++ client/TracyProfiler.cpp | 3 +++ client/TracyProfiler.hpp | 14 ++++++++++++++ common/TracyProtocol.hpp | 1 + common/TracyQueue.hpp | 2 ++ server/TracyView.cpp | 9 ++++++--- server/TracyView.hpp | 2 +- 7 files changed, 29 insertions(+), 4 deletions(-) diff --git a/client/Tracy.hpp b/client/Tracy.hpp index 11f43ddd..331bc014 100644 --- a/client/Tracy.hpp +++ b/client/Tracy.hpp @@ -19,6 +19,7 @@ #define TracyPlot(x,y) #define TracyMessage(x,y) +#define TracyMessageL(x) #else @@ -42,6 +43,7 @@ #define TracyPlot( name, val ) tracy::Profiler::PlotData( name, val ); #define TracyMessage( txt, size ) tracy::Profiler::Message( txt, size ); +#define TracyMessageL( txt ) tracy::Profiler::Message( txt ); #endif diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index 7c016b00..118d01a0 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -285,6 +285,9 @@ bool Profiler::HandleServerQuery() SendString( ptr, (const char*)ptr, QueueType::MessageData ); tracy_free( (void*)ptr ); break; + case ServerQueryMessageLiteral: + SendString( ptr, (const char*)ptr, QueueType::MessageData ); + break; default: assert( false ); break; diff --git a/client/TracyProfiler.hpp b/client/TracyProfiler.hpp index 91c9038d..58a6876d 100644 --- a/client/TracyProfiler.hpp +++ b/client/TracyProfiler.hpp @@ -146,6 +146,20 @@ public: tail.store( magic + 1, std::memory_order_release ); } + static tracy_force_inline void Message( const char* txt ) + { + uint32_t cpu; + Magic magic; + auto& token = s_token.ptr; + auto& tail = token->get_tail_index(); + auto item = token->enqueue_begin( magic ); + item->hdr.type = QueueType::MessageLiteral; + item->message.time = GetTime( cpu ); + item->message.thread = GetThreadHandle(); + item->message.text = (uint64_t)txt; + tail.store( magic + 1, std::memory_order_release ); + } + static bool ShouldExit(); private: diff --git a/common/TracyProtocol.hpp b/common/TracyProtocol.hpp index fd4292aa..c821040a 100644 --- a/common/TracyProtocol.hpp +++ b/common/TracyProtocol.hpp @@ -24,6 +24,7 @@ enum ServerQuery : uint8_t ServerQuerySourceLocation, ServerQueryPlotName, ServerQueryMessage, + ServerQueryMessageLiteral, }; enum { WelcomeMessageProgramNameSize = 64 }; diff --git a/common/TracyQueue.hpp b/common/TracyQueue.hpp index 54ce7bee..5c148d6b 100644 --- a/common/TracyQueue.hpp +++ b/common/TracyQueue.hpp @@ -24,6 +24,7 @@ enum class QueueType : uint8_t PlotData, PlotName, Message, + MessageLiteral, MessageData, NUM_TYPES }; @@ -185,6 +186,7 @@ static const size_t QueueDataSize[] = { sizeof( QueueHeader ) + sizeof( QueuePlotData ), sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // plot name sizeof( QueueHeader ) + sizeof( QueueMessage ), + sizeof( QueueHeader ) + sizeof( QueueMessage ), // literal sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // message data }; diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 665617ba..bfa00a1c 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -511,7 +511,10 @@ void View::Process( const QueueItem& ev ) ProcessPlotData( ev.plotData ); break; case QueueType::Message: - ProcessMessage( ev.message ); + ProcessMessage( ev.message, false ); + break; + case QueueType::MessageLiteral: + ProcessMessage( ev.message, true ); break; default: assert( false ); @@ -701,10 +704,10 @@ void View::ProcessPlotData( const QueuePlotData& ev ) } } -void View::ProcessMessage( const QueueMessage& ev ) +void View::ProcessMessage( const QueueMessage& ev, bool literal ) { m_pendingMessages.emplace( ev.text, MessagePending { int64_t( ev.time * m_timerMul ), ev.thread } ); - ServerQuery( ServerQueryMessage, ev.text ); + ServerQuery( literal ? ServerQueryMessageLiteral : ServerQueryMessage, ev.text ); } void View::CheckString( uint64_t ptr ) diff --git a/server/TracyView.hpp b/server/TracyView.hpp index ee3bc1a5..88bc8f31 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -108,7 +108,7 @@ private: void ProcessLockRelease( const QueueLockRelease& ev ); void ProcessLockMark( const QueueLockMark& ev ); void ProcessPlotData( const QueuePlotData& ev ); - void ProcessMessage( const QueueMessage& ev ); + void ProcessMessage( const QueueMessage& ev, bool literal ); void CheckString( uint64_t ptr ); void CheckThreadString( uint64_t id );