tracy/common/TracyQueue.hpp
Bartosz Taudul 7424077d70 Store source location in a single object.
Source file, function name and line number are now stored in a const
static container object. This has the following benefits:
- Slightly lighter profiling workload (3 instructions less).
- Profiling queue event size is significantly reduced, by 12 bytes. This
  has an effect on all queue event types.
- Source location grouping has now no cost, as it's performed at the
  compilation stage. This allows simplification of server code.
The downside is that the full source location resolution is now
performed in two steps, as the server has to query both source location
container and strings contained within. This has almost no real impact
on profiler operation.
2017-09-26 02:39:08 +02:00

82 lines
1.3 KiB
C++
Executable File

#ifndef __TRACYQUEUE_HPP__
#define __TRACYQUEUE_HPP__
#include <stdint.h>
namespace tracy
{
enum class QueueType : uint8_t
{
ZoneBegin,
ZoneEnd,
StringData,
ThreadName,
FrameMark,
SourceLocation,
NUM_TYPES
};
#pragma pack( 1 )
struct QueueZoneBegin
{
int64_t time;
uint64_t srcloc; // ptr
uint64_t thread;
uint32_t color;
};
struct QueueZoneEnd
{
int64_t time;
};
struct QueueSourceLocation
{
uint64_t function; // ptr
uint64_t file; // ptr
uint32_t line;
};
struct QueueHeader
{
union
{
QueueType type;
uint8_t idx;
};
uint64_t id;
};
struct QueueItem
{
QueueHeader hdr;
union
{
QueueZoneBegin zoneBegin;
QueueZoneEnd zoneEnd;
QueueSourceLocation srcloc;
};
};
#pragma pack()
enum { QueueItemSize = sizeof( QueueItem ) };
static const size_t QueueDataSize[] = {
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ),
sizeof( QueueHeader ) + sizeof( QueueZoneEnd ),
sizeof( QueueHeader ),
sizeof( QueueHeader ),
sizeof( QueueHeader ),
sizeof( QueueHeader ) + sizeof( QueueSourceLocation ),
};
static_assert( sizeof( QueueDataSize ) / sizeof( size_t ) == (uint8_t)QueueType::NUM_TYPES, "QueueDataSize mismatch" );
static_assert( sizeof( void* ) <= sizeof( uint64_t ), "Pointer size > 8 bytes" );
};
#endif