mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-26 16:04:34 +00: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:
parent
ec58aa4ce1
commit
8beb1c1a39
@ -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;
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ class Worker
|
||||
|
||||
struct DataBlock
|
||||
{
|
||||
DataBlock() : zonesCnt( 0 ), lastTime( 0 ) {}
|
||||
DataBlock() : zonesCnt( 0 ), lastTime( 0 ), threadLast( std::numeric_limits<uint64_t>::max(), 0 ) {}
|
||||
|
||||
NonRecursiveBenaphore lock;
|
||||
Vector<int64_t> frames;
|
||||
@ -100,6 +100,7 @@ class Worker
|
||||
|
||||
flat_hash_map<uint64_t, uint16_t, nohash<uint64_t>> threadMap;
|
||||
Vector<uint64_t> threadExpand;
|
||||
std::pair<uint64_t, uint16_t> threadLast;
|
||||
};
|
||||
|
||||
struct MbpsBlock
|
||||
@ -239,6 +240,7 @@ private:
|
||||
void HandlePostponedPlots();
|
||||
|
||||
StringLocation StoreString( char* str, size_t sz );
|
||||
uint16_t CompressThreadReal( uint64_t thread );
|
||||
uint16_t CompressThreadNew( uint64_t thread );
|
||||
|
||||
tracy_force_inline void ReadTimeline( FileRead& f, Vector<ZoneEvent*>& vec, uint16_t thread );
|
||||
|
Loading…
Reference in New Issue
Block a user