mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Preemptive sending of custom strings.
This commit is contained in:
parent
c2797a4cc7
commit
76e11174dc
@ -263,7 +263,20 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token )
|
|||||||
{
|
{
|
||||||
for( size_t i=0; i<sz; i++ )
|
for( size_t i=0; i<sz; i++ )
|
||||||
{
|
{
|
||||||
if( !AppendData( m_itemBuf+i, QueueDataSize[m_itemBuf[i].hdr.idx] ) ) return ConnectionLost;
|
const auto item = m_itemBuf + i;
|
||||||
|
switch( item->hdr.type )
|
||||||
|
{
|
||||||
|
case QueueType::ZoneText:
|
||||||
|
{
|
||||||
|
const auto ptr = item->zoneText.text;
|
||||||
|
SendString( ptr, (const char*)ptr, QueueType::CustomStringData );
|
||||||
|
tracy_free( (void*)ptr );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if( !AppendData( item, QueueDataSize[m_itemBuf[i].hdr.idx] ) ) return ConnectionLost;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -394,10 +407,6 @@ bool Profiler::HandleServerQuery()
|
|||||||
SendString( ptr, GetThreadName( ptr ), QueueType::ThreadName );
|
SendString( ptr, GetThreadName( ptr ), QueueType::ThreadName );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ServerQueryCustomString:
|
|
||||||
SendString( ptr, (const char*)ptr, QueueType::CustomStringData );
|
|
||||||
tracy_free( (void*)ptr );
|
|
||||||
break;
|
|
||||||
case ServerQuerySourceLocation:
|
case ServerQuerySourceLocation:
|
||||||
SendSourceLocation( ptr );
|
SendSourceLocation( ptr );
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -21,7 +21,6 @@ enum ServerQuery : uint8_t
|
|||||||
ServerQueryTerminate,
|
ServerQueryTerminate,
|
||||||
ServerQueryString,
|
ServerQueryString,
|
||||||
ServerQueryThreadString,
|
ServerQueryThreadString,
|
||||||
ServerQueryCustomString,
|
|
||||||
ServerQuerySourceLocation,
|
ServerQuerySourceLocation,
|
||||||
ServerQuerySourceLocationPayload,
|
ServerQuerySourceLocationPayload,
|
||||||
ServerQueryPlotName,
|
ServerQueryPlotName,
|
||||||
|
|||||||
@ -666,7 +666,12 @@ void View::ProcessZoneText( const QueueZoneText& ev )
|
|||||||
auto& stack = m_zoneStack[ev.thread];
|
auto& stack = m_zoneStack[ev.thread];
|
||||||
assert( !stack.empty() );
|
assert( !stack.empty() );
|
||||||
auto zone = stack.back();
|
auto zone = stack.back();
|
||||||
CheckCustomString( ev.text, zone );
|
auto it = m_pendingCustomStrings.find( ev.text );
|
||||||
|
assert( it != m_pendingCustomStrings.end() );
|
||||||
|
m_lock.lock();
|
||||||
|
GetTextData( *zone )->userText = it->second;
|
||||||
|
m_lock.unlock();
|
||||||
|
m_pendingCustomStrings.erase( it );
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::ProcessZoneName( const QueueZoneName& ev )
|
void View::ProcessZoneName( const QueueZoneName& ev )
|
||||||
@ -836,14 +841,6 @@ void View::CheckThreadString( uint64_t id )
|
|||||||
ServerQuery( ServerQueryThreadString, id );
|
ServerQuery( ServerQueryThreadString, id );
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::CheckCustomString( uint64_t ptr, ZoneEvent* dst )
|
|
||||||
{
|
|
||||||
assert( m_pendingCustomStrings.find( ptr ) == m_pendingCustomStrings.end() );
|
|
||||||
m_pendingCustomStrings.emplace( ptr, dst );
|
|
||||||
|
|
||||||
ServerQuery( ServerQueryCustomString, ptr );
|
|
||||||
}
|
|
||||||
|
|
||||||
void View::CheckSourceLocation( uint64_t ptr )
|
void View::CheckSourceLocation( uint64_t ptr )
|
||||||
{
|
{
|
||||||
if( m_sourceLocation.find( ptr ) != m_sourceLocation.end() ) return;
|
if( m_sourceLocation.find( ptr ) != m_sourceLocation.end() ) return;
|
||||||
@ -886,13 +883,9 @@ void View::AddThreadString( uint64_t id, char* str, size_t sz )
|
|||||||
|
|
||||||
void View::AddCustomString( uint64_t ptr, char* str, size_t sz )
|
void View::AddCustomString( uint64_t ptr, char* str, size_t sz )
|
||||||
{
|
{
|
||||||
auto pit = m_pendingCustomStrings.find( ptr );
|
|
||||||
assert( pit != m_pendingCustomStrings.end() );
|
|
||||||
const auto sl = StoreString( str, sz );
|
const auto sl = StoreString( str, sz );
|
||||||
m_lock.lock();
|
assert( m_pendingCustomString.find( ptr ) == m_pendingCustomStrings.end() );
|
||||||
GetTextData( *pit->second )->userText = sl.ptr;
|
m_pendingCustomStrings.emplace( ptr, sl.ptr );
|
||||||
m_lock.unlock();
|
|
||||||
m_pendingCustomStrings.erase( pit );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
View::StringLocation View::StoreString( char* str, size_t sz )
|
View::StringLocation View::StoreString( char* str, size_t sz )
|
||||||
|
|||||||
@ -148,7 +148,6 @@ private:
|
|||||||
|
|
||||||
void CheckString( uint64_t ptr );
|
void CheckString( uint64_t ptr );
|
||||||
void CheckThreadString( uint64_t id );
|
void CheckThreadString( uint64_t id );
|
||||||
void CheckCustomString( uint64_t ptr, ZoneEvent* dst );
|
|
||||||
void CheckSourceLocation( uint64_t ptr );
|
void CheckSourceLocation( uint64_t ptr );
|
||||||
void CheckSourceLocationPayload( uint64_t ptr, ZoneEvent* dst );
|
void CheckSourceLocationPayload( uint64_t ptr, ZoneEvent* dst );
|
||||||
|
|
||||||
@ -260,7 +259,7 @@ private:
|
|||||||
std::unordered_set<uint64_t> m_pendingStrings;
|
std::unordered_set<uint64_t> m_pendingStrings;
|
||||||
std::unordered_set<uint64_t> m_pendingThreads;
|
std::unordered_set<uint64_t> m_pendingThreads;
|
||||||
std::unordered_set<uint64_t> m_pendingSourceLocation;
|
std::unordered_set<uint64_t> m_pendingSourceLocation;
|
||||||
std::unordered_map<uint64_t, ZoneEvent*> m_pendingCustomStrings;
|
std::unordered_map<uint64_t, const char*> m_pendingCustomStrings;
|
||||||
std::unordered_map<uint64_t, uint32_t> m_threadMap;
|
std::unordered_map<uint64_t, uint32_t> m_threadMap;
|
||||||
std::unordered_map<uint64_t, uint32_t> m_plotMap;
|
std::unordered_map<uint64_t, uint32_t> m_plotMap;
|
||||||
std::unordered_map<const char*, uint32_t, charutil::Hasher, charutil::Comparator> m_plotRev;
|
std::unordered_map<const char*, uint32_t, charutil::Hasher, charutil::Comparator> m_plotRev;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user