mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-22 14:44:34 +00:00
Add fiber support on client side.
This commit is contained in:
parent
8b15cd049c
commit
229d547e91
@ -97,6 +97,9 @@
|
||||
#define TracyParameterSetup(x,y,z,w)
|
||||
#define TracyIsConnected false
|
||||
|
||||
#define TracyFiberEnter(x)
|
||||
#define TracyFiberLeave
|
||||
|
||||
#else
|
||||
|
||||
#include <string.h>
|
||||
@ -254,6 +257,11 @@
|
||||
#define TracyParameterSetup( idx, name, isBool, val ) tracy::Profiler::ParameterSetup( idx, name, isBool, val );
|
||||
#define TracyIsConnected tracy::GetProfiler().IsConnected()
|
||||
|
||||
#ifdef TRACY_FIBERS
|
||||
# define TracyFiberEnter( fiber ) tracy::Profiler::EnterFiber( fiber );
|
||||
# define TracyFiberLeave tracy::Profiler::LeaveFiber();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -2752,6 +2752,24 @@ Profiler::DequeueStatus Profiler::DequeueSerial()
|
||||
tracy_free_fast( (void*)ptr );
|
||||
break;
|
||||
}
|
||||
case QueueType::FiberEnter:
|
||||
{
|
||||
ThreadCtxCheckSerial( fiberEnter );
|
||||
int64_t t = MemRead<int64_t>( &item->fiberEnter.time );
|
||||
int64_t dt = t - refThread;
|
||||
refThread = t;
|
||||
MemWrite( &item->fiberEnter.time, dt );
|
||||
break;
|
||||
}
|
||||
case QueueType::FiberLeave:
|
||||
{
|
||||
ThreadCtxCheckSerial( fiberLeave );
|
||||
int64_t t = MemRead<int64_t>( &item->fiberLeave.time );
|
||||
int64_t dt = t - refThread;
|
||||
refThread = t;
|
||||
MemWrite( &item->fiberLeave.time, dt );
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
assert( false );
|
||||
|
@ -584,6 +584,23 @@ public:
|
||||
TracyLfqCommit;
|
||||
}
|
||||
|
||||
#ifdef TRACY_FIBERS
|
||||
static tracy_force_inline void EnterFiber( const char* fiber )
|
||||
{
|
||||
TracyQueuePrepare( QueueType::FiberEnter );
|
||||
MemWrite( &item->fiberEnter.time, GetTime() );
|
||||
MemWrite( &item->fiberEnter.fiber, (uint64_t)fiber );
|
||||
TracyQueueCommit( fiberEnter );
|
||||
}
|
||||
|
||||
static tracy_force_inline void LeaveFiber()
|
||||
{
|
||||
TracyQueuePrepare( QueueType::FiberLeave );
|
||||
MemWrite( &item->fiberLeave.time, GetTime() );
|
||||
TracyQueueCommit( fiberLeave );
|
||||
}
|
||||
#endif
|
||||
|
||||
void SendCallstack( int depth, const char* skipBefore );
|
||||
static void CutCallstack( void* callstack, const char* skipBefore );
|
||||
|
||||
|
@ -9,7 +9,7 @@ namespace tracy
|
||||
|
||||
constexpr unsigned Lz4CompressBound( unsigned isize ) { return isize + ( isize / 255 ) + 16; }
|
||||
|
||||
enum : uint32_t { ProtocolVersion = 51 };
|
||||
enum : uint32_t { ProtocolVersion = 52 };
|
||||
enum : uint16_t { BroadcastVersion = 2 };
|
||||
|
||||
using lz4sz_t = uint32_t;
|
||||
|
@ -59,6 +59,8 @@ enum class QueueType : uint8_t
|
||||
SymbolInformation,
|
||||
CodeInformation,
|
||||
ExternalNameMetadata,
|
||||
FiberEnter,
|
||||
FiberLeave,
|
||||
Terminate,
|
||||
KeepAlive,
|
||||
ThreadContext,
|
||||
@ -236,6 +238,19 @@ struct QueueLockAnnounce
|
||||
LockType type;
|
||||
};
|
||||
|
||||
struct QueueFiberEnter
|
||||
{
|
||||
int64_t time;
|
||||
uint64_t fiber; // ptr
|
||||
uint32_t thread;
|
||||
};
|
||||
|
||||
struct QueueFiberLeave
|
||||
{
|
||||
int64_t time;
|
||||
uint32_t thread;
|
||||
};
|
||||
|
||||
struct QueueLockTerminate
|
||||
{
|
||||
uint32_t id;
|
||||
@ -692,6 +707,8 @@ struct QueueItem
|
||||
QueueParamSetup paramSetup;
|
||||
QueueCpuTopology cpuTopology;
|
||||
QueueExternalNameMetadata externalNameMetadata;
|
||||
QueueFiberEnter fiberEnter;
|
||||
QueueFiberLeave fiberLeave;
|
||||
};
|
||||
};
|
||||
#pragma pack()
|
||||
@ -750,7 +767,9 @@ static constexpr size_t QueueDataSize[] = {
|
||||
sizeof( QueueHeader ) + sizeof( QueueCallstackFrameSize ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueSymbolInformation ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueCodeInformation ),
|
||||
sizeof( QueueHeader), // ExternalNameMetadata - not for wire transfer
|
||||
sizeof( QueueHeader ), // ExternalNameMetadata - not for wire transfer
|
||||
sizeof( QueueHeader ) + sizeof( QueueFiberEnter ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueFiberLeave ),
|
||||
// above items must be first
|
||||
sizeof( QueueHeader ), // terminate
|
||||
sizeof( QueueHeader ), // keep alive
|
||||
|
Loading…
Reference in New Issue
Block a user