Take callstack field in ZoneEvent into account in save/load.

This commit is contained in:
Bartosz Taudul 2018-06-22 01:30:08 +02:00
parent e40c5068c9
commit 4992ae6b39
2 changed files with 68 additions and 24 deletions

View File

@ -453,7 +453,14 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
f.Read( tid ); f.Read( tid );
td->id = tid; td->id = tid;
f.Read( td->count ); f.Read( td->count );
if( fileVer <= FileVersion( 0, 3, 1 ) )
{
ReadTimelinePre032( f, td->timeline, CompressThread( tid ) );
}
else
{
ReadTimeline( f, td->timeline, CompressThread( tid ) ); ReadTimeline( f, td->timeline, CompressThread( tid ) );
}
uint64_t msz; uint64_t msz;
f.Read( msz ); f.Read( msz );
if( eventMask & EventType::Messages ) if( eventMask & EventType::Messages )
@ -2340,6 +2347,16 @@ void Worker::ReadTimeline( FileRead& f, Vector<ZoneEvent*>& vec, uint16_t thread
} }
} }
void Worker::ReadTimelinePre032( FileRead& f, Vector<ZoneEvent*>& vec, uint16_t thread )
{
uint64_t sz;
f.Read( sz );
if( sz != 0 )
{
ReadTimelinePre032( f, vec, thread, sz );
}
}
void Worker::ReadTimeline( FileRead& f, Vector<GpuEvent*>& vec ) void Worker::ReadTimeline( FileRead& f, Vector<GpuEvent*>& vec )
{ {
uint64_t sz; uint64_t sz;
@ -2360,21 +2377,8 @@ void Worker::ReadTimelinePre032( FileRead& f, Vector<GpuEvent*>& vec )
} }
} }
void Worker::ReadTimeline( FileRead& f, Vector<ZoneEvent*>& vec, uint16_t thread, uint64_t size ) void Worker::ReadTimelineUpdateStatistics( ZoneEvent* zone, uint16_t thread )
{ {
assert( size != 0 );
vec.reserve_non_zero( size );
m_data.zonesCnt += size;
for( uint64_t i=0; i<size; i++ )
{
auto zone = m_slab.Alloc<ZoneEvent>();
vec.push_back_no_space_check( zone );
new( &zone->child ) decltype( zone->child );
f.Read( zone, sizeof( ZoneEvent ) - sizeof( ZoneEvent::child ) );
ReadTimeline( f, zone->child, thread );
#ifndef TRACY_NO_STATISTICS #ifndef TRACY_NO_STATISTICS
auto it = m_data.sourceLocationZones.find( zone->srcloc ); auto it = m_data.sourceLocationZones.find( zone->srcloc );
assert( it != m_data.sourceLocationZones.end() ); assert( it != m_data.sourceLocationZones.end() );
@ -2399,6 +2403,42 @@ void Worker::ReadTimeline( FileRead& f, Vector<ZoneEvent*>& vec, uint16_t thread
} }
} }
#endif #endif
}
void Worker::ReadTimeline( FileRead& f, Vector<ZoneEvent*>& vec, uint16_t thread, uint64_t size )
{
assert( size != 0 );
vec.reserve_non_zero( size );
m_data.zonesCnt += size;
for( uint64_t i=0; i<size; i++ )
{
auto zone = m_slab.Alloc<ZoneEvent>();
vec.push_back_no_space_check( zone );
new( &zone->child ) decltype( zone->child );
f.Read( zone, sizeof( ZoneEvent ) - sizeof( ZoneEvent::child ) );
ReadTimeline( f, zone->child, thread );
ReadTimelineUpdateStatistics( zone, thread );
}
}
void Worker::ReadTimelinePre032( FileRead& f, Vector<ZoneEvent*>& vec, uint16_t thread, uint64_t size )
{
assert( size != 0 );
vec.reserve_non_zero( size );
m_data.zonesCnt += size;
for( uint64_t i=0; i<size; i++ )
{
auto zone = m_slab.Alloc<ZoneEvent>();
vec.push_back_no_space_check( zone );
new( &zone->child ) decltype( zone->child );
f.Read( zone, 26 );
zone->callstack = 0;
ReadTimelinePre032( f, zone->child, thread );
ReadTimelineUpdateStatistics( zone, thread );
} }
} }

View File

@ -282,10 +282,14 @@ private:
uint16_t CompressThreadNew( uint64_t thread ); uint16_t CompressThreadNew( uint64_t thread );
tracy_force_inline void ReadTimeline( FileRead& f, Vector<ZoneEvent*>& vec, uint16_t thread ); tracy_force_inline void ReadTimeline( FileRead& f, Vector<ZoneEvent*>& vec, uint16_t thread );
tracy_force_inline void ReadTimelinePre032( FileRead& f, Vector<ZoneEvent*>& vec, uint16_t thread );
tracy_force_inline void ReadTimeline( FileRead& f, Vector<GpuEvent*>& vec ); tracy_force_inline void ReadTimeline( FileRead& f, Vector<GpuEvent*>& vec );
tracy_force_inline void ReadTimelinePre032( FileRead& f, Vector<GpuEvent*>& vec ); tracy_force_inline void ReadTimelinePre032( FileRead& f, Vector<GpuEvent*>& vec );
tracy_force_inline void ReadTimelineUpdateStatistics( ZoneEvent* zone, uint16_t thread );
void ReadTimeline( FileRead& f, Vector<ZoneEvent*>& vec, uint16_t thread, uint64_t size ); void ReadTimeline( FileRead& f, Vector<ZoneEvent*>& vec, uint16_t thread, uint64_t size );
void ReadTimelinePre032( FileRead& f, Vector<ZoneEvent*>& vec, uint16_t thread, uint64_t size );
void ReadTimeline( FileRead& f, Vector<GpuEvent*>& vec, uint64_t size ); void ReadTimeline( FileRead& f, Vector<GpuEvent*>& vec, uint64_t size );
void ReadTimelinePre032( FileRead& f, Vector<GpuEvent*>& vec, uint64_t size ); void ReadTimelinePre032( FileRead& f, Vector<GpuEvent*>& vec, uint64_t size );