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

SelectMerge latency is high #689

Closed
kolesnikovae opened this issue May 12, 2023 · 3 comments
Closed

SelectMerge latency is high #689

kolesnikovae opened this issue May 12, 2023 · 3 comments

Comments

@kolesnikovae
Copy link
Contributor

kolesnikovae commented May 12, 2023

Most of the queries spend significant time after all the samples were fetched and deduplicated. We need to figure out and fix what causes the latency.

For example, phlare-querier SelectMergeStacktraces:
image

Solving the problem may result in a very significant decrease in the overall query latencies (up to 50%).

It’s very likely that this is caused by pulling and merging resolved stacks from the ingesters: the size of the payload may be quite big. If this is the case, we may want to find a way to reduce it, e.g. by stack truncation:
image

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. That would also decrease CPU time of the query execution, and allocations as well:
image
image

@kolesnikovae
Copy link
Contributor Author

Also related: grafana/pyroscope#2107

@cyriltovena
Copy link
Collaborator

Based on our discussions I think this is a great idea to use an opaque format for the internal API. We should use the Pyroscope tree package https://github.com/grafana/pyroscope/blob/254c5759900d3a2da6e6dfaf4ef2767c05cb45bb/pkg/storage/tree/tree.go between query-frontend - querier - ingester and store-gateway.

@kolesnikovae
Copy link
Contributor Author

#702 reduces the query duration 2-3 times in certain cases:

Image

As a bonus, resource consumption also decreased:

Image

Closing the issue for now

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants