Move towards proper data structures.

This commit is contained in:
Bartosz Taudul 2017-10-04 18:17:31 +02:00
parent 4fad4be816
commit c2bccf7126
3 changed files with 28 additions and 10 deletions

View File

@ -32,11 +32,29 @@ enum { EventSize = sizeof( Event ) };
struct LockEvent
{
uint64_t srcloc;
enum class Type : uint8_t
{
Wait,
Obtain,
Release
};
int64_t time;
uint64_t thread;
Type type;
};
enum { LockEventSize = sizeof( LockEvent ) };
struct LockTimeline
{
uint64_t id;
Vector<LockEvent*> timeline;
};
enum { LockTimelineSize = sizeof( LockTimeline ) };
#pragma pack()
}

View File

@ -454,14 +454,9 @@ void View::ProcessLockAnnounce( const QueueLockAnnounce& ev )
{
CheckSourceLocation( ev.srcloc );
auto ptr = m_slab.Alloc<LockEvent>();
ptr->srcloc = ev.srcloc;
assert( m_lockMap.find( ev.id ) == m_lockMap.end() );
m_lockMap.emplace( ev.id, ptr );
std::lock_guard<std::mutex> lock( m_lock );
m_locks.push_back( ptr );
assert( m_lockMap.find( ev.id ) == m_lockMap.end() );
m_lockMap.emplace( ev.id, LockMap { ev.srcloc } );
}
void View::CheckString( uint64_t ptr )

View File

@ -44,6 +44,12 @@ private:
Vector<Event*> timeline;
};
struct LockMap
{
uint64_t srcloc;
LockTimeline ev;
};
void Worker();
void DispatchProcess( const QueueItem& ev );
@ -117,11 +123,11 @@ private:
std::mutex m_lock;
Vector<uint64_t> m_frames;
Vector<ThreadData*> m_threads;
Vector<LockEvent*> m_locks;
std::unordered_map<uint64_t, std::string> m_strings;
std::unordered_map<uint64_t, std::string> m_threadNames;
std::unordered_set<const char*, charutil::Hasher, charutil::Comparator> m_customStrings;
std::unordered_map<uint64_t, QueueSourceLocation> m_sourceLocation;
std::unordered_map<uint64_t, LockMap> m_lockMap;
uint64_t m_zonesCnt;
std::mutex m_mbpslock;
@ -134,7 +140,6 @@ private:
std::unordered_set<uint64_t> m_pendingSourceLocation;
std::unordered_map<uint64_t, Event*> m_pendingCustomStrings;
std::unordered_map<uint64_t, uint32_t> m_threadMap;
std::unordered_map<uint64_t, LockEvent*> m_lockMap;
Slab<EventSize*1024*1024> m_slab;