1
0
mirror of https://github.com/wolfpld/tracy synced 2025-05-01 13:13:53 +00:00

Pack LockEvent data, saving one byte.

This commit is contained in:
Bartosz Taudul 2017-10-29 16:49:22 +01:00
parent 97880a89ae
commit 9524b6447e
2 changed files with 10 additions and 8 deletions

View File

@ -43,10 +43,10 @@ struct LockEvent
int64_t time; int64_t time;
uint32_t srcloc; uint32_t srcloc;
uint64_t waitList; uint64_t waitList;
uint8_t thread; uint16_t thread : 6;
uint8_t lockingThread; uint16_t lockingThread : 6;
uint16_t type : 2;
uint8_t lockCount; uint8_t lockCount;
Type type;
}; };
enum { LockEventSize = sizeof( LockEvent ) }; enum { LockEventSize = sizeof( LockEvent ) };

View File

@ -721,7 +721,7 @@ void View::ProcessLockWait( const QueueLockWait& ev )
{ {
auto lev = m_slab.Alloc<LockEvent>(); auto lev = m_slab.Alloc<LockEvent>();
lev->time = ev.time * m_timerMul; lev->time = ev.time * m_timerMul;
lev->type = LockEvent::Type::Wait; lev->type = (uint8_t)LockEvent::Type::Wait;
lev->srcloc = 0; lev->srcloc = 0;
auto it = m_lockMap.find( ev.id ); auto it = m_lockMap.find( ev.id );
@ -746,7 +746,7 @@ void View::ProcessLockObtain( const QueueLockObtain& ev )
{ {
auto lev = m_slab.Alloc<LockEvent>(); auto lev = m_slab.Alloc<LockEvent>();
lev->time = ev.time * m_timerMul; lev->time = ev.time * m_timerMul;
lev->type = LockEvent::Type::Obtain; lev->type = (uint8_t)LockEvent::Type::Obtain;
lev->srcloc = 0; lev->srcloc = 0;
std::lock_guard<std::mutex> lock( m_lock ); std::lock_guard<std::mutex> lock( m_lock );
@ -757,7 +757,7 @@ void View::ProcessLockRelease( const QueueLockRelease& ev )
{ {
auto lev = m_slab.Alloc<LockEvent>(); auto lev = m_slab.Alloc<LockEvent>();
lev->time = ev.time * m_timerMul; lev->time = ev.time * m_timerMul;
lev->type = LockEvent::Type::Release; lev->type = (uint8_t)LockEvent::Type::Release;
lev->srcloc = 0; lev->srcloc = 0;
std::lock_guard<std::mutex> lock( m_lock ); std::lock_guard<std::mutex> lock( m_lock );
@ -780,7 +780,7 @@ void View::ProcessLockMark( const QueueLockMark& ev )
--it; --it;
if( (*it)->thread == thread ) if( (*it)->thread == thread )
{ {
switch( (*it)->type ) switch( (LockEvent::Type)(*it)->type )
{ {
case LockEvent::Type::Obtain: case LockEvent::Type::Obtain:
case LockEvent::Type::Wait: case LockEvent::Type::Wait:
@ -1071,6 +1071,7 @@ void View::InsertLockEvent( LockMap& lockmap, LockEvent* lev, uint64_t thread )
lockmap.threadList.emplace_back( thread ); lockmap.threadList.emplace_back( thread );
} }
lev->thread = it->second; lev->thread = it->second;
assert( lev->thread == it->second );
auto& timeline = lockmap.timeline; auto& timeline = lockmap.timeline;
if( timeline.empty() || timeline.back()->time < lev->time ) if( timeline.empty() || timeline.back()->time < lev->time )
{ {
@ -1096,7 +1097,7 @@ void View::UpdateLockCount( LockMap& lockmap, size_t pos )
while( pos != end ) while( pos != end )
{ {
const auto tbit = uint64_t( 1 ) << timeline[pos]->thread; const auto tbit = uint64_t( 1 ) << timeline[pos]->thread;
switch( timeline[pos]->type ) switch( (LockEvent::Type)timeline[pos]->type )
{ {
case LockEvent::Type::Wait: case LockEvent::Type::Wait:
waitList |= tbit; waitList |= tbit;
@ -1118,6 +1119,7 @@ void View::UpdateLockCount( LockMap& lockmap, size_t pos )
timeline[pos]->lockingThread = lockingThread; timeline[pos]->lockingThread = lockingThread;
timeline[pos]->waitList = waitList; timeline[pos]->waitList = waitList;
timeline[pos]->lockCount = lockCount; timeline[pos]->lockCount = lockCount;
assert( timeline[pos]->lockingThread == lockingThread );
pos++; pos++;
} }
} }