prometheus/model/histogram
Filip Petkovski 583f3e587c
Optimize histogram iterators (#13340)
Optimize histogram iterators

Histogram iterators allocate new objects in the AtHistogram and
AtFloatHistogram methods, which makes calculating rates over long
ranges expensive.

In #13215 we allowed an existing object to be reused
when converting an integer histogram to a float histogram. This commit follows
the same idea and allows injecting an existing object in the AtHistogram and
AtFloatHistogram methods. When the injected value is nil, iterators allocate
new histograms, otherwise they populate and return the injected object.

The commit also adds a CopyTo method to Histogram and FloatHistogram which
is used in the BufferedIterator to overwrite items in the ring instead of making
new copies.

Note that a specialized HPoint pool is needed for all of this to work 
(`matrixSelectorHPool`).

---------

Signed-off-by: Filip Petkovski <filip.petkovsky@gmail.com>
Co-authored-by: George Krajcsovits <krajorama@users.noreply.github.com>
2024-01-23 17:02:14 +01:00
..
float_histogram.go Optimize histogram iterators (#13340) 2024-01-23 17:02:14 +01:00
float_histogram_test.go Optimize histogram iterators (#13340) 2024-01-23 17:02:14 +01:00
generic.go Reuse slices in [Float]Histogram.ReduceResolution 2023-11-28 15:45:31 +02:00
generic_test.go fix slice copy in 1.20 (#13389) 2024-01-16 11:06:58 +00:00
histogram.go Optimize histogram iterators (#13340) 2024-01-23 17:02:14 +01:00
histogram_test.go Optimize histogram iterators (#13340) 2024-01-23 17:02:14 +01:00
test_utils.go Move histogram validation code to model/histogram 2023-11-03 16:17:24 +02:00