Store unique callstack payloads.

This commit is contained in:
Bartosz Taudul 2018-06-19 21:15:36 +02:00
parent 87467a472c
commit c28465aa7c
2 changed files with 38 additions and 1 deletions

View File

@ -982,7 +982,7 @@ void Worker::DispatchProcess( const QueueItem& ev, char*& ptr )
AddSourceLocationPayload( ev.stringTransfer.ptr, ptr, sz ); AddSourceLocationPayload( ev.stringTransfer.ptr, ptr, sz );
break; break;
case QueueType::CallstackPayload: case QueueType::CallstackPayload:
//AddCallstackPayload( ev.stringTransfer.ptr, ptr, sz ); AddCallstackPayload( ev.stringTransfer.ptr, ptr, sz );
break; break;
default: default:
assert( false ); assert( false );
@ -1265,6 +1265,36 @@ void Worker::AddCustomString( uint64_t ptr, char* str, size_t sz )
m_pendingCustomStrings.emplace( ptr, StoreString( str, sz ) ); m_pendingCustomStrings.emplace( ptr, StoreString( str, sz ) );
} }
void Worker::AddCallstackPayload( uint64_t ptr, char* _data, size_t sz )
{
assert( m_pendingCallstacks.find( ptr ) == m_pendingCallstacks.end() );
const auto memsize = sizeof( VarArray<uint64_t> ) + sz;
auto mem = (char*)m_slab.AllocRaw( memsize );
auto data = (uint64_t*)mem;
memcpy( data, _data, sz );
auto arr = (VarArray<uint64_t>*)( mem + sz );
new(arr) VarArray<uint64_t>( sz / sizeof( uint64_t ), data );
uint32_t idx;
auto it = m_data.callstackMap.find( arr );
if( it == m_data.callstackMap.end() )
{
idx = m_data.callstackPayload.size();
m_data.callstackMap.emplace( arr, idx );
m_data.callstackPayload.push_back( arr );
}
else
{
idx = it->second;
m_slab.Unalloc( memsize );
}
m_pendingCallstacks.emplace( ptr, idx );
}
void Worker::InsertPlot( PlotData* plot, int64_t time, double val ) void Worker::InsertPlot( PlotData* plot, int64_t time, double val )
{ {
if( plot->data.empty() ) if( plot->data.empty() )

View File

@ -17,6 +17,7 @@
#include "tracy_flat_hash_map.hpp" #include "tracy_flat_hash_map.hpp"
#include "TracyEvent.hpp" #include "TracyEvent.hpp"
#include "TracySlab.hpp" #include "TracySlab.hpp"
#include "TracyVarArray.hpp"
namespace tracy namespace tracy
{ {
@ -98,6 +99,9 @@ class Worker
bool sourceLocationZonesReady; bool sourceLocationZonesReady;
#endif #endif
flat_hash_map<VarArray<uint64_t>*, uint32_t, VarArrayHasherPOT<uint64_t>, VarArrayComparator<uint64_t>> callstackMap;
Vector<VarArray<uint64_t>*> callstackPayload;
std::map<uint32_t, LockMap> lockMap; std::map<uint32_t, LockMap> lockMap;
flat_hash_map<uint64_t, uint16_t, nohash<uint64_t>> threadMap; flat_hash_map<uint64_t, uint16_t, nohash<uint64_t>> threadMap;
@ -243,6 +247,8 @@ private:
void AddThreadString( uint64_t id, char* str, size_t sz ); void AddThreadString( uint64_t id, char* str, size_t sz );
void AddCustomString( uint64_t ptr, char* str, size_t sz ); void AddCustomString( uint64_t ptr, char* str, size_t sz );
void AddCallstackPayload( uint64_t ptr, char* data, size_t sz );
void InsertPlot( PlotData* plot, int64_t time, double val ); void InsertPlot( PlotData* plot, int64_t time, double val );
void HandlePlotName( uint64_t name, char* str, size_t sz ); void HandlePlotName( uint64_t name, char* str, size_t sz );
@ -288,6 +294,7 @@ private:
flat_hash_map<uint16_t, GpuCtxData*, nohash<uint16_t>> m_gpuCtxMap; flat_hash_map<uint16_t, GpuCtxData*, nohash<uint16_t>> m_gpuCtxMap;
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, PlotData*, nohash<uint64_t>> m_plotMap; flat_hash_map<uint64_t, PlotData*, nohash<uint64_t>> m_plotMap;
flat_hash_map<const char*, PlotData*, charutil::HasherPOT, charutil::Comparator> m_plotRev; flat_hash_map<const char*, PlotData*, charutil::HasherPOT, charutil::Comparator> m_plotRev;
flat_hash_map<uint64_t, int32_t, nohash<uint64_t>> m_pendingSourceLocationPayload; flat_hash_map<uint64_t, int32_t, nohash<uint64_t>> m_pendingSourceLocationPayload;