mirror of
https://github.com/wolfpld/tracy
synced 2025-04-29 20:33:52 +00:00
Store context switches.
This commit is contained in:
parent
90d26cb1b6
commit
419f74280d
@ -219,6 +219,18 @@ struct CrashEvent
|
|||||||
|
|
||||||
enum { CrashEventSize = sizeof( CrashEvent ) };
|
enum { CrashEventSize = sizeof( CrashEvent ) };
|
||||||
|
|
||||||
|
|
||||||
|
struct ContextSwitchData
|
||||||
|
{
|
||||||
|
int64_t start;
|
||||||
|
int64_t end;
|
||||||
|
uint8_t cpu;
|
||||||
|
int8_t reason;
|
||||||
|
int8_t state;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum { ContextSwitchDataSize = sizeof( ContextSwitchData ) };
|
||||||
|
|
||||||
#pragma pack()
|
#pragma pack()
|
||||||
|
|
||||||
|
|
||||||
@ -364,6 +376,11 @@ struct FrameImage
|
|||||||
uint8_t flip;
|
uint8_t flip;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ContextSwitch
|
||||||
|
{
|
||||||
|
Vector<ContextSwitchData> v;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -2611,6 +2611,9 @@ bool Worker::Process( const QueueItem& ev )
|
|||||||
case QueueType::SysTimeReport:
|
case QueueType::SysTimeReport:
|
||||||
ProcessSysTime( ev.sysTime );
|
ProcessSysTime( ev.sysTime );
|
||||||
break;
|
break;
|
||||||
|
case QueueType::ContextSwitch:
|
||||||
|
ProcessContextSwitch( ev.contextSwitch );
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
assert( false );
|
assert( false );
|
||||||
break;
|
break;
|
||||||
@ -3629,6 +3632,44 @@ void Worker::ProcessSysTime( const QueueSysTime& ev )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Worker::ProcessContextSwitch( const QueueContextSwitch& ev )
|
||||||
|
{
|
||||||
|
const auto time = TscTime( ev.time );
|
||||||
|
m_data.lastTime = std::max( m_data.lastTime, time );
|
||||||
|
|
||||||
|
if( ev.oldThread != 0 )
|
||||||
|
{
|
||||||
|
auto it = m_data.ctxSwitch.find( ev.oldThread );
|
||||||
|
if( it != m_data.ctxSwitch.end() )
|
||||||
|
{
|
||||||
|
auto& data = it->second->v;
|
||||||
|
assert( !data.empty() );
|
||||||
|
auto& item = data.back();
|
||||||
|
assert( item.start <= time );
|
||||||
|
item.end = time;
|
||||||
|
item.reason = ev.reason;
|
||||||
|
item.state = ev.state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( ev.newThread != 0 )
|
||||||
|
{
|
||||||
|
auto it = m_data.ctxSwitch.find( ev.newThread );
|
||||||
|
if( it == m_data.ctxSwitch.end() )
|
||||||
|
{
|
||||||
|
auto ctx = m_slab.AllocInit<ContextSwitch>();
|
||||||
|
it = m_data.ctxSwitch.emplace( ev.newThread, ctx ).first;
|
||||||
|
}
|
||||||
|
auto& data = it->second->v;
|
||||||
|
assert( data.empty() || (uint64_t)data.back().end <= time );
|
||||||
|
auto& item = data.push_next();
|
||||||
|
item.start = time;
|
||||||
|
item.end = -1;
|
||||||
|
item.cpu = ev.cpu;
|
||||||
|
item.reason = -1;
|
||||||
|
item.state = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Worker::MemAllocChanged( int64_t time )
|
void Worker::MemAllocChanged( int64_t time )
|
||||||
{
|
{
|
||||||
const auto val = (double)m_data.memory.usage;
|
const auto val = (double)m_data.memory.usage;
|
||||||
|
@ -194,6 +194,8 @@ private:
|
|||||||
Vector<StringRef> appInfo;
|
Vector<StringRef> appInfo;
|
||||||
|
|
||||||
CrashEvent crashEvent;
|
CrashEvent crashEvent;
|
||||||
|
|
||||||
|
flat_hash_map<uint64_t, ContextSwitch*, nohash<uint64_t>> ctxSwitch;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MbpsBlock
|
struct MbpsBlock
|
||||||
@ -412,6 +414,7 @@ private:
|
|||||||
tracy_force_inline void ProcessCallstackFrame( const QueueCallstackFrame& ev );
|
tracy_force_inline void ProcessCallstackFrame( const QueueCallstackFrame& ev );
|
||||||
tracy_force_inline void ProcessCrashReport( const QueueCrashReport& ev );
|
tracy_force_inline void ProcessCrashReport( const QueueCrashReport& ev );
|
||||||
tracy_force_inline void ProcessSysTime( const QueueSysTime& ev );
|
tracy_force_inline void ProcessSysTime( const QueueSysTime& ev );
|
||||||
|
tracy_force_inline void ProcessContextSwitch( const QueueContextSwitch& ev );
|
||||||
|
|
||||||
tracy_force_inline void ProcessZoneBeginImpl( ZoneEvent* zone, const QueueZoneBegin& ev );
|
tracy_force_inline void ProcessZoneBeginImpl( ZoneEvent* zone, const QueueZoneBegin& ev );
|
||||||
tracy_force_inline void ProcessZoneBeginAllocSrcLocImpl( ZoneEvent* zone, const QueueZoneBegin& ev );
|
tracy_force_inline void ProcessZoneBeginAllocSrcLocImpl( ZoneEvent* zone, const QueueZoneBegin& ev );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user