1
0
mirror of https://github.com/wolfpld/tracy synced 2025-05-02 21:53:52 +00:00

Remove lock announce message.

This removes problem with static initialization order of mutices vs
tracy.

Lock source location is now transferred in lock wait message.
This commit is contained in:
Bartosz Taudul 2017-10-12 20:14:17 +02:00
parent c42106f4ff
commit 737671adbf
4 changed files with 16 additions and 29 deletions

View File

@ -17,15 +17,8 @@ class Lockable
public: public:
tracy_force_inline Lockable( const SourceLocation* srcloc ) tracy_force_inline Lockable( const SourceLocation* srcloc )
: m_id( s_lockCounter.fetch_add( 1, std::memory_order_relaxed ) ) : m_id( s_lockCounter.fetch_add( 1, std::memory_order_relaxed ) )
, m_lckloc( (uint64_t)srcloc )
{ {
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.srcloc = (uint64_t)srcloc;
tail.store( magic + 1, std::memory_order_release );
} }
Lockable( const Lockable& ) = delete; Lockable( const Lockable& ) = delete;
@ -44,6 +37,7 @@ public:
item->lockWait.id = m_id; item->lockWait.id = m_id;
item->lockWait.thread = thread; item->lockWait.thread = thread;
item->lockWait.time = Profiler::GetTime( cpu ); item->lockWait.time = Profiler::GetTime( cpu );
item->lockWait.lckloc = m_lckloc;
tail.store( magic + 1, std::memory_order_release ); tail.store( magic + 1, std::memory_order_release );
} }
@ -113,6 +107,7 @@ public:
private: private:
T m_lockable; T m_lockable;
uint64_t m_id; uint64_t m_id;
uint64_t m_lckloc;
}; };
}; };

View File

@ -17,7 +17,6 @@ enum class QueueType : uint8_t
SourceLocation, SourceLocation,
ZoneText, ZoneText,
ZoneName, ZoneName,
LockAnnounce,
LockWait, LockWait,
LockObtain, LockObtain,
LockRelease, LockRelease,
@ -73,17 +72,12 @@ struct QueueZoneName
uint64_t name; // ptr uint64_t name; // ptr
}; };
struct QueueLockAnnounce
{
uint64_t id;
uint64_t srcloc; // ptr
};
struct QueueLockWait struct QueueLockWait
{ {
uint64_t id; uint64_t id;
int64_t time; int64_t time;
uint64_t thread; uint64_t thread;
uint64_t lckloc; // ptr
}; };
struct QueueLockObtain struct QueueLockObtain
@ -128,7 +122,6 @@ struct QueueItem
QueueSourceLocation srcloc; QueueSourceLocation srcloc;
QueueZoneText zoneText; QueueZoneText zoneText;
QueueZoneName zoneName; QueueZoneName zoneName;
QueueLockAnnounce lockAnnounce;
QueueLockWait lockWait; QueueLockWait lockWait;
QueueLockObtain lockObtain; QueueLockObtain lockObtain;
QueueLockRelease lockRelease; QueueLockRelease lockRelease;
@ -150,7 +143,6 @@ static const size_t QueueDataSize[] = {
sizeof( QueueHeader ) + sizeof( QueueSourceLocation ), sizeof( QueueHeader ) + sizeof( QueueSourceLocation ),
sizeof( QueueHeader ) + sizeof( QueueZoneText ), sizeof( QueueHeader ) + sizeof( QueueZoneText ),
sizeof( QueueHeader ) + sizeof( QueueZoneName ), sizeof( QueueHeader ) + sizeof( QueueZoneName ),
sizeof( QueueHeader ) + sizeof( QueueLockAnnounce ),
sizeof( QueueHeader ) + sizeof( QueueLockWait ), sizeof( QueueHeader ) + sizeof( QueueLockWait ),
sizeof( QueueHeader ) + sizeof( QueueLockObtain ), sizeof( QueueHeader ) + sizeof( QueueLockObtain ),
sizeof( QueueHeader ) + sizeof( QueueLockRelease ), sizeof( QueueHeader ) + sizeof( QueueLockRelease ),

View File

@ -416,9 +416,6 @@ void View::Process( const QueueItem& ev )
case QueueType::ZoneName: case QueueType::ZoneName:
ProcessZoneName( ev.zoneName ); ProcessZoneName( ev.zoneName );
break; break;
case QueueType::LockAnnounce:
ProcessLockAnnounce( ev.lockAnnounce );
break;
case QueueType::LockWait: case QueueType::LockWait:
ProcessLockWait( ev.lockWait ); ProcessLockWait( ev.lockWait );
break; break;
@ -500,13 +497,6 @@ void View::ProcessZoneName( const QueueZoneName& ev )
GetTextData( *zone )->zoneName = ev.name; GetTextData( *zone )->zoneName = ev.name;
} }
void View::ProcessLockAnnounce( const QueueLockAnnounce& ev )
{
CheckSourceLocation( ev.srcloc );
std::lock_guard<std::mutex> lock( m_lock );
m_lockMap[ev.id].srcloc = ev.srcloc;
}
void View::ProcessLockWait( const QueueLockWait& ev ) void View::ProcessLockWait( const QueueLockWait& ev )
{ {
auto lev = m_slab.Alloc<LockEvent>(); auto lev = m_slab.Alloc<LockEvent>();
@ -514,8 +504,19 @@ void View::ProcessLockWait( const QueueLockWait& ev )
lev->type = LockEvent::Type::Wait; lev->type = LockEvent::Type::Wait;
lev->srcloc = 0; lev->srcloc = 0;
auto it = m_lockMap.find( ev.id );
std::lock_guard<std::mutex> lock( m_lock ); std::lock_guard<std::mutex> lock( m_lock );
InsertLockEvent( m_lockMap[ev.id], lev, ev.thread ); if( it == m_lockMap.end() )
{
it = m_lockMap.emplace( ev.id, LockMap { ev.lckloc } ).first;
CheckSourceLocation( ev.lckloc );
}
else if( it->second.srcloc == 0 )
{
it->second.srcloc = ev.lckloc;
CheckSourceLocation( ev.lckloc );
}
InsertLockEvent( it->second, lev, ev.thread );
} }
void View::ProcessLockObtain( const QueueLockObtain& ev ) void View::ProcessLockObtain( const QueueLockObtain& ev )

View File

@ -75,7 +75,6 @@ private:
void ProcessFrameMark( const QueueFrameMark& ev ); void ProcessFrameMark( const QueueFrameMark& ev );
void ProcessZoneText( const QueueZoneText& ev ); void ProcessZoneText( const QueueZoneText& ev );
void ProcessZoneName( const QueueZoneName& ev ); void ProcessZoneName( const QueueZoneName& ev );
void ProcessLockAnnounce( const QueueLockAnnounce& ev );
void ProcessLockWait( const QueueLockWait& ev ); void ProcessLockWait( const QueueLockWait& ev );
void ProcessLockObtain( const QueueLockObtain& ev ); void ProcessLockObtain( const QueueLockObtain& ev );
void ProcessLockRelease( const QueueLockRelease& ev ); void ProcessLockRelease( const QueueLockRelease& ev );