Skip to content

Commit f134e06

Browse files
committed
Add client side fragmented blob support
1 parent 1aeb661 commit f134e06

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

public/client/TracyProfiler.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2464,7 +2464,7 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token )
24642464
case QueueType::BlobCallstack:
24652465
ptr = MemRead<uint64_t>( &item->blobData.data );
24662466
size = MemRead<uint16_t>( &item->blobData.size );
2467-
SendSingleString( (const char*)ptr, size );
2467+
SendBlob( (const char*)ptr, size );
24682468
tracy_free_fast( (void*)ptr );
24692469
break;
24702470
case QueueType::ZoneBeginAllocSrcLoc:
@@ -2999,7 +2999,7 @@ Profiler::DequeueStatus Profiler::DequeueSerial()
29992999
ThreadCtxCheckSerial( blobDataThread );
30003000
ptr = MemRead<uint64_t>( &item->blobData.data );
30013001
uint16_t size = MemRead<uint16_t>( &item->blobData.size );
3002-
SendSingleString( (const char*)ptr, size );
3002+
SendBlob( (const char*)ptr, size );
30033003
tracy_free_fast( (void*)ptr );
30043004
break;
30053005
}
@@ -3267,6 +3267,23 @@ void Profiler::SendLongString( uint64_t str, const char* ptr, size_t len, QueueT
32673267
AppendDataUnsafe( ptr, l32 );
32683268
}
32693269

3270+
void Profiler::SendBlob( const char* ptr, size_t len )
3271+
{
3272+
QueueItem item;
3273+
MemWrite( &item.hdr.type, QueueType::BlobFragment );
3274+
while (len)
3275+
{
3276+
uint32_t fragment_size = len > TargetFrameSize ? TargetFrameSize : len;
3277+
len -= fragment_size;
3278+
3279+
NeedDataSize( QueueDataSize[(int)QueueType::BlobFragment] + sizeof( fragment_size ) + fragment_size );
3280+
3281+
AppendDataUnsafe( &item, QueueDataSize[(int)QueueType::BlobFragment] );
3282+
AppendDataUnsafe( &fragment_size, sizeof( fragment_size ) );
3283+
AppendDataUnsafe( ptr, fragment_size );
3284+
}
3285+
}
3286+
32703287
void Profiler::SendSourceLocation( uint64_t ptr )
32713288
{
32723289
auto srcloc = (const SourceLocationData*)ptr;

public/client/TracyProfiler.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,8 @@ class Profiler
790790
void SendSecondString( const char* ptr ) { SendSecondString( ptr, strlen( ptr ) ); }
791791
void SendSecondString( const char* ptr, size_t len );
792792

793+
void SendBlob( const char* ptr, size_t len );
794+
793795

794796
// Allocated source location data layout:
795797
// 2b payload size

public/common/TracyQueue.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ enum class QueueType : uint8_t
126126
SymbolCode,
127127
SourceCode,
128128
FiberName,
129+
BlobFragment,
129130
NUM_TYPES
130131
};
131132

@@ -931,6 +932,7 @@ static constexpr size_t QueueDataSize[] = {
931932
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // symbol code
932933
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // source code
933934
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // fiber name
935+
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // blob fragment
934936
};
935937

936938
static_assert( QueueItemSize == 32, "Queue item size not 32 bytes" );

0 commit comments

Comments
 (0)