Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
b2b68b8
[PROTON] Refactor linked virtual node handling in buildHatchetJson an…
Jokeren May 21, 2026
43b245d
Enhance cudagraph tests by removing empty frames and validating metri…
Jokeren May 21, 2026
69cfac0
Refactor cudagraph test to streamline metric payload checks and remov…
Jokeren May 21, 2026
a28738a
Optimize Proton TreeData msgpack flushing
Jokeren May 22, 2026
89d5f8e
Remove non-general TreeData serialization shortcuts
Jokeren May 22, 2026
7fcb4b7
Inline trivial TreeData serialization helpers
Jokeren May 22, 2026
395ee4c
Handle graph-specific capture tags during dumping
Jokeren May 22, 2026
9023344
Tag CUDA graph capture contexts by graph id
Jokeren May 22, 2026
918f9dc
Resolve graph linked dumps from target roots
Jokeren May 22, 2026
f51bd95
Remove linked kernel leaf packing shortcut
Jokeren May 22, 2026
aab38e2
Remove redundant JSON flexible metric promotion
Jokeren May 22, 2026
c8a755f
Prune linked graph dumps without capture ids
Jokeren May 22, 2026
9fbce0e
Clarify linked flexible metric pruning
Jokeren May 23, 2026
91ad8a5
Inline graph capture tag display helpers
Jokeren May 23, 2026
3c33f64
Mark linked virtual ancestors directly
Jokeren May 23, 2026
e1ea3c8
Document MsgPack metric entry counts
Jokeren May 23, 2026
649af3d
Document TreeData serializer helpers
Jokeren May 23, 2026
2b8bfc2
Reuse linked virtual node marks
Jokeren May 23, 2026
51deaa2
Avoid throwing in packUIntString
Jokeren May 23, 2026
eed568d
Skip empty linked MsgPack metric work
Jokeren May 23, 2026
8646a65
Pack Hatchet frame headers directly
Jokeren May 23, 2026
ac2f160
Cache virtual MsgPack frame headers
Jokeren May 23, 2026
cae3c76
Refactor formatting in Metric.h and TraceData.cpp for improved readab…
Jokeren May 23, 2026
6ed04f7
Simplify cached MsgPack frame headers
Jokeren May 26, 2026
1c90e44
Remove TreeData child index cache
Jokeren May 26, 2026
46b3aa1
Revert TraceData context copy changes
Jokeren May 26, 2026
0da7be0
Restore TreeData child index map
Jokeren May 26, 2026
0a9c196
Refine Proton MsgPack byte appends
Jokeren May 26, 2026
d216515
Simplify Proton JSON linked virtual dumping
Jokeren May 26, 2026
9027c35
Split empty-node pruning from fast file write
Jokeren May 26, 2026
16d8c8e
Apply Proton formatting fixes
Jokeren May 27, 2026
291e126
Remove Proton MsgPack frame header caches
Jokeren May 26, 2026
828e20f
Clarify linked flexible metric JSON placement
Jokeren May 26, 2026
7f8a474
Avoid std::function in Proton MsgPack recursion
Jokeren May 26, 2026
f6b53db
Refactor flexible metrics handling in buildHatchetMsgPack
Jokeren May 26, 2026
7febd86
Tighten Proton linked metric assertions
Jokeren May 26, 2026
db814ea
Revert Proton linked metric test additions
Jokeren May 26, 2026
cfaa437
Constrain linked flexible JSON promotion
Jokeren May 28, 2026
f029f51
Restore Proton MsgPack metric prepass
Jokeren May 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 35 additions & 12 deletions third_party/proton/csrc/include/Data/Metric.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <set>
#include <shared_mutex>
#include <stdexcept>
#include <string_view>
#include <type_traits>
#include <utility>
#include <variant>
Expand Down Expand Up @@ -65,7 +66,7 @@ class Metric {

virtual const std::string &getName() const = 0;

virtual const std::string &getValueName(int valueId) const = 0;
virtual std::string_view getValueName(int valueId) const = 0;

virtual bool isProperty(int valueId) const = 0;

Expand All @@ -81,8 +82,8 @@ class Metric {
if (values[valueId].index() != value.index()) {
throw makeInvalidArgument(
std::string("Metric value type mismatch for valueId ") +
std::to_string(valueId) + " (" + getValueName(valueId) + ")" +
": current=" + getTypeNameForIndex(values[valueId].index()) +
std::to_string(valueId) + " (" + std::string(getValueName(valueId)) +
")" + ": current=" + getTypeNameForIndex(values[valueId].index()) +
", new=" + getTypeNameForIndex(value.index()));
}
// Handle string and other values separately
Expand All @@ -105,7 +106,8 @@ class Metric {
throw makeInvalidArgument(
std::string("Vector metric size mismatch for "
"valueId ") +
std::to_string(valueId) + " (" + getValueName(valueId) +
std::to_string(valueId) + " (" +
std::string(getValueName(valueId)) +
"): current=" + std::to_string(currentValue.size()) +
", new=" + std::to_string(otherValue.size()));
}
Expand All @@ -116,7 +118,8 @@ class Metric {
throw makeLogicError(
std::string("Metric aggregation not supported for "
"valueId ") +
std::to_string(valueId) + " (" + getValueName(valueId) +
std::to_string(valueId) + " (" +
std::string(getValueName(valueId)) +
"): type=" + getTypeNameForIndex(values[valueId].index()));
}
}
Expand Down Expand Up @@ -172,7 +175,8 @@ class FlexibleMetric : public Metric {

const std::string &getName() const override { return name; }

const std::string &getValueName(int valueId) const override {
// Flexible metrics carry their name as per-instance state.
std::string_view getValueName(int valueId) const override {
return valueName;
}

Expand Down Expand Up @@ -219,7 +223,13 @@ class KernelMetric : public Metric {

const std::string &getName() const override { return name; }

const std::string &getValueName(int valueId) const override {
// Fast path for callers that already know they are working with KernelMetric.
static constexpr std::string_view getValueName(kernelMetricKind valueId) {
return VALUE_NAMES[valueId];
}

// Virtual access used through the Metric interface.
std::string_view getValueName(int valueId) const override {
return VALUE_NAMES[valueId];
}

Expand All @@ -232,7 +242,7 @@ class KernelMetric : public Metric {
true, true, false, false, true, true, true, true};
const static inline bool EXCLUSIVE[kernelMetricKind::Count] = {
false, false, false, false, true, true, true, true};
const static inline std::string VALUE_NAMES[kernelMetricKind::Count] = {
static constexpr std::string_view VALUE_NAMES[kernelMetricKind::Count] = {
"start_time (ns)", "end_time (ns)", "count", "time (ns)",
"device_id", "device_type", "stream_id", "is_metric_kernel",
};
Expand Down Expand Up @@ -278,14 +288,21 @@ class PCSamplingMetric : public Metric {

const std::string &getName() const override { return name; }

const std::string &getValueName(int valueId) const override {
// Fast path for callers that already know they are working with
// PCSamplingMetric.
static constexpr std::string_view getValueName(PCSamplingMetricKind valueId) {
return VALUE_NAMES[valueId];
}

// Virtual access used through the Metric interface.
std::string_view getValueName(int valueId) const override {
return VALUE_NAMES[valueId];
}

bool isProperty(int valueId) const override { return false; }
bool isExclusive(int valueId) const override { return false; }

const static inline std::string VALUE_NAMES[PCSamplingMetricKind::Count] = {
static constexpr std::string_view VALUE_NAMES[PCSamplingMetricKind::Count] = {
"num_samples",
"num_stalled_samples",
"stalled_branch_resolving",
Expand Down Expand Up @@ -359,7 +376,13 @@ class CycleMetric : public Metric {

const std::string &getName() const override { return name; }

const std::string &getValueName(int valueId) const override {
// Fast path for callers that already know they are working with CycleMetric.
static constexpr std::string_view getValueName(CycleMetricKind valueId) {
return VALUE_NAMES[valueId];
}

// Virtual access used through the Metric interface.
std::string_view getValueName(int valueId) const override {
return VALUE_NAMES[valueId];
}

Expand All @@ -374,7 +397,7 @@ class CycleMetric : public Metric {
const static inline bool EXCLUSIVE[CycleMetricKind::Count] = {
false, false, true, true, true, true, true, true,
true, true, true, true, false, false, false};
const static inline std::string VALUE_NAMES[CycleMetricKind::Count] = {
static constexpr std::string_view VALUE_NAMES[CycleMetricKind::Count] = {
"start_cycle", "end_cycle", "cycles", "normalized_cycles",
"kernel_id", "kernel_name", "block_id", "processor_id",
"unit_id", "device_id", "device_type", "time_shift_cost",
Expand Down
2 changes: 1 addition & 1 deletion third_party/proton/csrc/include/Profiler/Graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <map>
#include <memory>
#include <mutex>
#include <optional>
#include <set>
#include <shared_mutex>
#include <unordered_map>
Expand Down Expand Up @@ -45,6 +44,7 @@ struct GraphState {
// Capture tag to identify captured call paths
static constexpr const char *captureTag = "<captured_at>";
static constexpr const char *metricTag = "<metric>";

struct NodeState {
// The graph node id for this node
uint64_t nodeId{};
Expand Down
12 changes: 12 additions & 0 deletions third_party/proton/csrc/include/Utility/MsgPackWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <cstddef>
#include <cstdint>
#include <cstring>
#include <string_view>
#include <vector>

Expand All @@ -21,6 +22,17 @@ class MsgPackWriter {
void packInt(int64_t value);
void packDouble(double value);
void packStr(std::string_view value);
template <size_t N> void packFixStrLiteral(const char (&value)[N]) {
static_assert(N > 0);
constexpr uint32_t size = static_cast<uint32_t>(N - 1);
// MsgPack fixstr stores the string length in 5 bits, so literals must fit
// in the 0..31 byte range.
static_assert(size <= 31);
out.push_back(static_cast<uint8_t>(0xa0 | size));
const auto offset = out.size();
out.resize(offset + size);
std::memcpy(out.data() + offset, value, size);
}
void packArray(uint32_t size);
void packMap(uint32_t size);

Expand Down
Loading
Loading