grafana / pyroscope

Continuous Profiling Platform. Debug performance issues down to a single line of code
https://grafana.com/oss/pyroscope/
GNU Affero General Public License v3.0
10.14k stars 614 forks source link

Add an option to limit the number of series returned in `SelectSeries` API #3593

Closed kolesnikovae closed 1 month ago

kolesnikovae commented 2 months ago

SelectSeries always returns all time series in a single response. In many cases, only a subset of the series is actually used (for example, in Explore Profiles, we only show the top 10).

As a quick optimization, we could add a parameter that limits the number of series returned, something like:

message Limit {
   int32 top_k_total = 1;
}

Note that the limit should be applied in the query frontend, after all the series have been collected. Later on, we can implement a fully-fledged time-series query engine capable of handling PromQL syntax (or a subset)