mirror of
https://github.com/wolfpld/tracy
synced 2025-04-30 20:53:52 +00:00
Preemptive transfer of source location payload.
This commit is contained in:
parent
7f3b8f4647
commit
59ec40c045
@ -277,6 +277,11 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token )
|
|||||||
SendString( ptr, (const char*)ptr, QueueType::CustomStringData );
|
SendString( ptr, (const char*)ptr, QueueType::CustomStringData );
|
||||||
tracy_free( (void*)ptr );
|
tracy_free( (void*)ptr );
|
||||||
break;
|
break;
|
||||||
|
case QueueType::ZoneBeginAllocSrcLoc:
|
||||||
|
ptr = item->zoneBegin.srcloc;
|
||||||
|
SendSourceLocationPayload( ptr );
|
||||||
|
tracy_free( (void*)ptr );
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -414,10 +419,6 @@ bool Profiler::HandleServerQuery()
|
|||||||
case ServerQuerySourceLocation:
|
case ServerQuerySourceLocation:
|
||||||
SendSourceLocation( ptr );
|
SendSourceLocation( ptr );
|
||||||
break;
|
break;
|
||||||
case ServerQuerySourceLocationPayload:
|
|
||||||
SendSourceLocationPayload( ptr );
|
|
||||||
tracy_free( (void*)ptr );
|
|
||||||
break;
|
|
||||||
case ServerQueryPlotName:
|
case ServerQueryPlotName:
|
||||||
SendString( ptr, (const char*)ptr, QueueType::PlotName );
|
SendString( ptr, (const char*)ptr, QueueType::PlotName );
|
||||||
break;
|
break;
|
||||||
|
@ -22,7 +22,6 @@ enum ServerQuery : uint8_t
|
|||||||
ServerQueryString,
|
ServerQueryString,
|
||||||
ServerQueryThreadString,
|
ServerQueryThreadString,
|
||||||
ServerQuerySourceLocation,
|
ServerQuerySourceLocation,
|
||||||
ServerQuerySourceLocationPayload,
|
|
||||||
ServerQueryPlotName,
|
ServerQueryPlotName,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -615,6 +615,9 @@ void View::ProcessZoneBegin( const QueueZoneBegin& ev )
|
|||||||
|
|
||||||
void View::ProcessZoneBeginAllocSrcLoc( const QueueZoneBegin& ev )
|
void View::ProcessZoneBeginAllocSrcLoc( const QueueZoneBegin& ev )
|
||||||
{
|
{
|
||||||
|
auto it = m_pendingSourceLocationPayload.find( ev.srcloc );
|
||||||
|
assert( it != m_pendingSourceLocationPayload.end() );
|
||||||
|
|
||||||
auto zone = m_slab.AllocInit<ZoneEvent>();
|
auto zone = m_slab.AllocInit<ZoneEvent>();
|
||||||
|
|
||||||
zone->start = ev.time * m_timerMul;
|
zone->start = ev.time * m_timerMul;
|
||||||
@ -623,13 +626,14 @@ void View::ProcessZoneBeginAllocSrcLoc( const QueueZoneBegin& ev )
|
|||||||
assert( ev.cpu == 0xFFFFFFFF || ev.cpu <= std::numeric_limits<int8_t>::max() );
|
assert( ev.cpu == 0xFFFFFFFF || ev.cpu <= std::numeric_limits<int8_t>::max() );
|
||||||
zone->cpu_start = ev.cpu == 0xFFFFFFFF ? -1 : (int8_t)ev.cpu;
|
zone->cpu_start = ev.cpu == 0xFFFFFFFF ? -1 : (int8_t)ev.cpu;
|
||||||
zone->text = -1;
|
zone->text = -1;
|
||||||
|
zone->srcloc = it->second;
|
||||||
CheckSourceLocationPayload( ev.srcloc, zone );
|
|
||||||
|
|
||||||
std::unique_lock<std::mutex> lock( m_lock );
|
std::unique_lock<std::mutex> lock( m_lock );
|
||||||
NewZone( zone, ev.thread );
|
NewZone( zone, ev.thread );
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
m_zoneStack[ev.thread].push_back( zone );
|
m_zoneStack[ev.thread].push_back( zone );
|
||||||
|
|
||||||
|
m_pendingSourceLocationPayload.erase( it );
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::ProcessZoneEnd( const QueueZoneEnd& ev )
|
void View::ProcessZoneEnd( const QueueZoneEnd& ev )
|
||||||
@ -854,14 +858,6 @@ void View::CheckSourceLocation( uint64_t ptr )
|
|||||||
ServerQuery( ServerQuerySourceLocation, ptr );
|
ServerQuery( ServerQuerySourceLocation, ptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::CheckSourceLocationPayload( uint64_t ptr, ZoneEvent* dst )
|
|
||||||
{
|
|
||||||
assert( m_pendingSourceLocationPayload.find( ptr ) == m_pendingSourceLocationPayload.end() );
|
|
||||||
m_pendingSourceLocationPayload.emplace( ptr, dst );
|
|
||||||
|
|
||||||
ServerQuery( ServerQuerySourceLocationPayload, ptr );
|
|
||||||
}
|
|
||||||
|
|
||||||
void View::AddString( uint64_t ptr, char* str, size_t sz )
|
void View::AddString( uint64_t ptr, char* str, size_t sz )
|
||||||
{
|
{
|
||||||
assert( m_strings.find( ptr ) == m_strings.end() );
|
assert( m_strings.find( ptr ) == m_strings.end() );
|
||||||
@ -932,8 +928,7 @@ void View::AddSourceLocationPayload( uint64_t ptr, char* data, size_t sz )
|
|||||||
{
|
{
|
||||||
const auto start = data;
|
const auto start = data;
|
||||||
|
|
||||||
auto pit = m_pendingSourceLocationPayload.find( ptr );
|
assert( m_pendingSourceLocationPayload.find( ptr ) == m_pendingSourceLocationPayload.end() );
|
||||||
assert( pit != m_pendingSourceLocationPayload.end() );
|
|
||||||
|
|
||||||
uint32_t color, line;
|
uint32_t color, line;
|
||||||
memcpy( &color, data, 4 );
|
memcpy( &color, data, 4 );
|
||||||
@ -955,17 +950,14 @@ void View::AddSourceLocationPayload( uint64_t ptr, char* data, size_t sz )
|
|||||||
memcpy( slptr, &srcloc, sizeof( srcloc ) );
|
memcpy( slptr, &srcloc, sizeof( srcloc ) );
|
||||||
uint32_t idx = m_sourceLocationPayload.size();
|
uint32_t idx = m_sourceLocationPayload.size();
|
||||||
m_sourceLocationPayloadMap.emplace( slptr, idx );
|
m_sourceLocationPayloadMap.emplace( slptr, idx );
|
||||||
|
m_pendingSourceLocationPayload.emplace( ptr, -int32_t( idx + 1 ) );
|
||||||
std::unique_lock<std::mutex> lock( m_lock );
|
std::unique_lock<std::mutex> lock( m_lock );
|
||||||
m_sourceLocationPayload.push_back( slptr );
|
m_sourceLocationPayload.push_back( slptr );
|
||||||
pit->second->srcloc = -int32_t( idx + 1 );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock( m_lock );
|
m_pendingSourceLocationPayload.emplace( ptr, -int32_t( it->second + 1 ) );
|
||||||
pit->second->srcloc = -int32_t( it->second + 1 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pendingSourceLocationPayload.erase( pit );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t View::ShrinkSourceLocation( uint64_t srcloc )
|
uint32_t View::ShrinkSourceLocation( uint64_t srcloc )
|
||||||
|
@ -143,7 +143,6 @@ private:
|
|||||||
void CheckString( uint64_t ptr );
|
void CheckString( uint64_t ptr );
|
||||||
void CheckThreadString( uint64_t id );
|
void CheckThreadString( uint64_t id );
|
||||||
void CheckSourceLocation( uint64_t ptr );
|
void CheckSourceLocation( uint64_t ptr );
|
||||||
void CheckSourceLocationPayload( uint64_t ptr, ZoneEvent* dst );
|
|
||||||
|
|
||||||
void AddString( uint64_t ptr, char* str, size_t sz );
|
void AddString( uint64_t ptr, char* str, size_t sz );
|
||||||
void AddThreadString( uint64_t id, char* str, size_t sz );
|
void AddThreadString( uint64_t id, char* str, size_t sz );
|
||||||
@ -258,7 +257,7 @@ private:
|
|||||||
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;
|
||||||
std::unordered_map<uint64_t, PlotData*> m_pendingPlots;
|
std::unordered_map<uint64_t, PlotData*> m_pendingPlots;
|
||||||
std::unordered_map<uint64_t, uint32_t> m_sourceLocationShrink;
|
std::unordered_map<uint64_t, uint32_t> m_sourceLocationShrink;
|
||||||
std::unordered_map<uint64_t, ZoneEvent*> m_pendingSourceLocationPayload;
|
std::unordered_map<uint64_t, int32_t> m_pendingSourceLocationPayload;
|
||||||
|
|
||||||
Slab<64*1024*1024> m_slab;
|
Slab<64*1024*1024> m_slab;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user