mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Process fiber entry and leave events.
This commit is contained in:
parent
b4e4c05088
commit
211b202d8e
@ -4701,6 +4701,12 @@ bool Worker::Process( const QueueItem& ev )
|
||||
case QueueType::MemNamePayload:
|
||||
ProcessMemNamePayload( ev.memName );
|
||||
break;
|
||||
case QueueType::FiberEnter:
|
||||
ProcessFiberEnter( ev.fiberEnter );
|
||||
break;
|
||||
case QueueType::FiberLeave:
|
||||
ProcessFiberLeave( ev.fiberLeave );
|
||||
break;
|
||||
default:
|
||||
assert( false );
|
||||
break;
|
||||
@ -6705,6 +6711,60 @@ void Worker::ProcessMemNamePayload( const QueueMemNamePayload& ev )
|
||||
m_memNamePayload = ev.name;
|
||||
}
|
||||
|
||||
void Worker::ProcessFiberEnter( const QueueFiberEnter& ev )
|
||||
{
|
||||
const auto refTime = m_refTimeThread + ev.time;
|
||||
m_refTimeThread = refTime;
|
||||
const auto t = TscTime( refTime - m_data.baseTime );
|
||||
if( m_data.lastTime < t ) m_data.lastTime = t;
|
||||
|
||||
uint64_t tid;
|
||||
auto it = m_data.fiberToThreadMap.find( ev.fiber );
|
||||
if( it == m_data.fiberToThreadMap.end() )
|
||||
{
|
||||
tid = ( uint64_t(1) << 32 ) | m_data.fiberToThreadMap.size();
|
||||
m_data.fiberToThreadMap.emplace( ev.fiber, tid );
|
||||
NewThread( tid, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
tid = it->second;
|
||||
}
|
||||
|
||||
if( m_data.threadToFiberMap.find( ev.thread ) != m_data.threadToFiberMap.end() )
|
||||
{
|
||||
FiberEnterFailure();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_data.threadToFiberMap.emplace( ev.thread, tid );
|
||||
}
|
||||
|
||||
m_data.threadDataLast.first = 0;
|
||||
m_threadCtxData = nullptr;
|
||||
}
|
||||
|
||||
void Worker::ProcessFiberLeave( const QueueFiberLeave& ev )
|
||||
{
|
||||
const auto refTime = m_refTimeThread + ev.time;
|
||||
m_refTimeThread = refTime;
|
||||
const auto t = TscTime( refTime - m_data.baseTime );
|
||||
if( m_data.lastTime < t ) m_data.lastTime = t;
|
||||
|
||||
auto it = m_data.threadToFiberMap.find( ev.thread );
|
||||
if( it == m_data.threadToFiberMap.end() )
|
||||
{
|
||||
FiberLeaveFailure();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_data.threadToFiberMap.erase( it );
|
||||
}
|
||||
|
||||
m_data.threadDataLast.first = 0;
|
||||
m_threadCtxData = nullptr;
|
||||
}
|
||||
|
||||
void Worker::MemAllocChanged( uint64_t memname, MemData& memdata, int64_t time )
|
||||
{
|
||||
const auto val = (double)memdata.usage;
|
||||
|
@ -364,6 +364,7 @@ private:
|
||||
|
||||
unordered_flat_map<uint64_t, HwSampleData> hwSamples;
|
||||
|
||||
unordered_flat_map<uint64_t, uint64_t> fiberToThreadMap;
|
||||
unordered_flat_map<uint64_t, uint64_t> threadToFiberMap;
|
||||
};
|
||||
|
||||
@ -707,6 +708,8 @@ private:
|
||||
tracy_force_inline void ProcessParamSetup( const QueueParamSetup& ev );
|
||||
tracy_force_inline void ProcessCpuTopology( const QueueCpuTopology& ev );
|
||||
tracy_force_inline void ProcessMemNamePayload( const QueueMemNamePayload& ev );
|
||||
tracy_force_inline void ProcessFiberEnter( const QueueFiberEnter& ev );
|
||||
tracy_force_inline void ProcessFiberLeave( const QueueFiberLeave& ev );
|
||||
|
||||
tracy_force_inline ZoneEvent* AllocZoneEvent();
|
||||
tracy_force_inline void ProcessZoneBeginImpl( ZoneEvent* zone, const QueueZoneBegin& ev );
|
||||
|
Loading…
Reference in New Issue
Block a user