1
0
mirror of https://github.com/wolfpld/tracy synced 2025-05-03 06:03:51 +00:00

Don't use hash table to store 256 pointers.

This commit is contained in:
Bartosz Taudul 2018-06-22 15:14:44 +02:00
parent 55ddb64352
commit cd5ca3e754
2 changed files with 13 additions and 15 deletions

View File

@ -193,6 +193,8 @@ Worker::Worker( const char* addr )
m_data.threadExpand.push_back( 0 ); m_data.threadExpand.push_back( 0 );
m_data.callstackPayload.push_back( nullptr ); m_data.callstackPayload.push_back( nullptr );
memset( m_gpuCtxMap, 0, sizeof( m_gpuCtxMap ) );
#ifndef TRACY_NO_STATISTICS #ifndef TRACY_NO_STATISTICS
m_data.sourceLocationZonesReady = true; m_data.sourceLocationZonesReady = true;
#endif #endif
@ -1928,7 +1930,7 @@ void Worker::ProcessMessageLiteral( const QueueMessage& ev )
void Worker::ProcessGpuNewContext( const QueueGpuNewContext& ev ) void Worker::ProcessGpuNewContext( const QueueGpuNewContext& ev )
{ {
assert( m_gpuCtxMap.find( ev.context ) == m_gpuCtxMap.end() ); assert( !m_gpuCtxMap[ev.context] );
int64_t gpuTime; int64_t gpuTime;
if( ev.period == 1.f ) if( ev.period == 1.f )
@ -1947,14 +1949,13 @@ void Worker::ProcessGpuNewContext( const QueueGpuNewContext& ev )
gpu->period = ev.period; gpu->period = ev.period;
gpu->count = 0; gpu->count = 0;
m_data.gpuData.push_back( gpu ); m_data.gpuData.push_back( gpu );
m_gpuCtxMap.emplace( ev.context, gpu ); m_gpuCtxMap[ev.context] = gpu;
} }
void Worker::ProcessGpuZoneBeginImpl( GpuEvent* zone, const QueueGpuZoneBegin& ev ) void Worker::ProcessGpuZoneBeginImpl( GpuEvent* zone, const QueueGpuZoneBegin& ev )
{ {
auto it = m_gpuCtxMap.find( ev.context ); auto ctx = m_gpuCtxMap[ev.context];
assert( it != m_gpuCtxMap.end() ); assert( ctx );
auto ctx = it->second;
CheckSourceLocation( ev.srcloc ); CheckSourceLocation( ev.srcloc );
@ -2009,9 +2010,8 @@ void Worker::ProcessGpuZoneBeginCallstack( const QueueGpuZoneBegin& ev )
void Worker::ProcessGpuZoneEnd( const QueueGpuZoneEnd& ev ) void Worker::ProcessGpuZoneEnd( const QueueGpuZoneEnd& ev )
{ {
auto it = m_gpuCtxMap.find( ev.context ); auto ctx = m_gpuCtxMap[ev.context];
assert( it != m_gpuCtxMap.end() ); assert( ctx );
auto ctx = it->second;
assert( !ctx->stack.empty() ); assert( !ctx->stack.empty() );
auto zone = ctx->stack.back_and_pop(); auto zone = ctx->stack.back_and_pop();
@ -2023,9 +2023,8 @@ void Worker::ProcessGpuZoneEnd( const QueueGpuZoneEnd& ev )
void Worker::ProcessGpuTime( const QueueGpuTime& ev ) void Worker::ProcessGpuTime( const QueueGpuTime& ev )
{ {
auto it = m_gpuCtxMap.find( ev.context ); auto ctx = m_gpuCtxMap[ev.context];
assert( it != m_gpuCtxMap.end() ); assert( ctx );
auto ctx = it->second;
int64_t gpuTime; int64_t gpuTime;
if( ctx->period == 1.f ) if( ctx->period == 1.f )
@ -2066,9 +2065,8 @@ void Worker::ProcessGpuTime( const QueueGpuTime& ev )
void Worker::ProcessGpuResync( const QueueGpuResync& ev ) void Worker::ProcessGpuResync( const QueueGpuResync& ev )
{ {
auto it = m_gpuCtxMap.find( ev.context ); auto ctx = m_gpuCtxMap[ev.context];
assert( it != m_gpuCtxMap.end() ); assert( ctx );
auto ctx = it->second;
int64_t gpuTime; int64_t gpuTime;
if( ctx->period == 1.f ) if( ctx->period == 1.f )

View File

@ -322,7 +322,7 @@ private:
char* m_buffer; char* m_buffer;
int m_bufferOffset; int m_bufferOffset;
flat_hash_map<uint8_t, GpuCtxData*, nohash<uint8_t>> m_gpuCtxMap; GpuCtxData* m_gpuCtxMap[256];
flat_hash_map<uint64_t, StringLocation, nohash<uint64_t>> m_pendingCustomStrings; flat_hash_map<uint64_t, StringLocation, nohash<uint64_t>> m_pendingCustomStrings;
flat_hash_map<uint64_t, PlotData*, nohash<uint64_t>> m_pendingPlots; flat_hash_map<uint64_t, PlotData*, nohash<uint64_t>> m_pendingPlots;
flat_hash_map<uint64_t, uint32_t> m_pendingCallstacks; flat_hash_map<uint64_t, uint32_t> m_pendingCallstacks;