mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-29 16:54:35 +00:00
Lock events dispatch.
This commit is contained in:
parent
110e5971d1
commit
54735bacea
@ -46,15 +46,6 @@ struct LockEvent
|
|||||||
|
|
||||||
enum { LockEventSize = sizeof( LockEvent ) };
|
enum { LockEventSize = sizeof( LockEvent ) };
|
||||||
|
|
||||||
|
|
||||||
struct LockTimeline
|
|
||||||
{
|
|
||||||
uint64_t id;
|
|
||||||
Vector<LockEvent*> timeline;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum { LockTimelineSize = sizeof( LockTimeline ) };
|
|
||||||
|
|
||||||
#pragma pack()
|
#pragma pack()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -457,41 +457,80 @@ void View::ProcessLockAnnounce( const QueueLockAnnounce& ev )
|
|||||||
{
|
{
|
||||||
CheckSourceLocation( ev.srcloc );
|
CheckSourceLocation( ev.srcloc );
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock( m_lock );
|
|
||||||
assert( m_lockMap.find( ev.id ) == m_lockMap.end() );
|
assert( m_lockMap.find( ev.id ) == m_lockMap.end() );
|
||||||
m_lockMap.emplace( ev.id, LockMap { ev.srcloc } );
|
auto it = m_pendingLocks.find( ev.id );
|
||||||
|
|
||||||
|
std::unique_lock<std::mutex> lock( m_lock );
|
||||||
|
auto& lockmap = m_lockMap.emplace( ev.id, LockMap { ev.id, ev.srcloc } ).first->second;
|
||||||
|
|
||||||
|
if( it != m_pendingLocks.end() )
|
||||||
|
{
|
||||||
|
for( auto& v : it->second )
|
||||||
|
{
|
||||||
|
InsertLockEvent( lockmap.timeline, v );
|
||||||
|
}
|
||||||
|
lock.unlock();
|
||||||
|
m_pendingLocks.erase( it );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::ProcessLockWait( const QueueLockWait& ev )
|
void View::ProcessLockWait( const QueueLockWait& ev )
|
||||||
{
|
{
|
||||||
|
auto lev = m_slab.Alloc<LockEvent>();
|
||||||
|
lev->time = ev.time;
|
||||||
|
lev->thread = ev.thread;
|
||||||
|
lev->type = LockEvent::Type::Wait;
|
||||||
|
|
||||||
auto it = m_lockMap.find( ev.id );
|
auto it = m_lockMap.find( ev.id );
|
||||||
if( it == m_lockMap.end() )
|
if( it == m_lockMap.end() )
|
||||||
{
|
{
|
||||||
auto& v = m_pendingLocks[ev.id];
|
auto& v = m_pendingLocks[ev.id];
|
||||||
v.push_back( LockEvent { ev.time, ev.thread, LockEvent::Type::Wait } );
|
v.push_back( lev );
|
||||||
return;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock( m_lock );
|
||||||
|
InsertLockEvent( it->second.timeline, lev );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::ProcessLockObtain( const QueueLockObtain& ev )
|
void View::ProcessLockObtain( const QueueLockObtain& ev )
|
||||||
{
|
{
|
||||||
|
auto lev = m_slab.Alloc<LockEvent>();
|
||||||
|
lev->time = ev.time;
|
||||||
|
lev->thread = ev.thread;
|
||||||
|
lev->type = LockEvent::Type::Obtain;
|
||||||
|
|
||||||
auto it = m_lockMap.find( ev.id );
|
auto it = m_lockMap.find( ev.id );
|
||||||
if( it == m_lockMap.end() )
|
if( it == m_lockMap.end() )
|
||||||
{
|
{
|
||||||
auto& v = m_pendingLocks[ev.id];
|
auto& v = m_pendingLocks[ev.id];
|
||||||
v.push_back( LockEvent { ev.time, ev.thread, LockEvent::Type::Obtain } );
|
v.push_back( lev );
|
||||||
return;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock( m_lock );
|
||||||
|
InsertLockEvent( it->second.timeline, lev );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::ProcessLockRelease( const QueueLockRelease& ev )
|
void View::ProcessLockRelease( const QueueLockRelease& ev )
|
||||||
{
|
{
|
||||||
|
auto lev = m_slab.Alloc<LockEvent>();
|
||||||
|
lev->time = ev.time;
|
||||||
|
lev->thread = ev.thread;
|
||||||
|
lev->type = LockEvent::Type::Release;
|
||||||
|
|
||||||
auto it = m_lockMap.find( ev.id );
|
auto it = m_lockMap.find( ev.id );
|
||||||
if( it == m_lockMap.end() )
|
if( it == m_lockMap.end() )
|
||||||
{
|
{
|
||||||
auto& v = m_pendingLocks[ev.id];
|
auto& v = m_pendingLocks[ev.id];
|
||||||
v.push_back( LockEvent { ev.time, ev.thread, LockEvent::Type::Release } );
|
v.push_back( lev );
|
||||||
return;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock( m_lock );
|
||||||
|
InsertLockEvent( it->second.timeline, lev );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -637,6 +676,10 @@ void View::InsertZone( Event* zone, Event* parent, Vector<Event*>& vec )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void View::InsertLockEvent( Vector<LockEvent*>& timeline, const LockEvent* lev )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t View::GetFrameTime( size_t idx ) const
|
uint64_t View::GetFrameTime( size_t idx ) const
|
||||||
{
|
{
|
||||||
if( idx < m_frames.size() - 1 )
|
if( idx < m_frames.size() - 1 )
|
||||||
|
@ -46,8 +46,9 @@ private:
|
|||||||
|
|
||||||
struct LockMap
|
struct LockMap
|
||||||
{
|
{
|
||||||
|
uint64_t id;
|
||||||
uint64_t srcloc;
|
uint64_t srcloc;
|
||||||
LockTimeline ev;
|
Vector<LockEvent*> timeline;
|
||||||
};
|
};
|
||||||
|
|
||||||
void Worker();
|
void Worker();
|
||||||
@ -83,6 +84,8 @@ private:
|
|||||||
|
|
||||||
void InsertZone( Event* zone, Event* parent, Vector<Event*>& vec );
|
void InsertZone( Event* zone, Event* parent, Vector<Event*>& vec );
|
||||||
|
|
||||||
|
void InsertLockEvent( Vector<LockEvent*>& timeline, const LockEvent* lev );
|
||||||
|
|
||||||
uint64_t GetFrameTime( size_t idx ) const;
|
uint64_t GetFrameTime( size_t idx ) const;
|
||||||
uint64_t GetFrameBegin( size_t idx ) const;
|
uint64_t GetFrameBegin( size_t idx ) const;
|
||||||
uint64_t GetFrameEnd( size_t idx ) const;
|
uint64_t GetFrameEnd( size_t idx ) const;
|
||||||
@ -143,7 +146,7 @@ private:
|
|||||||
std::unordered_set<uint64_t> m_pendingSourceLocation;
|
std::unordered_set<uint64_t> m_pendingSourceLocation;
|
||||||
std::unordered_map<uint64_t, Event*> m_pendingCustomStrings;
|
std::unordered_map<uint64_t, Event*> m_pendingCustomStrings;
|
||||||
std::unordered_map<uint64_t, uint32_t> m_threadMap;
|
std::unordered_map<uint64_t, uint32_t> m_threadMap;
|
||||||
std::unordered_map<uint64_t, std::vector<LockEvent>> m_pendingLocks;
|
std::unordered_map<uint64_t, std::vector<LockEvent*>> m_pendingLocks;
|
||||||
|
|
||||||
Slab<EventSize*1024*1024> m_slab;
|
Slab<EventSize*1024*1024> m_slab;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user