Calculate lock wait counts.

This commit is contained in:
Bartosz Taudul 2017-10-05 14:02:08 +02:00
parent 2582f04977
commit 78067eb35e
2 changed files with 15 additions and 6 deletions

View File

@ -42,6 +42,7 @@ struct LockEvent
int64_t time; int64_t time;
uint64_t thread; uint64_t thread;
uint8_t lockCount; uint8_t lockCount;
uint8_t waitCount;
Type type; Type type;
}; };

View File

@ -719,25 +719,33 @@ void View::InsertLockEvent( LockMap& lockmap, LockEvent* lev )
void View::UpdateLockCount( Vector<LockEvent*>& timeline, size_t pos ) void View::UpdateLockCount( Vector<LockEvent*>& timeline, size_t pos )
{ {
uint8_t count = pos == 0 ? 0 : timeline[pos-1]->lockCount; uint8_t lockCount = pos == 0 ? 0 : timeline[pos-1]->lockCount;
uint8_t waitCount = pos == 0 ? 0 : timeline[pos-1]->waitCount;
const auto end = timeline.size(); const auto end = timeline.size();
while( pos != end ) while( pos != end )
{ {
switch( timeline[pos]->type ) switch( timeline[pos]->type )
{ {
case LockEvent::Type::Wait:
assert( waitCount < std::numeric_limits<uint8_t>::max() );
waitCount++;
break;
case LockEvent::Type::Obtain: case LockEvent::Type::Obtain:
assert( count < std::numeric_limits<uint8_t>::max() ); assert( lockCount < std::numeric_limits<uint8_t>::max() );
count++; assert( waitCount > 0 );
lockCount++;
waitCount--;
break; break;
case LockEvent::Type::Release: case LockEvent::Type::Release:
assert( count > 0 ); assert( lockCount > 0 );
count--; lockCount--;
break; break;
default: default:
break; break;
} }
timeline[pos]->lockCount = count; timeline[pos]->lockCount = lockCount;
timeline[pos]->waitCount = waitCount;
pos++; pos++;
} }
} }