Thread id compression/decompression.

This commit is contained in:
Bartosz Taudul 2018-03-18 20:45:22 +01:00
parent 40c6f01a41
commit 777d672e05
2 changed files with 28 additions and 0 deletions

View File

@ -426,6 +426,28 @@ const Worker::SourceLocationZones& Worker::GetZonesForSourceLocation( int32_t sr
}
#endif
uint16_t Worker::CompressThread( uint64_t thread )
{
auto it = m_data.threadMap.find( thread );
if( it != m_data.threadMap.end() )
{
return it->second;
}
else
{
auto sz = m_data.threadExpand.size();
m_data.threadExpand.push_back( thread );
m_data.threadMap.emplace( thread, sz );
return sz;
}
}
uint64_t Worker::DecompressThread( uint16_t thread ) const
{
assert( thread < m_data.threadExpand.size() );
return m_data.threadExpand[thread];
}
void Worker::Exec()
{
timeval tv;

View File

@ -69,6 +69,9 @@ class Worker
#endif
std::map<uint32_t, LockMap> lockMap;
flat_hash_map<uint64_t, uint16_t, nohash<uint64_t>> threadMap;
Vector<uint64_t> threadExpand;
};
struct MbpsBlock
@ -126,6 +129,9 @@ public:
const SourceLocationZones& GetZonesForSourceLocation( int32_t srcloc ) const;
#endif
uint16_t CompressThread( uint64_t thread );
uint64_t DecompressThread( uint16_t thread ) const;
NonRecursiveBenaphore& GetMbpsDataLock() { return m_mbpsData.lock; }
const std::vector<float>& GetMbpsData() const { return m_mbpsData.mbps; }
float GetCompRatio() const { return m_mbpsData.compRatio; }