From 5553761c024d6fdde1ee4a2f98c1367e787eec30 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 26 Jul 2020 00:53:55 +0200 Subject: [PATCH] Send single string for zone text and name. --- client/TracyProfiler.cpp | 4 ++-- common/TracyQueue.hpp | 11 +++-------- server/TracyWorker.cpp | 23 ++++++++++------------- server/TracyWorker.hpp | 4 ++-- 4 files changed, 17 insertions(+), 25 deletions(-) diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index 83dde728..ddf21c5e 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -1710,7 +1710,7 @@ static void FreeAssociatedMemory( const QueueItem& item ) { case QueueType::ZoneText: case QueueType::ZoneName: - ptr = MemRead( &item.zoneText.text ); + ptr = MemRead( &item.zoneTextFat.text ); tracy_free( (void*)ptr ); break; case QueueType::Message: @@ -1835,7 +1835,7 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token ) case QueueType::ZoneName: ptr = MemRead( &item->zoneTextFat.text ); size = MemRead( &item->zoneTextFat.size ); - SendString( ptr, (const char*)ptr, size, QueueType::CustomStringData ); + SendSingleString( (const char*)ptr, size ); tracy_free( (void*)ptr ); break; case QueueType::Message: diff --git a/common/TracyQueue.hpp b/common/TracyQueue.hpp index b86a8226..901bf113 100644 --- a/common/TracyQueue.hpp +++ b/common/TracyQueue.hpp @@ -166,13 +166,9 @@ struct QueueSourceLocation uint8_t b; }; -struct QueueZoneText +struct QueueZoneTextFat { uint64_t text; // ptr -}; - -struct QueueZoneTextFat : public QueueZoneText -{ uint16_t size; }; @@ -488,7 +484,6 @@ struct QueueItem QueueFrameImage frameImage; QueueFrameImage frameImageLean; QueueSourceLocation srcloc; - QueueZoneText zoneText; QueueZoneTextFat zoneTextFat; QueueLockAnnounce lockAnnounce; QueueLockTerminate lockTerminate; @@ -534,8 +529,8 @@ struct QueueItem enum { QueueItemSize = sizeof( QueueItem ) }; static constexpr size_t QueueDataSize[] = { - sizeof( QueueHeader ) + sizeof( QueueZoneText ), - sizeof( QueueHeader ) + sizeof( QueueZoneText ), // zone name + sizeof( QueueHeader ), // zone text + sizeof( QueueHeader ), // zone name sizeof( QueueHeader ) + sizeof( QueueMessage ), sizeof( QueueHeader ) + sizeof( QueueMessageColor ), sizeof( QueueHeader ) + sizeof( QueueMessage ), // callstack diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index cbe27fae..14687b50 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -3899,10 +3899,10 @@ bool Worker::Process( const QueueItem& ev ) m_serverQuerySpaceLeft++; break; case QueueType::ZoneText: - ProcessZoneText( ev.zoneText ); + ProcessZoneText(); break; case QueueType::ZoneName: - ProcessZoneName( ev.zoneText ); + ProcessZoneName(); break; case QueueType::ZoneValue: ProcessZoneValue( ev.zoneValue ); @@ -4462,7 +4462,7 @@ void Worker::ProcessFrameImage( const QueueFrameImageLean& ev ) } } -void Worker::ProcessZoneText( const QueueZoneText& ev ) +void Worker::ProcessZoneText() { auto td = RetrieveThread( m_threadCtx ); if( !td || td->stack.empty() || td->nextZoneId != td->zoneIdStack.back() ) @@ -4471,20 +4471,21 @@ void Worker::ProcessZoneText( const QueueZoneText& ev ) return; } + const auto ptr = m_pendingSingleString.ptr; + const auto idx = GetSingleStringIdx(); + td->nextZoneId = 0; auto& stack = td->stack; auto zone = stack.back(); - auto it = m_pendingCustomStrings.find( ev.text ); - assert( it != m_pendingCustomStrings.end() ); auto& extra = RequestZoneExtra( *zone ); if( !extra.text.Active() ) { - extra.text = StringIdx( it->second.idx ); + extra.text = StringIdx( idx ); } else { const auto str0 = GetString( extra.text ); - const auto str1 = it->second.ptr; + const auto str1 = ptr; const auto len0 = strlen( str0 ); const auto len1 = strlen( str1 ); const auto bsz = len0+len1+1; @@ -4500,10 +4501,9 @@ void Worker::ProcessZoneText( const QueueZoneText& ev ) memcpy( buf+len0+1, str1, len1 ); extra.text = StringIdx( StoreString( buf, bsz ).idx ); } - m_pendingCustomStrings.erase( it ); } -void Worker::ProcessZoneName( const QueueZoneText& ev ) +void Worker::ProcessZoneName() { auto td = RetrieveThread( m_threadCtx ); if( !td || td->stack.empty() || td->nextZoneId != td->zoneIdStack.back() ) @@ -4515,11 +4515,8 @@ void Worker::ProcessZoneName( const QueueZoneText& ev ) td->nextZoneId = 0; auto& stack = td->stack; auto zone = stack.back(); - auto it = m_pendingCustomStrings.find( ev.text ); - assert( it != m_pendingCustomStrings.end() ); auto& extra = RequestZoneExtra( *zone ); - extra.name = StringIdx( it->second.idx ); - m_pendingCustomStrings.erase( it ); + extra.name = StringIdx( GetSingleStringIdx() ); } void Worker::ProcessZoneValue( const QueueZoneValue& ev ) diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index 9108814b..8a33e09b 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -614,8 +614,8 @@ private: tracy_force_inline void ProcessFrameMarkStart( const QueueFrameMark& ev ); tracy_force_inline void ProcessFrameMarkEnd( const QueueFrameMark& ev ); tracy_force_inline void ProcessFrameImage( const QueueFrameImageLean& ev ); - tracy_force_inline void ProcessZoneText( const QueueZoneText& ev ); - tracy_force_inline void ProcessZoneName( const QueueZoneText& ev ); + tracy_force_inline void ProcessZoneText(); + tracy_force_inline void ProcessZoneName(); tracy_force_inline void ProcessZoneValue( const QueueZoneValue& ev ); tracy_force_inline void ProcessLockAnnounce( const QueueLockAnnounce& ev ); tracy_force_inline void ProcessLockTerminate( const QueueLockTerminate& ev );