diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index ddf21c5e..e8ba2c41 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -1447,12 +1447,14 @@ void Profiler::Worker() for( auto& item : m_deferredQueue ) { uint64_t ptr; + uint16_t size; const auto idx = MemRead( &item.hdr.idx ); switch( (QueueType)idx ) { case QueueType::MessageAppInfo: - ptr = MemRead( &item.message.text ); - SendString( ptr, (const char*)ptr, QueueType::CustomStringData ); + ptr = MemRead( &item.messageFat.text ); + size = MemRead( &item.messageFat.size ); + SendSingleString( (const char*)ptr, size ); break; case QueueType::LockName: ptr = MemRead( &item.lockName.name ); @@ -1720,7 +1722,7 @@ static void FreeAssociatedMemory( const QueueItem& item ) #ifndef TRACY_ON_DEMAND case QueueType::MessageAppInfo: #endif - ptr = MemRead( &item.message.text ); + ptr = MemRead( &item.messageFat.text ); tracy_free( (void*)ptr ); break; case QueueType::ZoneBeginAllocSrcLoc: @@ -1842,19 +1844,20 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token ) case QueueType::MessageCallstack: ptr = MemRead( &item->messageFat.text ); size = MemRead( &item->messageFat.size ); - SendString( ptr, (const char*)ptr, size, QueueType::CustomStringData ); + SendSingleString( (const char*)ptr, size ); tracy_free( (void*)ptr ); break; case QueueType::MessageColor: case QueueType::MessageColorCallstack: ptr = MemRead( &item->messageColorFat.text ); size = MemRead( &item->messageColorFat.size ); - SendString( ptr, (const char*)ptr, size, QueueType::CustomStringData ); + SendSingleString( (const char*)ptr, size ); tracy_free( (void*)ptr ); break; case QueueType::MessageAppInfo: - ptr = MemRead( &item->message.text ); - SendString( ptr, (const char*)ptr, QueueType::CustomStringData ); + ptr = MemRead( &item->messageFat.text ); + size = MemRead( &item->messageFat.size ); + SendSingleString( (const char*)ptr, size ); #ifndef TRACY_ON_DEMAND tracy_free( (void*)ptr ); #endif diff --git a/client/TracyProfiler.hpp b/client/TracyProfiler.hpp index 511df3ab..d37c51dc 100644 --- a/client/TracyProfiler.hpp +++ b/client/TracyProfiler.hpp @@ -298,8 +298,8 @@ public: if( !GetProfiler().IsConnected() ) return; #endif TracyLfqPrepare( callstack == 0 ? QueueType::MessageLiteral : QueueType::MessageLiteralCallstack ); - MemWrite( &item->message.time, GetTime() ); - MemWrite( &item->message.text, (uint64_t)txt ); + MemWrite( &item->messageLiteral.time, GetTime() ); + MemWrite( &item->messageLiteral.text, (uint64_t)txt ); TracyLfqCommit; if( callstack != 0 ) tracy::GetProfiler().SendCallstack( callstack ); @@ -331,11 +331,11 @@ public: if( !GetProfiler().IsConnected() ) return; #endif TracyLfqPrepare( callstack == 0 ? QueueType::MessageLiteralColor : QueueType::MessageLiteralColorCallstack ); - MemWrite( &item->messageColor.time, GetTime() ); - MemWrite( &item->messageColor.text, (uint64_t)txt ); - MemWrite( &item->messageColor.r, uint8_t( ( color ) & 0xFF ) ); - MemWrite( &item->messageColor.g, uint8_t( ( color >> 8 ) & 0xFF ) ); - MemWrite( &item->messageColor.b, uint8_t( ( color >> 16 ) & 0xFF ) ); + MemWrite( &item->messageColorLiteral.time, GetTime() ); + MemWrite( &item->messageColorLiteral.text, (uint64_t)txt ); + MemWrite( &item->messageColorLiteral.r, uint8_t( ( color ) & 0xFF ) ); + MemWrite( &item->messageColorLiteral.g, uint8_t( ( color >> 8 ) & 0xFF ) ); + MemWrite( &item->messageColorLiteral.b, uint8_t( ( color >> 16 ) & 0xFF ) ); TracyLfqCommit; if( callstack != 0 ) tracy::GetProfiler().SendCallstack( callstack ); @@ -343,13 +343,14 @@ public: static tracy_force_inline void MessageAppInfo( const char* txt, size_t size ) { + assert( size < std::numeric_limits::max() ); InitRPMallocThread(); - auto ptr = (char*)tracy_malloc( size+1 ); + auto ptr = (char*)tracy_malloc( size ); memcpy( ptr, txt, size ); - ptr[size] = '\0'; TracyLfqPrepare( QueueType::MessageAppInfo ); - MemWrite( &item->message.time, GetTime() ); - MemWrite( &item->message.text, (uint64_t)ptr ); + MemWrite( &item->messageFat.time, GetTime() ); + MemWrite( &item->messageFat.text, (uint64_t)ptr ); + MemWrite( &item->messageFat.size, (uint16_t)size ); #ifdef TRACY_ON_DEMAND GetProfiler().DeferItem( *item ); diff --git a/common/TracyQueue.hpp b/common/TracyQueue.hpp index 901bf113..2b73a94d 100644 --- a/common/TracyQueue.hpp +++ b/common/TracyQueue.hpp @@ -251,7 +251,6 @@ struct QueuePlotData struct QueueMessage { int64_t time; - uint64_t text; // ptr }; struct QueueMessageColor : public QueueMessage @@ -261,13 +260,25 @@ struct QueueMessageColor : public QueueMessage uint8_t b; }; +struct QueueMessageLiteral : public QueueMessage +{ + uint64_t text; // ptr +}; + +struct QueueMessageColorLiteral : public QueueMessageColor +{ + uint64_t text; // ptr +}; + struct QueueMessageFat : public QueueMessage { + uint64_t text; // ptr uint16_t size; }; struct QueueMessageColorFat : public QueueMessageColor { + uint64_t text; // ptr uint16_t size; }; @@ -495,6 +506,8 @@ struct QueueItem QueuePlotData plotData; QueueMessage message; QueueMessageColor messageColor; + QueueMessageLiteral messageLiteral; + QueueMessageColorLiteral messageColorLiteral; QueueMessageFat messageFat; QueueMessageColorFat messageColorFat; QueueGpuNewContext gpuNewContext; @@ -590,10 +603,10 @@ static constexpr size_t QueueDataSize[] = { sizeof( QueueHeader ) + sizeof( QueueLockAnnounce ), sizeof( QueueHeader ) + sizeof( QueueLockTerminate ), sizeof( QueueHeader ) + sizeof( QueueLockMark ), - sizeof( QueueHeader ) + sizeof( QueueMessage ), // literal - sizeof( QueueHeader ) + sizeof( QueueMessageColor ), // literal - sizeof( QueueHeader ) + sizeof( QueueMessage ), // literal, callstack - sizeof( QueueHeader ) + sizeof( QueueMessageColor ), // literal, callstack + sizeof( QueueHeader ) + sizeof( QueueMessageLiteral ), + sizeof( QueueHeader ) + sizeof( QueueMessageColorLiteral ), + sizeof( QueueHeader ) + sizeof( QueueMessageLiteral ), // callstack + sizeof( QueueHeader ) + sizeof( QueueMessageColorLiteral ), // callstack sizeof( QueueHeader ) + sizeof( QueueGpuNewContext ), sizeof( QueueHeader ) + sizeof( QueueCallstackFrameSize ), sizeof( QueueHeader ) + sizeof( QueueCallstackFrame ), diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 14687b50..68b17feb 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -3947,25 +3947,25 @@ bool Worker::Process( const QueueItem& ev ) ProcessMessage( ev.message ); break; case QueueType::MessageLiteral: - ProcessMessageLiteral( ev.message ); + ProcessMessageLiteral( ev.messageLiteral ); break; case QueueType::MessageColor: ProcessMessageColor( ev.messageColor ); break; case QueueType::MessageLiteralColor: - ProcessMessageLiteralColor( ev.messageColor ); + ProcessMessageLiteralColor( ev.messageColorLiteral ); break; case QueueType::MessageCallstack: ProcessMessageCallstack( ev.message ); break; case QueueType::MessageLiteralCallstack: - ProcessMessageLiteralCallstack( ev.message ); + ProcessMessageLiteralCallstack( ev.messageLiteral ); break; case QueueType::MessageColorCallstack: ProcessMessageColorCallstack( ev.messageColor ); break; case QueueType::MessageLiteralColorCallstack: - ProcessMessageLiteralColorCallstack( ev.messageColor ); + ProcessMessageLiteralColorCallstack( ev.messageColorLiteral ); break; case QueueType::MessageAppInfo: ProcessMessageAppInfo( ev.message ); @@ -4810,21 +4810,18 @@ void Worker::ProcessPlotConfig( const QueuePlotConfig& ev ) void Worker::ProcessMessage( const QueueMessage& ev ) { - auto it = m_pendingCustomStrings.find( ev.text ); - assert( it != m_pendingCustomStrings.end() ); auto msg = m_slab.Alloc(); const auto time = TscTime( ev.time - m_data.baseTime ); msg->time = time; - msg->ref = StringRef( StringRef::Type::Idx, it->second.idx ); + msg->ref = StringRef( StringRef::Type::Idx, GetSingleStringIdx() ); msg->thread = CompressThread( m_threadCtx ); msg->color = 0xFFFFFFFF; msg->callstack.SetVal( 0 ); if( m_data.lastTime < time ) m_data.lastTime = time; InsertMessageData( msg ); - m_pendingCustomStrings.erase( it ); } -void Worker::ProcessMessageLiteral( const QueueMessage& ev ) +void Worker::ProcessMessageLiteral( const QueueMessageLiteral& ev ) { CheckString( ev.text ); auto msg = m_slab.Alloc(); @@ -4840,21 +4837,18 @@ void Worker::ProcessMessageLiteral( const QueueMessage& ev ) void Worker::ProcessMessageColor( const QueueMessageColor& ev ) { - auto it = m_pendingCustomStrings.find( ev.text ); - assert( it != m_pendingCustomStrings.end() ); auto msg = m_slab.Alloc(); const auto time = TscTime( ev.time - m_data.baseTime ); msg->time = time; - msg->ref = StringRef( StringRef::Type::Idx, it->second.idx ); + msg->ref = StringRef( StringRef::Type::Idx, GetSingleStringIdx() ); msg->thread = CompressThread( m_threadCtx ); msg->color = 0xFF000000 | ( ev.r << 16 ) | ( ev.g << 8 ) | ev.b; msg->callstack.SetVal( 0 ); if( m_data.lastTime < time ) m_data.lastTime = time; InsertMessageData( msg ); - m_pendingCustomStrings.erase( it ); } -void Worker::ProcessMessageLiteralColor( const QueueMessageColor& ev ) +void Worker::ProcessMessageLiteralColor( const QueueMessageColorLiteral& ev ) { CheckString( ev.text ); auto msg = m_slab.Alloc(); @@ -4876,7 +4870,7 @@ void Worker::ProcessMessageCallstack( const QueueMessage& ev ) next.type = NextCallstackType::Message; } -void Worker::ProcessMessageLiteralCallstack( const QueueMessage& ev ) +void Worker::ProcessMessageLiteralCallstack( const QueueMessageLiteral& ev ) { ProcessMessageLiteral( ev ); @@ -4892,7 +4886,7 @@ void Worker::ProcessMessageColorCallstack( const QueueMessageColor& ev ) next.type = NextCallstackType::Message; } -void Worker::ProcessMessageLiteralColorCallstack( const QueueMessageColor& ev ) +void Worker::ProcessMessageLiteralColorCallstack( const QueueMessageColorLiteral& ev ) { ProcessMessageLiteralColor( ev ); @@ -4902,12 +4896,9 @@ void Worker::ProcessMessageLiteralColorCallstack( const QueueMessageColor& ev ) void Worker::ProcessMessageAppInfo( const QueueMessage& ev ) { - auto it = m_pendingCustomStrings.find( ev.text ); - assert( it != m_pendingCustomStrings.end() ); - m_data.appInfo.push_back( StringRef( StringRef::Type::Idx, it->second.idx ) ); + m_data.appInfo.push_back( StringRef( StringRef::Type::Idx, GetSingleStringIdx() ) ); const auto time = TscTime( ev.time - m_data.baseTime ); if( m_data.lastTime < time ) m_data.lastTime = time; - m_pendingCustomStrings.erase( it ); } void Worker::ProcessGpuNewContext( const QueueGpuNewContext& ev ) diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index 8a33e09b..ac74f156 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -630,13 +630,13 @@ private: tracy_force_inline void ProcessPlotData( const QueuePlotData& ev ); tracy_force_inline void ProcessPlotConfig( const QueuePlotConfig& ev ); tracy_force_inline void ProcessMessage( const QueueMessage& ev ); - tracy_force_inline void ProcessMessageLiteral( const QueueMessage& ev ); + tracy_force_inline void ProcessMessageLiteral( const QueueMessageLiteral& ev ); tracy_force_inline void ProcessMessageColor( const QueueMessageColor& ev ); - tracy_force_inline void ProcessMessageLiteralColor( const QueueMessageColor& ev ); + tracy_force_inline void ProcessMessageLiteralColor( const QueueMessageColorLiteral& ev ); tracy_force_inline void ProcessMessageCallstack( const QueueMessage& ev ); - tracy_force_inline void ProcessMessageLiteralCallstack( const QueueMessage& ev ); + tracy_force_inline void ProcessMessageLiteralCallstack( const QueueMessageLiteral& ev ); tracy_force_inline void ProcessMessageColorCallstack( const QueueMessageColor& ev ); - tracy_force_inline void ProcessMessageLiteralColorCallstack( const QueueMessageColor& ev ); + tracy_force_inline void ProcessMessageLiteralColorCallstack( const QueueMessageColorLiteral& ev ); tracy_force_inline void ProcessMessageAppInfo( const QueueMessage& ev ); tracy_force_inline void ProcessGpuNewContext( const QueueGpuNewContext& ev ); tracy_force_inline void ProcessGpuZoneBegin( const QueueGpuZoneBegin& ev, bool serial );