app/vmselect/promql: re-use metrics.Histogram when calculating histogram function for each point on the graph

This should reduce the amounts memory allocations
This commit is contained in:
Aliaksandr Valialkin 2019-11-25 14:23:35 +02:00
parent 0f184affa7
commit f46fb6c740

View File

@ -187,9 +187,10 @@ func aggrFuncGeomean(tss []*timeseries) []*timeseries {
} }
func aggrFuncHistogram(tss []*timeseries) []*timeseries { func aggrFuncHistogram(tss []*timeseries) []*timeseries {
var h metrics.Histogram
m := make(map[string]*timeseries) m := make(map[string]*timeseries)
for i := range tss[0].Values { for i := range tss[0].Values {
var h metrics.Histogram h.Reset()
for _, ts := range tss { for _, ts := range tss {
v := ts.Values[i] v := ts.Values[i]
h.Update(v) h.Update(v)