Skip to content
This repository has been archived by the owner on Jul 19, 2023. It is now read-only.

Use pyroscope tree representation in MergeProfilesStacktraces API #702

Merged
merged 14 commits into from
May 24, 2023

Conversation

kolesnikovae
Copy link
Contributor

@kolesnikovae kolesnikovae commented May 18, 2023

The PR is aimed at decreasing querier-ingester latency. See #689:

We may want to optimize the representation of results in this API: notice that stacks take appx. 50MB (encoded in protobuf). We should consider building a truncated tree (w/o insignificant nodes) as close to the storage as possible, instead of passing an array of stack traces along the way

@kolesnikovae kolesnikovae changed the title Use pyroscope tree representation in SelectMergeStacktraces API Use pyroscope tree representation in MergeProfilesStacktraces API May 18, 2023
Comment on lines 55 to 68
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;
}
Copy link
Contributor Author

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

@kolesnikovae kolesnikovae marked this pull request as ready for review May 23, 2023 17:59
lock.Lock()
defer lock.Unlock()
result = append(result, merge)
m.MergeStackTraces(merge.Stacktraces, merge.FunctionNames)
Copy link
Collaborator

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 ?

Copy link
Contributor Author

@kolesnikovae kolesnikovae May 24, 2023

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

pkg/model/tree.go Outdated Show resolved Hide resolved
Result: phlaremodel.MergeBatchMergeStacktraces(result...),
Result: &ingestv1.MergeProfilesStacktracesResult{
Format: ingestv1.StacktracesMergeFormat_MERGE_FORMAT_TREE,
TreeBytes: m.TreeBytes(r.GetMaxNodes()),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

Copy link
Collaborator

@cyriltovena cyriltovena left a 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.

@kolesnikovae kolesnikovae force-pushed the feat/proflie-tree-representation branch from f814b2e to 449af86 Compare May 24, 2023 09:58
@kolesnikovae kolesnikovae merged commit c7d96b7 into main May 24, 2023
@kolesnikovae kolesnikovae deleted the feat/proflie-tree-representation branch May 24, 2023 10:13
simonswine pushed a commit to simonswine/pyroscope that referenced this pull request Jun 30, 2023
…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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants