Skip to content

Commit

Permalink
Add client side fragmented blob support
Browse files Browse the repository at this point in the history
  • Loading branch information
eibach committed Dec 9, 2024
1 parent 1aeb661 commit f134e06
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
21 changes: 19 additions & 2 deletions public/client/TracyProfiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2464,7 +2464,7 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token )
case QueueType::BlobCallstack:
ptr = MemRead<uint64_t>( &item->blobData.data );
size = MemRead<uint16_t>( &item->blobData.size );
SendSingleString( (const char*)ptr, size );
SendBlob( (const char*)ptr, size );
tracy_free_fast( (void*)ptr );
break;
case QueueType::ZoneBeginAllocSrcLoc:
Expand Down Expand Up @@ -2999,7 +2999,7 @@ Profiler::DequeueStatus Profiler::DequeueSerial()
ThreadCtxCheckSerial( blobDataThread );
ptr = MemRead<uint64_t>( &item->blobData.data );
uint16_t size = MemRead<uint16_t>( &item->blobData.size );
SendSingleString( (const char*)ptr, size );
SendBlob( (const char*)ptr, size );
tracy_free_fast( (void*)ptr );
break;
}
Expand Down Expand Up @@ -3267,6 +3267,23 @@ void Profiler::SendLongString( uint64_t str, const char* ptr, size_t len, QueueT
AppendDataUnsafe( ptr, l32 );
}

void Profiler::SendBlob( const char* ptr, size_t len )
{
QueueItem item;
MemWrite( &item.hdr.type, QueueType::BlobFragment );
while (len)
{
uint32_t fragment_size = len > TargetFrameSize ? TargetFrameSize : len;
len -= fragment_size;

NeedDataSize( QueueDataSize[(int)QueueType::BlobFragment] + sizeof( fragment_size ) + fragment_size );

AppendDataUnsafe( &item, QueueDataSize[(int)QueueType::BlobFragment] );
AppendDataUnsafe( &fragment_size, sizeof( fragment_size ) );
AppendDataUnsafe( ptr, fragment_size );
}
}

void Profiler::SendSourceLocation( uint64_t ptr )
{
auto srcloc = (const SourceLocationData*)ptr;
Expand Down
2 changes: 2 additions & 0 deletions public/client/TracyProfiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,8 @@ class Profiler
void SendSecondString( const char* ptr ) { SendSecondString( ptr, strlen( ptr ) ); }
void SendSecondString( const char* ptr, size_t len );

void SendBlob( const char* ptr, size_t len );


// Allocated source location data layout:
// 2b payload size
Expand Down
2 changes: 2 additions & 0 deletions public/common/TracyQueue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ enum class QueueType : uint8_t
SymbolCode,
SourceCode,
FiberName,
BlobFragment,
NUM_TYPES
};

Expand Down Expand Up @@ -931,6 +932,7 @@ static constexpr size_t QueueDataSize[] = {
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // symbol code
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // source code
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // fiber name
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // blob fragment
};

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

0 comments on commit f134e06

Please sign in to comment.