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

Use table instead of map to track reentrant calls.

This commit is contained in:
Bartosz Taudul
2021-11-14 16:42:11 +01:00
parent cb004e9cc0
commit ffa8bf4d75
3 changed files with 13 additions and 57 deletions
+3 -47
View File
@@ -620,57 +620,12 @@ enum { GhostZoneSize = sizeof( GhostZone ) };
#pragma pack()
using SrcLocCountMap = unordered_flat_map<int16_t, size_t>;
static tracy_force_inline void IncSrcLocCount( SrcLocCountMap& countMap, int16_t srcloc )
{
const auto it = countMap.find( srcloc );
if( it == countMap.end() )
{
countMap.emplace( srcloc, 1 );
return;
}
assert( it->second != 0 );
it->second++;
}
static tracy_force_inline bool DecSrcLocCount( SrcLocCountMap& countMap, int16_t srcloc )
{
const auto it = countMap.find( srcloc );
assert( it != countMap.end() );
assert( it->second != 0 );
if( it->second == 1 )
{
countMap.erase( it );
return false;
}
it->second--;
return true;
}
static tracy_force_inline bool HasSrcLocCount( const SrcLocCountMap& countMap, int16_t srcloc )
{
const auto it = countMap.find( srcloc );
if( it != countMap.end() )
{
assert( it->second != 0 );
return true;
}
return false;
}
struct ThreadData
{
uint64_t id;
uint64_t count;
Vector<short_ptr<ZoneEvent>> timeline;
Vector<short_ptr<ZoneEvent>> stack;
SrcLocCountMap stackCount;
Vector<short_ptr<MessageData>> messages;
uint32_t nextZoneId;
Vector<uint32_t> zoneIdStack;
@@ -686,9 +641,10 @@ struct ThreadData
uint64_t kernelSampleCnt;
uint8_t isFiber;
ThreadData* fiber;
uint8_t* stackCount;
tracy_force_inline void IncStackCount( int16_t srcloc ) { IncSrcLocCount( stackCount, srcloc ); }
tracy_force_inline bool DecStackCount( int16_t srcloc ) { return DecSrcLocCount( stackCount, srcloc ); }
tracy_force_inline void IncStackCount( int16_t srcloc ) { stackCount[uint16_t(srcloc)]++; }
tracy_force_inline bool DecStackCount( int16_t srcloc ) { return --stackCount[uint16_t(srcloc)] != 0; }
};
struct GpuCtxThreadData