Send single string for zone text and name.

This commit is contained in:
Bartosz Taudul 2020-07-26 00:53:55 +02:00
parent 309a151610
commit 5553761c02
4 changed files with 17 additions and 25 deletions

View File

@ -1710,7 +1710,7 @@ static void FreeAssociatedMemory( const QueueItem& item )
{ {
case QueueType::ZoneText: case QueueType::ZoneText:
case QueueType::ZoneName: case QueueType::ZoneName:
ptr = MemRead<uint64_t>( &item.zoneText.text ); ptr = MemRead<uint64_t>( &item.zoneTextFat.text );
tracy_free( (void*)ptr ); tracy_free( (void*)ptr );
break; break;
case QueueType::Message: case QueueType::Message:
@ -1835,7 +1835,7 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token )
case QueueType::ZoneName: case QueueType::ZoneName:
ptr = MemRead<uint64_t>( &item->zoneTextFat.text ); ptr = MemRead<uint64_t>( &item->zoneTextFat.text );
size = MemRead<uint16_t>( &item->zoneTextFat.size ); size = MemRead<uint16_t>( &item->zoneTextFat.size );
SendString( ptr, (const char*)ptr, size, QueueType::CustomStringData ); SendSingleString( (const char*)ptr, size );
tracy_free( (void*)ptr ); tracy_free( (void*)ptr );
break; break;
case QueueType::Message: case QueueType::Message:

View File

@ -166,13 +166,9 @@ struct QueueSourceLocation
uint8_t b; uint8_t b;
}; };
struct QueueZoneText struct QueueZoneTextFat
{ {
uint64_t text; // ptr uint64_t text; // ptr
};
struct QueueZoneTextFat : public QueueZoneText
{
uint16_t size; uint16_t size;
}; };
@ -488,7 +484,6 @@ struct QueueItem
QueueFrameImage frameImage; QueueFrameImage frameImage;
QueueFrameImage frameImageLean; QueueFrameImage frameImageLean;
QueueSourceLocation srcloc; QueueSourceLocation srcloc;
QueueZoneText zoneText;
QueueZoneTextFat zoneTextFat; QueueZoneTextFat zoneTextFat;
QueueLockAnnounce lockAnnounce; QueueLockAnnounce lockAnnounce;
QueueLockTerminate lockTerminate; QueueLockTerminate lockTerminate;
@ -534,8 +529,8 @@ struct QueueItem
enum { QueueItemSize = sizeof( QueueItem ) }; enum { QueueItemSize = sizeof( QueueItem ) };
static constexpr size_t QueueDataSize[] = { static constexpr size_t QueueDataSize[] = {
sizeof( QueueHeader ) + sizeof( QueueZoneText ), sizeof( QueueHeader ), // zone text
sizeof( QueueHeader ) + sizeof( QueueZoneText ), // zone name sizeof( QueueHeader ), // zone name
sizeof( QueueHeader ) + sizeof( QueueMessage ), sizeof( QueueHeader ) + sizeof( QueueMessage ),
sizeof( QueueHeader ) + sizeof( QueueMessageColor ), sizeof( QueueHeader ) + sizeof( QueueMessageColor ),
sizeof( QueueHeader ) + sizeof( QueueMessage ), // callstack sizeof( QueueHeader ) + sizeof( QueueMessage ), // callstack

View File

@ -3899,10 +3899,10 @@ bool Worker::Process( const QueueItem& ev )
m_serverQuerySpaceLeft++; m_serverQuerySpaceLeft++;
break; break;
case QueueType::ZoneText: case QueueType::ZoneText:
ProcessZoneText( ev.zoneText ); ProcessZoneText();
break; break;
case QueueType::ZoneName: case QueueType::ZoneName:
ProcessZoneName( ev.zoneText ); ProcessZoneName();
break; break;
case QueueType::ZoneValue: case QueueType::ZoneValue:
ProcessZoneValue( ev.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 ); auto td = RetrieveThread( m_threadCtx );
if( !td || td->stack.empty() || td->nextZoneId != td->zoneIdStack.back() ) if( !td || td->stack.empty() || td->nextZoneId != td->zoneIdStack.back() )
@ -4471,20 +4471,21 @@ void Worker::ProcessZoneText( const QueueZoneText& ev )
return; return;
} }
const auto ptr = m_pendingSingleString.ptr;
const auto idx = GetSingleStringIdx();
td->nextZoneId = 0; td->nextZoneId = 0;
auto& stack = td->stack; auto& stack = td->stack;
auto zone = stack.back(); auto zone = stack.back();
auto it = m_pendingCustomStrings.find( ev.text );
assert( it != m_pendingCustomStrings.end() );
auto& extra = RequestZoneExtra( *zone ); auto& extra = RequestZoneExtra( *zone );
if( !extra.text.Active() ) if( !extra.text.Active() )
{ {
extra.text = StringIdx( it->second.idx ); extra.text = StringIdx( idx );
} }
else else
{ {
const auto str0 = GetString( extra.text ); const auto str0 = GetString( extra.text );
const auto str1 = it->second.ptr; const auto str1 = ptr;
const auto len0 = strlen( str0 ); const auto len0 = strlen( str0 );
const auto len1 = strlen( str1 ); const auto len1 = strlen( str1 );
const auto bsz = len0+len1+1; const auto bsz = len0+len1+1;
@ -4500,10 +4501,9 @@ void Worker::ProcessZoneText( const QueueZoneText& ev )
memcpy( buf+len0+1, str1, len1 ); memcpy( buf+len0+1, str1, len1 );
extra.text = StringIdx( StoreString( buf, bsz ).idx ); 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 ); auto td = RetrieveThread( m_threadCtx );
if( !td || td->stack.empty() || td->nextZoneId != td->zoneIdStack.back() ) if( !td || td->stack.empty() || td->nextZoneId != td->zoneIdStack.back() )
@ -4515,11 +4515,8 @@ void Worker::ProcessZoneName( const QueueZoneText& ev )
td->nextZoneId = 0; td->nextZoneId = 0;
auto& stack = td->stack; auto& stack = td->stack;
auto zone = stack.back(); auto zone = stack.back();
auto it = m_pendingCustomStrings.find( ev.text );
assert( it != m_pendingCustomStrings.end() );
auto& extra = RequestZoneExtra( *zone ); auto& extra = RequestZoneExtra( *zone );
extra.name = StringIdx( it->second.idx ); extra.name = StringIdx( GetSingleStringIdx() );
m_pendingCustomStrings.erase( it );
} }
void Worker::ProcessZoneValue( const QueueZoneValue& ev ) void Worker::ProcessZoneValue( const QueueZoneValue& ev )

View File

@ -614,8 +614,8 @@ private:
tracy_force_inline void ProcessFrameMarkStart( const QueueFrameMark& ev ); tracy_force_inline void ProcessFrameMarkStart( const QueueFrameMark& ev );
tracy_force_inline void ProcessFrameMarkEnd( const QueueFrameMark& ev ); tracy_force_inline void ProcessFrameMarkEnd( const QueueFrameMark& ev );
tracy_force_inline void ProcessFrameImage( const QueueFrameImageLean& ev ); tracy_force_inline void ProcessFrameImage( const QueueFrameImageLean& ev );
tracy_force_inline void ProcessZoneText( const QueueZoneText& ev ); tracy_force_inline void ProcessZoneText();
tracy_force_inline void ProcessZoneName( const QueueZoneText& ev ); tracy_force_inline void ProcessZoneName();
tracy_force_inline void ProcessZoneValue( const QueueZoneValue& ev ); tracy_force_inline void ProcessZoneValue( const QueueZoneValue& ev );
tracy_force_inline void ProcessLockAnnounce( const QueueLockAnnounce& ev ); tracy_force_inline void ProcessLockAnnounce( const QueueLockAnnounce& ev );
tracy_force_inline void ProcessLockTerminate( const QueueLockTerminate& ev ); tracy_force_inline void ProcessLockTerminate( const QueueLockTerminate& ev );