mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-25 23:44:35 +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 TracyParameterSetup(x,y,z,w)
|
||||||
#define TracyIsConnected false
|
#define TracyIsConnected false
|
||||||
|
|
||||||
|
#define TracyFiberEnter(x)
|
||||||
|
#define TracyFiberLeave
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -254,6 +257,11 @@
|
|||||||
#define TracyParameterSetup( idx, name, isBool, val ) tracy::Profiler::ParameterSetup( idx, name, isBool, val );
|
#define TracyParameterSetup( idx, name, isBool, val ) tracy::Profiler::ParameterSetup( idx, name, isBool, val );
|
||||||
#define TracyIsConnected tracy::GetProfiler().IsConnected()
|
#define TracyIsConnected tracy::GetProfiler().IsConnected()
|
||||||
|
|
||||||
|
#ifdef TRACY_FIBERS
|
||||||
|
# define TracyFiberEnter( fiber ) tracy::Profiler::EnterFiber( fiber );
|
||||||
|
# define TracyFiberLeave tracy::Profiler::LeaveFiber();
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -2752,6 +2752,24 @@ Profiler::DequeueStatus Profiler::DequeueSerial()
|
|||||||
tracy_free_fast( (void*)ptr );
|
tracy_free_fast( (void*)ptr );
|
||||||
break;
|
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
|
#endif
|
||||||
default:
|
default:
|
||||||
assert( false );
|
assert( false );
|
||||||
|
@ -584,6 +584,23 @@ public:
|
|||||||
TracyLfqCommit;
|
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 );
|
void SendCallstack( int depth, const char* skipBefore );
|
||||||
static void CutCallstack( void* callstack, 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; }
|
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 };
|
enum : uint16_t { BroadcastVersion = 2 };
|
||||||
|
|
||||||
using lz4sz_t = uint32_t;
|
using lz4sz_t = uint32_t;
|
||||||
|
@ -59,6 +59,8 @@ enum class QueueType : uint8_t
|
|||||||
SymbolInformation,
|
SymbolInformation,
|
||||||
CodeInformation,
|
CodeInformation,
|
||||||
ExternalNameMetadata,
|
ExternalNameMetadata,
|
||||||
|
FiberEnter,
|
||||||
|
FiberLeave,
|
||||||
Terminate,
|
Terminate,
|
||||||
KeepAlive,
|
KeepAlive,
|
||||||
ThreadContext,
|
ThreadContext,
|
||||||
@ -236,6 +238,19 @@ struct QueueLockAnnounce
|
|||||||
LockType type;
|
LockType type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct QueueFiberEnter
|
||||||
|
{
|
||||||
|
int64_t time;
|
||||||
|
uint64_t fiber; // ptr
|
||||||
|
uint32_t thread;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct QueueFiberLeave
|
||||||
|
{
|
||||||
|
int64_t time;
|
||||||
|
uint32_t thread;
|
||||||
|
};
|
||||||
|
|
||||||
struct QueueLockTerminate
|
struct QueueLockTerminate
|
||||||
{
|
{
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
@ -692,6 +707,8 @@ struct QueueItem
|
|||||||
QueueParamSetup paramSetup;
|
QueueParamSetup paramSetup;
|
||||||
QueueCpuTopology cpuTopology;
|
QueueCpuTopology cpuTopology;
|
||||||
QueueExternalNameMetadata externalNameMetadata;
|
QueueExternalNameMetadata externalNameMetadata;
|
||||||
|
QueueFiberEnter fiberEnter;
|
||||||
|
QueueFiberLeave fiberLeave;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
#pragma pack()
|
#pragma pack()
|
||||||
@ -750,7 +767,9 @@ static constexpr size_t QueueDataSize[] = {
|
|||||||
sizeof( QueueHeader ) + sizeof( QueueCallstackFrameSize ),
|
sizeof( QueueHeader ) + sizeof( QueueCallstackFrameSize ),
|
||||||
sizeof( QueueHeader ) + sizeof( QueueSymbolInformation ),
|
sizeof( QueueHeader ) + sizeof( QueueSymbolInformation ),
|
||||||
sizeof( QueueHeader ) + sizeof( QueueCodeInformation ),
|
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
|
// above items must be first
|
||||||
sizeof( QueueHeader ), // terminate
|
sizeof( QueueHeader ), // terminate
|
||||||
sizeof( QueueHeader ), // keep alive
|
sizeof( QueueHeader ), // keep alive
|
||||||
|
Loading…
Reference in New Issue
Block a user