prometheus/rules
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
..
fixtures
alerting.go ci(lint): enable godot; append dot at the end of comments 2023-10-31 19:53:38 +02:00
alerting_test.go golangci-lint: enable testifylint linter (#13254) 2023-12-07 11:35:01 +00:00
group.go Address PR feedback 2023-10-31 09:56:05 +11:00
manager.go ci(lint): enable godot; append dot at the end of comments 2023-10-31 19:53:38 +02:00
manager_test.go Optimize histogram iterators (#13340) 2024-01-23 17:02:14 +01:00
origin.go Panic if rule type was not expected 2023-01-20 10:27:50 +02:00
origin_test.go lint: Adjust to the lint warnings raised by current versions of golint-ci 2023-04-19 17:10:10 +02:00
recording.go labels: simplify call to get Labels from Builder 2023-03-22 17:05:20 +00:00
recording_test.go promql: allow tests to be imported (#12050) 2023-08-18 20:48:59 +02:00
rule.go Refactoring manager.go into separate concerns 2023-10-21 11:11:11 +02:00