mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-26 16:04:34 +00:00
Reintroduce lock announce events.
This commit is contained in:
parent
ea604d484d
commit
3567d7edd8
@ -18,9 +18,18 @@ class Lockable
|
||||
public:
|
||||
tracy_force_inline Lockable( const SourceLocation* srcloc )
|
||||
: m_id( s_lockCounter.fetch_add( 1, std::memory_order_relaxed ) )
|
||||
, m_lckloc( (uint64_t)srcloc )
|
||||
{
|
||||
assert( m_id != std::numeric_limits<uint32_t>::max() );
|
||||
|
||||
Magic magic;
|
||||
auto& token = s_token.ptr;
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<moodycamel::CanAlloc>( magic );
|
||||
item->hdr.type = QueueType::LockAnnounce;
|
||||
item->lockAnnounce.id = m_id;
|
||||
item->lockAnnounce.lckloc = (uint64_t)srcloc;
|
||||
item->lockAnnounce.type = LockType::Lockable;
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
}
|
||||
|
||||
Lockable( const Lockable& ) = delete;
|
||||
@ -38,7 +47,6 @@ public:
|
||||
item->lockWait.id = m_id;
|
||||
item->lockWait.thread = thread;
|
||||
item->lockWait.time = Profiler::GetTime();
|
||||
item->lockWait.lckloc = m_lckloc;
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
}
|
||||
|
||||
@ -106,7 +114,6 @@ public:
|
||||
private:
|
||||
T m_lockable;
|
||||
uint32_t m_id;
|
||||
uint64_t m_lckloc;
|
||||
};
|
||||
|
||||
};
|
||||
|
@ -16,6 +16,7 @@ enum class QueueType : uint8_t
|
||||
ZoneEnd,
|
||||
FrameMarkMsg,
|
||||
SourceLocation,
|
||||
LockAnnounce,
|
||||
LockWait,
|
||||
LockObtain,
|
||||
LockRelease,
|
||||
@ -79,12 +80,23 @@ struct QueueZoneText
|
||||
uint64_t text; // ptr
|
||||
};
|
||||
|
||||
enum class LockType : uint8_t
|
||||
{
|
||||
Lockable
|
||||
};
|
||||
|
||||
struct QueueLockAnnounce
|
||||
{
|
||||
uint32_t id;
|
||||
uint64_t lckloc; // ptr
|
||||
LockType type;
|
||||
};
|
||||
|
||||
struct QueueLockWait
|
||||
{
|
||||
uint32_t id;
|
||||
int64_t time;
|
||||
uint64_t thread;
|
||||
uint64_t lckloc; // ptr
|
||||
};
|
||||
|
||||
struct QueueLockObtain
|
||||
@ -190,6 +202,7 @@ struct QueueItem
|
||||
QueueFrameMark frameMark;
|
||||
QueueSourceLocation srcloc;
|
||||
QueueZoneText zoneText;
|
||||
QueueLockAnnounce lockAnnounce;
|
||||
QueueLockWait lockWait;
|
||||
QueueLockObtain lockObtain;
|
||||
QueueLockRelease lockRelease;
|
||||
@ -218,6 +231,7 @@ static const size_t QueueDataSize[] = {
|
||||
sizeof( QueueHeader ) + sizeof( QueueZoneEnd ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueFrameMark ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueSourceLocation ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueLockAnnounce ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueLockWait ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueLockObtain ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueLockRelease ),
|
||||
|
@ -177,7 +177,9 @@ struct LockMap
|
||||
Vector<LockEvent*> timeline;
|
||||
std::unordered_map<uint64_t, uint8_t> threadMap;
|
||||
std::vector<uint64_t> threadList;
|
||||
LockType type;
|
||||
bool visible;
|
||||
bool valid;
|
||||
};
|
||||
|
||||
struct LockHighlight
|
||||
|
@ -296,6 +296,8 @@ View::View( FileRead& f )
|
||||
uint64_t tsz;
|
||||
f.Read( &id, sizeof( id ) );
|
||||
f.Read( &lockmap.srcloc, sizeof( lockmap.srcloc ) );
|
||||
f.Read( &lockmap.type, sizeof( lockmap.type ) );
|
||||
f.Read( &lockmap.valid, sizeof( lockmap.valid ) );
|
||||
f.Read( &tsz, sizeof( tsz ) );
|
||||
for( uint64_t i=0; i<tsz; i++ )
|
||||
{
|
||||
@ -588,6 +590,9 @@ void View::Process( const QueueItem& ev )
|
||||
case QueueType::ZoneText:
|
||||
ProcessZoneText( ev.zoneText );
|
||||
break;
|
||||
case QueueType::LockAnnounce:
|
||||
ProcessLockAnnounce( ev.lockAnnounce );
|
||||
break;
|
||||
case QueueType::LockWait:
|
||||
ProcessLockWait( ev.lockWait );
|
||||
break;
|
||||
@ -713,6 +718,28 @@ void View::ProcessZoneText( const QueueZoneText& ev )
|
||||
m_pendingCustomStrings.erase( it );
|
||||
}
|
||||
|
||||
void View::ProcessLockAnnounce( const QueueLockAnnounce& ev )
|
||||
{
|
||||
auto it = m_lockMap.find( ev.id );
|
||||
if( it == m_lockMap.end() )
|
||||
{
|
||||
LockMap lm;
|
||||
lm.srcloc = ShrinkSourceLocation( ev.lckloc );
|
||||
lm.type = ev.type;
|
||||
lm.visible = true;
|
||||
lm.valid = true;
|
||||
m_lockMap.emplace( ev.id, std::move( lm ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
it->second.srcloc = ShrinkSourceLocation( ev.lckloc );
|
||||
it->second.type = ev.type;
|
||||
it->second.visible = true;
|
||||
it->second.valid = true;
|
||||
}
|
||||
CheckSourceLocation( ev.lckloc );
|
||||
}
|
||||
|
||||
void View::ProcessLockWait( const QueueLockWait& ev )
|
||||
{
|
||||
auto lev = m_slab.Alloc<LockEvent>();
|
||||
@ -724,16 +751,10 @@ void View::ProcessLockWait( const QueueLockWait& ev )
|
||||
if( it == m_lockMap.end() )
|
||||
{
|
||||
LockMap lm;
|
||||
lm.srcloc = ShrinkSourceLocation( ev.lckloc );
|
||||
lm.visible = true;
|
||||
lm.valid = false;
|
||||
it = m_lockMap.emplace( ev.id, std::move( lm ) ).first;
|
||||
CheckSourceLocation( ev.lckloc );
|
||||
}
|
||||
else if( it->second.srcloc == 0 )
|
||||
{
|
||||
it->second.srcloc = ShrinkSourceLocation( ev.lckloc );
|
||||
CheckSourceLocation( ev.lckloc );
|
||||
}
|
||||
|
||||
InsertLockEvent( it->second, lev, ev.thread );
|
||||
}
|
||||
|
||||
@ -744,6 +765,7 @@ void View::ProcessLockObtain( const QueueLockObtain& ev )
|
||||
lev->type = (uint8_t)LockEvent::Type::Obtain;
|
||||
lev->srcloc = 0;
|
||||
|
||||
assert( m_lockMap.find( ev.id ) != m_lockMap.end() );
|
||||
InsertLockEvent( m_lockMap[ev.id], lev, ev.thread );
|
||||
}
|
||||
|
||||
@ -754,6 +776,7 @@ void View::ProcessLockRelease( const QueueLockRelease& ev )
|
||||
lev->type = (uint8_t)LockEvent::Type::Release;
|
||||
lev->srcloc = 0;
|
||||
|
||||
assert( m_lockMap.find( ev.id ) != m_lockMap.end() );
|
||||
InsertLockEvent( m_lockMap[ev.id], lev, ev.thread );
|
||||
}
|
||||
|
||||
@ -2859,7 +2882,7 @@ int View::DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos,
|
||||
for( auto& v : m_lockMap )
|
||||
{
|
||||
auto& lockmap = v.second;
|
||||
if( !lockmap.visible ) continue;
|
||||
if( !lockmap.visible || !lockmap.valid ) continue;
|
||||
|
||||
auto it = lockmap.threadMap.find( tid );
|
||||
if( it == lockmap.threadMap.end() ) continue;
|
||||
@ -3597,9 +3620,12 @@ void View::DrawOptions()
|
||||
ImGui::Indent( tw );
|
||||
for( auto& l : m_lockMap )
|
||||
{
|
||||
char buf[1024];
|
||||
sprintf( buf, "%" PRIu32 ": %s", l.first, GetString( GetSourceLocation( l.second.srcloc ).function ) );
|
||||
ImGui::Checkbox( buf , &l.second.visible );
|
||||
if( l.second.valid )
|
||||
{
|
||||
char buf[1024];
|
||||
sprintf( buf, "%" PRIu32 ": %s", l.first, GetString( GetSourceLocation( l.second.srcloc ).function ) );
|
||||
ImGui::Checkbox( buf , &l.second.visible );
|
||||
}
|
||||
}
|
||||
ImGui::Unindent( tw );
|
||||
ImGui::Separator();
|
||||
@ -3951,6 +3977,8 @@ void View::Write( FileWrite& f )
|
||||
{
|
||||
f.Write( &v.first, sizeof( v.first ) );
|
||||
f.Write( &v.second.srcloc, sizeof( v.second.srcloc ) );
|
||||
f.Write( &v.second.type, sizeof( v.second.type ) );
|
||||
f.Write( &v.second.valid, sizeof( v.second.valid ) );
|
||||
sz = v.second.threadList.size();
|
||||
f.Write( &sz, sizeof( sz ) );
|
||||
for( auto& t : v.second.threadList )
|
||||
|
@ -74,6 +74,7 @@ private:
|
||||
tracy_force_inline void ProcessZoneEnd( const QueueZoneEnd& ev );
|
||||
tracy_force_inline void ProcessFrameMark( const QueueFrameMark& ev );
|
||||
tracy_force_inline void ProcessZoneText( const QueueZoneText& ev );
|
||||
tracy_force_inline void ProcessLockAnnounce( const QueueLockAnnounce& ev );
|
||||
tracy_force_inline void ProcessLockWait( const QueueLockWait& ev );
|
||||
tracy_force_inline void ProcessLockObtain( const QueueLockObtain& ev );
|
||||
tracy_force_inline void ProcessLockRelease( const QueueLockRelease& ev );
|
||||
|
Loading…
Reference in New Issue
Block a user