-
Notifications
You must be signed in to change notification settings - Fork 73
Use pyroscope tree representation in MergeProfilesStacktraces API #702
Conversation
message MergeProfilesStacktracesResult { | ||
StacktracesMergeFormat format = 3; | ||
// The list of stracktraces with their respective value | ||
repeated StacktraceSample stacktraces = 1; | ||
repeated string function_names = 2; | ||
// Merge result marshaled to pyroscope tree bytes. | ||
bytes tree_bytes = 4; | ||
} | ||
|
||
enum StacktracesMergeFormat { | ||
MERGE_FORMAT_UNSPECIFIED = 0; | ||
MERGE_FORMAT_STACKTRACES = 1; | ||
MERGE_FORMAT_TREE = 2; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about using oneof
but decided to use an explicit enum (because eventually we should use a single format).
I don't feel strong about that – please let me know if you want me to change it
lock.Lock() | ||
defer lock.Unlock() | ||
result = append(result, merge) | ||
m.MergeStackTraces(merge.Stacktraces, merge.FunctionNames) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be better if we return the tree directly from the q.MergeByStacktraces
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good point. I'd experiment with this. My idea was to merge samples to the tree (in batches) directly in MergeByStacktraces
, and pass the merger as an argument. However, I wasn't 100% sure if this approach is more efficient, and I didn't want to delay shipping of this feature
Result: phlaremodel.MergeBatchMergeStacktraces(result...), | ||
Result: &ingestv1.MergeProfilesStacktracesResult{ | ||
Format: ingestv1.StacktracesMergeFormat_MERGE_FORMAT_TREE, | ||
TreeBytes: m.TreeBytes(r.GetMaxNodes()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, really nice this is backward compatible.
f814b2e
to
449af86
Compare
…afana/phlare#702) * Add pyroscope tree to the MergeProfilesStacktracesResult type * Add support for multiple merge result formats * Refactor tree and flamegraph types to the model package * Update reference-configuration-parameters * Add stack truncation implementation notes * Implement tree merge * Fix tree merge * Fix stacktrace rewrite * Refine tree merge * Fix tests * Refactor unused functions * Remove dead code * Fix tree min value counting
The PR is aimed at decreasing querier-ingester latency. See #689: