7#ifndef PXR_EXEC_VDF_EXECUTION_STATS_H
8#define PXR_EXEC_VDF_EXECUTION_STATS_H
14#include "pxr/exec/vdf/api.h"
20#include <tbb/concurrent_queue.h>
21#include <tbb/enumerable_thread_specific.h>
27PXR_NAMESPACE_OPEN_SCOPE
40 constexpr static uint8_t _StartFlag = 0x80;
44 constexpr static uint8_t _EndFlag = 0xC0;
57 NodeEvaluateEvent = 0x0,
58 NodePrepareEvent = 0x1,
59 NodeRequiredInputsEvent = 0x2,
60 NodeInputsTaskEvent = 0x3,
63 NodeDidComputeEvent = 0x10,
64 ElementsCopiedEvent = 0x11,
65 ElementsProcessedEvent = 0x12,
66 RequestedOutputInSpeculationsEvent = 0x13,
72 typedef uint64_t EventData;
86 nodeId(nodeId), data(data), event(event) {}
125 std::string _tagName;
174 return _invokingNodeId;
181 const VdfId *invokingNodeId,
187 return (
EventType)(
static_cast<uint8_t
>(event) & 0x3F);
194 return 0x40 &
static_cast<uint8_t
>(event);
213 _events.local().events.push_back(
Event(event, nodeId, data));
228 VdfId invokingNodeId);
233 return (
EventType)(
static_cast<uint8_t
>(event) | _StartFlag);
239 return (
EventType)(
static_cast<uint8_t
>(event) | _EndFlag);
243 friend class VdfExecutionStatsProcessor;
251 std::optional<VdfId> _invokingNodeId;
255 struct _PerThreadEvents {
256 _PerThreadEvents() : threadId(
std::this_thread::get_id()) {}
259 std::thread::id threadId;
262 typedef std::deque<Event> EventVector;
268 tbb::enumerable_thread_specific<_PerThreadEvents> _events;
274 tbb::concurrent_queue<VdfExecutionStats*> _subStats;
279PXR_NAMESPACE_CLOSE_SCOPE
Execution stats profiling event logger.
static bool IsBeginEvent(EventType event)
Returns true if the event is a begin event.
static bool IsEndEvent(EventType event)
Returns true if the event is an end event (e.g.
EventType _TagEnd(EventType event)
Tags the end flag.
static VDF_API std::string GetMallocTagName(const VdfId *invokingNodeId, const VdfNode &node)
Returns a unique name for the given node.
EventType _TagBegin(EventType event)
Tags the begin flag.
VDF_API VdfExecutionStats * _AddSubStat(const VdfNetwork *network, VdfId invokingNodeId)
Adds sub stat.
VDF_API VdfExecutionStats(const VdfNetwork *network, VdfId nodeId)
Sub stat constructor.
VDF_API ~VdfExecutionStats()
Destructor.
void _Log(EventType event, VdfId nodeId, EventData data)
Logs data.
const std::optional< VdfId > & GetInvokingNodeId() const
Returns the invoking node, if any.
void LogData(EventType event, const VdfNode &node, EventData data)
Log event API.
void LogTimestamp(EventType event, const VdfNode &node)
Log timestamp API.
VDF_API VdfExecutionStats * AddSubStat(const VdfNetwork *network, const VdfNode *invokingNode)
Push execution stats onto the hierarchy queue.
void LogEndTimestamp(EventType event, const VdfNode &node)
Logs timestamped end event.
void _LogTime(EventType event, const VdfNode &node)
Logs timestamp.
VDF_API VdfExecutionStats(const VdfNetwork *network)
Constructor for parent execution stats that have no invoking node.
static EventType GetBaseEvent(EventType event)
Returns the base event (e.g.
void LogBeginTimestamp(EventType event, const VdfNode &node)
Logs timestamped begin event.
EventType
The upper 2 bits are reserved as a flag for the event type: Highest bit : time event flag 2nd high bi...
A VdfNetwork is a collection of VdfNodes and their connections.
This is the base class for all nodes in a VdfNetwork.
VdfId GetId() const
Returns the unique id of this node in its network.
uint64_t ArchGetTickTime()
Return the current time in system-dependent units.
uint64_t VdfId
The unique identifier type for Vdf objects.
Scoped event that automatically logs when created and destroyed.
Scoped event that automatically pushes and pops malloc tags for the given VdfNode.
High-resolution, low-cost timing routines.