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

View File

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

View File

@ -416,9 +416,6 @@ void View::Process( const QueueItem& ev )
case QueueType::ZoneName:
ProcessZoneName( ev.zoneName );
break;
case QueueType::LockAnnounce:
ProcessLockAnnounce( ev.lockAnnounce );
break;
case QueueType::LockWait:
ProcessLockWait( ev.lockWait );
break;
@ -500,13 +497,6 @@ void View::ProcessZoneName( const QueueZoneName& ev )
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 )
{
auto lev = m_slab.Alloc<LockEvent>();
@ -514,8 +504,19 @@ void View::ProcessLockWait( const QueueLockWait& ev )
lev->type = LockEvent::Type::Wait;
lev->srcloc = 0;
auto it = m_lockMap.find( ev.id );
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 )

View File

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