From c431747f06f2ff92800a023fe7d446e2d4b54af5 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Wed, 22 Nov 2017 02:28:12 +0100 Subject: [PATCH] Favor transfer of zones without predicted payload. --- client/TracyProfiler.cpp | 40 ++++++++++++++++++++++------------------ common/TracyQueue.hpp | 13 +++++++------ 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index 904a98b4..714011b7 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -269,25 +269,29 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token ) while( item != end ) { uint64_t ptr; - switch( item->hdr.type ) + if( item->hdr.idx < (int)QueueType::Terminate ) { - case QueueType::ZoneText: - ptr = item->zoneText.text; - SendString( ptr, (const char*)ptr, QueueType::CustomStringData ); - tracy_free( (void*)ptr ); - break; - case QueueType::Message: - ptr = item->message.text; - SendString( ptr, (const char*)ptr, QueueType::CustomStringData ); - tracy_free( (void*)ptr ); - break; - case QueueType::ZoneBeginAllocSrcLoc: - ptr = item->zoneBegin.srcloc; - SendSourceLocationPayload( ptr ); - tracy_free( (void*)ptr ); - break; - default: - break; + switch( item->hdr.type ) + { + case QueueType::ZoneText: + ptr = item->zoneText.text; + SendString( ptr, (const char*)ptr, QueueType::CustomStringData ); + tracy_free( (void*)ptr ); + break; + case QueueType::Message: + ptr = item->message.text; + SendString( ptr, (const char*)ptr, QueueType::CustomStringData ); + tracy_free( (void*)ptr ); + break; + case QueueType::ZoneBeginAllocSrcLoc: + ptr = item->zoneBegin.srcloc; + SendSourceLocationPayload( ptr ); + tracy_free( (void*)ptr ); + break; + default: + assert( false ); + break; + } } if( !AppendData( item, QueueDataSize[item->hdr.idx] ) ) return ConnectionLost; item++; diff --git a/common/TracyQueue.hpp b/common/TracyQueue.hpp index d453a0ad..067d5586 100644 --- a/common/TracyQueue.hpp +++ b/common/TracyQueue.hpp @@ -8,19 +8,19 @@ namespace tracy enum class QueueType : uint8_t { + ZoneText, + Message, + ZoneBeginAllocSrcLoc, Terminate, ZoneBegin, - ZoneBeginAllocSrcLoc, ZoneEnd, FrameMarkMsg, SourceLocation, - ZoneText, LockWait, LockObtain, LockRelease, LockMark, PlotData, - Message, MessageLiteral, GpuNewContext, GpuZoneBegin, @@ -200,19 +200,20 @@ struct QueueItem enum { QueueItemSize = sizeof( QueueItem ) }; static const size_t QueueDataSize[] = { + sizeof( QueueHeader ) + sizeof( QueueZoneText ), + sizeof( QueueHeader ) + sizeof( QueueMessage ), + sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // allocated source location + // above items must be first sizeof( QueueHeader ), // terminate sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), - sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // allocated source location sizeof( QueueHeader ) + sizeof( QueueZoneEnd ), sizeof( QueueHeader ) + sizeof( QueueFrameMark ), sizeof( QueueHeader ) + sizeof( QueueSourceLocation ), - sizeof( QueueHeader ) + sizeof( QueueZoneText ), sizeof( QueueHeader ) + sizeof( QueueLockWait ), sizeof( QueueHeader ) + sizeof( QueueLockObtain ), sizeof( QueueHeader ) + sizeof( QueueLockRelease ), sizeof( QueueHeader ) + sizeof( QueueLockMark ), sizeof( QueueHeader ) + sizeof( QueuePlotData ), - sizeof( QueueHeader ) + sizeof( QueueMessage ), sizeof( QueueHeader ) + sizeof( QueueMessage ), // literal sizeof( QueueHeader ) + sizeof( QueueGpuNewContext ), sizeof( QueueHeader ) + sizeof( QueueGpuZoneBegin ),