1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Add thread compression cache.

Observation: calls to CompressThread() are likely to be repeated with
the same value. Exploit that by storing last query and its result.
This commit is contained in:
Bartosz Taudul
2018-05-01 01:29:25 +02:00
parent ec58aa4ce1
commit 8beb1c1a39
2 changed files with 19 additions and 1 deletions
+16
View File
@@ -764,10 +764,24 @@ const Worker::SourceLocationZones& Worker::GetZonesForSourceLocation( int32_t sr
#endif
uint16_t Worker::CompressThread( uint64_t thread )
{
if( m_data.threadLast.first == thread )
{
return m_data.threadLast.second;
}
else
{
return CompressThreadReal( thread );
}
}
uint16_t Worker::CompressThreadReal( uint64_t thread )
{
auto it = m_data.threadMap.find( thread );
if( it != m_data.threadMap.end() )
{
m_data.threadLast.first = thread;
m_data.threadLast.second = it->second;
return it->second;
}
else
@@ -781,6 +795,8 @@ uint16_t Worker::CompressThreadNew( uint64_t thread )
auto sz = m_data.threadExpand.size();
m_data.threadExpand.push_back( thread );
m_data.threadMap.emplace( thread, sz );
m_data.threadLast.first = thread;
m_data.threadLast.second = sz;
return sz;
}