mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 10:41:50 +00:00
Track lock contention status.
This commit is contained in:
parent
a714cd4369
commit
0da1e8551f
@ -271,6 +271,7 @@ struct LockMap
|
|||||||
int64_t timeAnnounce;
|
int64_t timeAnnounce;
|
||||||
int64_t timeTerminate;
|
int64_t timeTerminate;
|
||||||
bool valid;
|
bool valid;
|
||||||
|
bool isContended;
|
||||||
|
|
||||||
TimeRange range[64];
|
TimeRange range[64];
|
||||||
};
|
};
|
||||||
|
@ -3145,7 +3145,7 @@ int View::DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos,
|
|||||||
{
|
{
|
||||||
const auto& lockmap = *v.second;
|
const auto& lockmap = *v.second;
|
||||||
if( !lockmap.valid || !Vis( &lockmap ).visible ) continue;
|
if( !lockmap.valid || !Vis( &lockmap ).visible ) continue;
|
||||||
if( m_onlyContendedLocks && lockmap.threadList.size() == 1 && m_lockInfoWindow != v.first ) continue;
|
if( m_onlyContendedLocks && ( lockmap.threadList.size() == 1 || !lockmap.isContended ) && m_lockInfoWindow != v.first ) continue;
|
||||||
|
|
||||||
auto it = lockmap.threadMap.find( tid );
|
auto it = lockmap.threadMap.find( tid );
|
||||||
if( it == lockmap.threadMap.end() ) continue;
|
if( it == lockmap.threadMap.end() ) continue;
|
||||||
|
@ -62,6 +62,7 @@ static const int CurrentVersion = FileVersion( Version::Major, Version::Minor, V
|
|||||||
static void UpdateLockCountLockable( LockMap& lockmap, size_t pos )
|
static void UpdateLockCountLockable( LockMap& lockmap, size_t pos )
|
||||||
{
|
{
|
||||||
auto& timeline = lockmap.timeline;
|
auto& timeline = lockmap.timeline;
|
||||||
|
bool isContended = lockmap.isContended;
|
||||||
uint8_t lockingThread;
|
uint8_t lockingThread;
|
||||||
uint8_t lockCount;
|
uint8_t lockCount;
|
||||||
uint64_t waitList;
|
uint64_t waitList;
|
||||||
@ -107,13 +108,17 @@ static void UpdateLockCountLockable( LockMap& lockmap, size_t pos )
|
|||||||
tl.lockingThread = lockingThread;
|
tl.lockingThread = lockingThread;
|
||||||
tl.waitList = waitList;
|
tl.waitList = waitList;
|
||||||
tl.lockCount = lockCount;
|
tl.lockCount = lockCount;
|
||||||
|
if( !isContended ) isContended = lockCount != 0 && waitList != 0;
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lockmap.isContended = isContended;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void UpdateLockCountSharedLockable( LockMap& lockmap, size_t pos )
|
static void UpdateLockCountSharedLockable( LockMap& lockmap, size_t pos )
|
||||||
{
|
{
|
||||||
auto& timeline = lockmap.timeline;
|
auto& timeline = lockmap.timeline;
|
||||||
|
bool isContended = lockmap.isContended;
|
||||||
uint8_t lockingThread;
|
uint8_t lockingThread;
|
||||||
uint8_t lockCount;
|
uint8_t lockCount;
|
||||||
uint64_t waitShared;
|
uint64_t waitShared;
|
||||||
@ -184,8 +189,11 @@ static void UpdateLockCountSharedLockable( LockMap& lockmap, size_t pos )
|
|||||||
tl.waitList = waitList;
|
tl.waitList = waitList;
|
||||||
tlp->sharedList = sharedList;
|
tlp->sharedList = sharedList;
|
||||||
tl.lockCount = lockCount;
|
tl.lockCount = lockCount;
|
||||||
|
if( !isContended ) isContended = ( lockCount != 0 && ( waitList != 0 || waitShared != 0 ) ) || ( sharedList != 0 && waitList != 0 );
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lockmap.isContended = isContended;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void UpdateLockCount( LockMap& lockmap, size_t pos )
|
static inline void UpdateLockCount( LockMap& lockmap, size_t pos )
|
||||||
@ -584,6 +592,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
|
|||||||
f.Read( lockmap.srcloc );
|
f.Read( lockmap.srcloc );
|
||||||
f.Read( lockmap.type );
|
f.Read( lockmap.type );
|
||||||
f.Read( lockmap.valid );
|
f.Read( lockmap.valid );
|
||||||
|
lockmap.isContended = false;
|
||||||
if( fileVer >= FileVersion( 0, 4, 1 ) )
|
if( fileVer >= FileVersion( 0, 4, 1 ) )
|
||||||
{
|
{
|
||||||
f.Read2( lockmap.timeAnnounce, lockmap.timeTerminate );
|
f.Read2( lockmap.timeAnnounce, lockmap.timeTerminate );
|
||||||
@ -2886,6 +2895,7 @@ void Worker::ProcessLockAnnounce( const QueueLockAnnounce& ev )
|
|||||||
lm->timeAnnounce = TscTime( ev.time );
|
lm->timeAnnounce = TscTime( ev.time );
|
||||||
lm->timeTerminate = 0;
|
lm->timeTerminate = 0;
|
||||||
lm->valid = true;
|
lm->valid = true;
|
||||||
|
lm->isContended = false;
|
||||||
m_data.lockMap.emplace( ev.id, lm );
|
m_data.lockMap.emplace( ev.id, lm );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2908,6 +2918,7 @@ void Worker::ProcessLockTerminate( const QueueLockTerminate& ev )
|
|||||||
lm->timeAnnounce = 0;
|
lm->timeAnnounce = 0;
|
||||||
lm->timeTerminate = TscTime( ev.time );
|
lm->timeTerminate = TscTime( ev.time );
|
||||||
lm->valid = false;
|
lm->valid = false;
|
||||||
|
lm->isContended = false;
|
||||||
m_data.lockMap.emplace( ev.id, lm );
|
m_data.lockMap.emplace( ev.id, lm );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2927,6 +2938,7 @@ void Worker::ProcessLockWait( const QueueLockWait& ev )
|
|||||||
lm->timeTerminate = 0;
|
lm->timeTerminate = 0;
|
||||||
lm->valid = false;
|
lm->valid = false;
|
||||||
lm->type = ev.type;
|
lm->type = ev.type;
|
||||||
|
lm->isContended = false;
|
||||||
it = m_data.lockMap.emplace( ev.id, lm ).first;
|
it = m_data.lockMap.emplace( ev.id, lm ).first;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2974,6 +2986,7 @@ void Worker::ProcessLockSharedWait( const QueueLockWait& ev )
|
|||||||
auto lm = m_slab.AllocInit<LockMap>();
|
auto lm = m_slab.AllocInit<LockMap>();
|
||||||
lm->valid = false;
|
lm->valid = false;
|
||||||
lm->type = ev.type;
|
lm->type = ev.type;
|
||||||
|
lm->isContended = false;
|
||||||
it = m_data.lockMap.emplace( ev.id, lm ).first;
|
it = m_data.lockMap.emplace( ev.id, lm ).first;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user