Shared lock events (still using old functionality).

This commit is contained in:
Bartosz Taudul 2017-12-10 22:04:49 +01:00
parent 1bddf76f8d
commit bcf2bf1c5c
4 changed files with 62 additions and 4 deletions

View File

@ -211,7 +211,7 @@ public:
auto& token = s_token.ptr;
auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<moodycamel::CanAlloc>( magic );
item->hdr.type = QueueType::LockWait;
item->hdr.type = QueueType::LockSharedWait;
item->lockWait.id = m_id;
item->lockWait.thread = thread;
item->lockWait.time = Profiler::GetTime();
@ -225,7 +225,7 @@ public:
auto& token = s_token.ptr;
auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<moodycamel::CanAlloc>( magic );
item->hdr.type = QueueType::LockObtain;
item->hdr.type = QueueType::LockSharedObtain;
item->lockObtain.id = m_id;
item->lockObtain.thread = thread;
item->lockObtain.time = Profiler::GetTime();
@ -241,7 +241,7 @@ public:
auto& token = s_token.ptr;
auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<moodycamel::CanAlloc>( magic );
item->hdr.type = QueueType::LockRelease;
item->hdr.type = QueueType::LockSharedRelease;
item->lockRelease.id = m_id;
item->lockRelease.thread = GetThreadHandle();
item->lockRelease.time = Profiler::GetTime();
@ -257,7 +257,7 @@ public:
auto& token = s_token.ptr;
auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<moodycamel::CanAlloc>( magic );
item->hdr.type = QueueType::LockObtain;
item->hdr.type = QueueType::LockSharedObtain;
item->lockObtain.id = (uint64_t)&m_lockable;
item->lockObtain.thread = GetThreadHandle();
item->lockObtain.time = Profiler::GetTime();

View File

@ -20,6 +20,9 @@ enum class QueueType : uint8_t
LockWait,
LockObtain,
LockRelease,
LockSharedWait,
LockSharedObtain,
LockSharedRelease,
LockMark,
PlotData,
MessageLiteral,
@ -236,6 +239,9 @@ static const size_t QueueDataSize[] = {
sizeof( QueueHeader ) + sizeof( QueueLockWait ),
sizeof( QueueHeader ) + sizeof( QueueLockObtain ),
sizeof( QueueHeader ) + sizeof( QueueLockRelease ),
sizeof( QueueHeader ) + sizeof( QueueLockWait ),
sizeof( QueueHeader ) + sizeof( QueueLockObtain ),
sizeof( QueueHeader ) + sizeof( QueueLockRelease ),
sizeof( QueueHeader ) + sizeof( QueueLockMark ),
sizeof( QueueHeader ) + sizeof( QueuePlotData ),
sizeof( QueueHeader ) + sizeof( QueueMessage ), // literal

View File

@ -602,6 +602,15 @@ void View::Process( const QueueItem& ev )
case QueueType::LockRelease:
ProcessLockRelease( ev.lockRelease );
break;
case QueueType::LockSharedWait:
ProcessLockSharedWait( ev.lockWait );
break;
case QueueType::LockSharedObtain:
ProcessLockSharedObtain( ev.lockObtain );
break;
case QueueType::LockSharedRelease:
ProcessLockSharedRelease( ev.lockRelease );
break;
case QueueType::LockMark:
ProcessLockMark( ev.lockMark );
break;
@ -780,6 +789,46 @@ void View::ProcessLockRelease( const QueueLockRelease& ev )
InsertLockEvent( m_lockMap[ev.id], lev, ev.thread );
}
void View::ProcessLockSharedWait( const QueueLockWait& ev )
{
auto lev = m_slab.Alloc<LockEvent>();
lev->time = ev.time * m_timerMul;
lev->type = (uint8_t)LockEvent::Type::Wait;
lev->srcloc = 0;
auto it = m_lockMap.find( ev.id );
if( it == m_lockMap.end() )
{
LockMap lm;
lm.valid = false;
it = m_lockMap.emplace( ev.id, std::move( lm ) ).first;
}
InsertLockEvent( it->second, lev, ev.thread );
}
void View::ProcessLockSharedObtain( const QueueLockObtain& ev )
{
auto lev = m_slab.Alloc<LockEvent>();
lev->time = ev.time * m_timerMul;
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 );
}
void View::ProcessLockSharedRelease( const QueueLockRelease& ev )
{
auto lev = m_slab.Alloc<LockEvent>();
lev->time = ev.time * m_timerMul;
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 );
}
void View::ProcessLockMark( const QueueLockMark& ev )
{
CheckSourceLocation( ev.srcloc );

View File

@ -78,6 +78,9 @@ private:
tracy_force_inline void ProcessLockWait( const QueueLockWait& ev );
tracy_force_inline void ProcessLockObtain( const QueueLockObtain& ev );
tracy_force_inline void ProcessLockRelease( const QueueLockRelease& ev );
tracy_force_inline void ProcessLockSharedWait( const QueueLockWait& ev );
tracy_force_inline void ProcessLockSharedObtain( const QueueLockObtain& ev );
tracy_force_inline void ProcessLockSharedRelease( const QueueLockRelease& ev );
tracy_force_inline void ProcessLockMark( const QueueLockMark& ev );
tracy_force_inline void ProcessPlotData( const QueuePlotData& ev );
tracy_force_inline void ProcessMessage( const QueueMessage& ev );